2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 #include "CalendarQuery.h"
19 #include <unicode/ucol.h>
24 static int db_connnect_count = 0;
26 calendar_query_error calendar_db_init()
29 calendar_query_error error_code = QUERY_SUCCESS;
34 rc = db_util_open(CALENDAR_DB_PATH, &hDBCt, 0);
36 error_code = QUERY_FAIL;
41 calendar_query_error calendar_db_finish()
44 calendar_query_error error_code = QUERY_SUCCESS;
47 if(db_connnect_count == 0)
49 rc = db_util_close(hDBCt);
51 error_code = QUERY_FAIL;
58 calendar_query_error calendar_exec_query(char* query)
61 char* pszErrorMsg = NULL;
62 calendar_query_error error_code = QUERY_SUCCESS;
64 rc = sqlite3_exec(hDBCt, query, NULL, NULL, &pszErrorMsg);
68 error_code = QUERY_FAIL;
72 sqlite3_free(pszErrorMsg);
77 int calendar_query_step(stmt pStmt)
79 return sqlite3_step(pStmt);
82 void calendar_query_finalize(stmt pStmt)
89 rc = sqlite3_finalize(pStmt);
96 int calendar_query_bind_double(stmt pStmt, int pos, double num)
98 return sqlite3_bind_double(pStmt, pos, num);
101 int calendar_query_bind_int(stmt pStmt, int pos, int num)
103 return sqlite3_bind_int(pStmt, pos, num);
106 int calendar_query_bind_text(stmt pStmt, int pos, char* str)
112 return sqlite3_bind_text(pStmt, pos, (const char*)str, len, SQLITE_STATIC);
117 void calendar_query_stmt_reset(stmt stmt)
120 sqlite3_clear_bindings(stmt);
123 int calendar_query_column_int(stmt pStmt, int pos)
125 return sqlite3_column_int(pStmt, pos);
128 double calendar_query_column_double(stmt pStmt, int pos)
130 return sqlite3_column_double(pStmt, pos);
133 char* calendar_query_column_text(stmt pStmt, int pos)
135 return (char *)sqlite3_column_text(pStmt, pos);
138 stmt calendar_query_prepare(char *query)
143 printf("\nquery : %s !!!!\n\n", query);
145 rc = sqlite3_prepare_v2(hDBCt, query, strlen(query), &pStmt, NULL);