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 query_error _db_init()
29 query_error error_code = QUERY_SUCCESS;
34 rc = db_util_open(CALENDAR_DB_PATH, &hDBCt, 0);
36 error_code = QUERY_FAIL;
41 query_error _db_finish()
44 query_error error_code = QUERY_SUCCESS;
47 if(db_connnect_count == 0)
49 rc = db_util_close(hDBCt);
51 error_code = QUERY_FAIL;
58 query_error _exec_query(char* query)
61 char* pszErrorMsg = NULL;
62 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 _query_step(stmt pStmt)
79 return sqlite3_step(pStmt);
82 void _contact_query_finalize(stmt pStmt)
89 rc = sqlite3_finalize(pStmt);
95 int _calendar_query_column_int(stmt pStmt, int pos)
97 return (int)sqlite3_column_int(pStmt, pos);
100 char* _calendar_query_column_text(stmt pStmt, int pos)
102 return (char *)sqlite3_column_text(pStmt, pos);
105 void _query_finalize(stmt pStmt)
112 rc = sqlite3_finalize(pStmt);
119 int _query_bind_double(stmt pStmt, int pos, double num)
121 return sqlite3_bind_double(pStmt, pos, num);
124 int _query_bind_int(stmt pStmt, int pos, int num)
126 return sqlite3_bind_int(pStmt, pos, num);
129 int _query_bind_text(stmt pStmt, int pos, char* str)
135 return sqlite3_bind_text(pStmt, pos, (const char*)str, len, SQLITE_STATIC);
140 void _query_stmt_reset(stmt stmt)
143 sqlite3_clear_bindings(stmt);
146 int _query_column_int(stmt pStmt, int pos)
148 return sqlite3_column_int(pStmt, pos);
151 double _query_column_double(stmt pStmt, int pos)
153 return sqlite3_column_double(pStmt, pos);
156 char* _query_column_text(stmt pStmt, int pos)
158 return (char *)sqlite3_column_text(pStmt, pos);
161 stmt _query_prepare(char *query)
166 printf("\nquery : %s !!!!\n", query);
168 rc = sqlite3_prepare_v2(hDBCt, query, strlen(query), &pStmt, NULL);