phonebookengines/contactsmodel/cntplsql/inc/dbsqlconstants.h
changeset 24 0ba2181d7c28
parent 0 e686773b3f54
child 25 76a2435edfd4
equal deleted inserted replaced
0:e686773b3f54 24:0ba2181d7c28
     1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
     1 /*
     2 // All rights reserved.
     2 * Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
     3 // This component and the accompanying materials are made available
     3 * All rights reserved.
     4 // under the terms of "Eclipse Public License v1.0"
     4 * This component and the accompanying materials are made available
     5 // which accompanies this distribution, and is available
     5 * under the terms of "Eclipse Public License v1.0"
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     6 * which accompanies this distribution, and is available
     7 //
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     8 // Initial Contributors:
     8 *
     9 // Nokia Corporation - initial contribution.
     9 * Initial Contributors:
    10 //
    10 * Nokia Corporation - initial contribution.
    11 // Contributors:
    11 *
    12 //
    12 * Contributors:
    13 // Description:
    13 *
    14 //
    14 * Description: 
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef DBSQLCONSTANTS_H
       
    19 #define DBSQLCONSTANTS_H
    15 
    20 
    16 #include <cntdef.hrh>
    21 #include <cntdef.hrh>
    17 
    22 
    18 const TInt KInitialValue = -1;
    23 const TInt KInitialValue = -1;
    19 const TInt KNumOfTables = 4;
    24 const TInt KNumOfTables = 5;
    20 const TInt KNumColInPrefTable = 6;
    25 const TInt KNumColInPrefTable = 6;
    21 const TInt KNumColInContactTable = 16;
    26 const TInt KNumColInContactTable = 16;
    22 const TInt KNumColInGroupTable = 3;
    27 const TInt KNumColInGroupTable = 3;
    23 const TInt KNumColInCommTable = 5;
    28 const TInt KNumColInCommTable = 5;
       
    29 const TInt KNumColInPredSearchTable = 4;
       
    30 const TInt KNumColInPresenceTable = 5;
    24 
    31 
    25 // tables in the contact database 
    32 // tables in the contact database 
    26 _LIT(KSqlContactTableName,"contact");
    33 _LIT(KSqlContactTableName,"contact");
    27 _LIT(KSqlContactGroupTableName,"groups");
    34 _LIT(KSqlContactGroupTableName,"groups");
    28 _LIT(KSqlContactPrefTableName,"preferences");
    35 _LIT(KSqlContactPrefTableName,"preferences");
    29 _LIT(KSqlContactCommAddrTableName,"comm_addr");
    36 _LIT(KSqlContactCommAddrTableName,"comm_addr");
       
    37 _LIT(KSqlContactPredSearchTableName,"predictivesearch");
       
    38 _LIT(KSqlContactPresenceTableName, "presence");
    30 
    39 
    31 enum TDatabaseTables
    40 enum TDatabaseTables
    32 	{
    41 	{
    33 	EContactPrefTableName,
    42 	EContactPrefTableName,
    34 	EContactTableName,
    43 	EContactTableName,
    35 	EContactGroupTableName,
    44 	EContactGroupTableName,
    36 	EContactCommAddressTableName
    45 	EContactCommAddressTableName,
       
    46 	KContactPredSearchTableName
    37 	};
    47 	};
    38 
    48 
    39 // columns for contact table
    49 // columns for contact table
    40 _LIT(KContactId, "contact_id");
    50 _LIT(KContactId, "contact_id");
    41 _LIT(KContactTemplateId, "template_id");
    51 _LIT(KContactTemplateId, "template_id");
   133 
   143 
   134 // create statements
   144 // create statements
   135 _LIT(KPreferencesCreateStmnt,  "CREATE TABLE preferences (preference_id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, data_schema_version INTEGER NOT NULL, preferred_cardtemplate_id INTEGER, machine_id , creation_date , preferred_sortorder BLOB); ");
   145 _LIT(KPreferencesCreateStmnt,  "CREATE TABLE preferences (preference_id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, data_schema_version INTEGER NOT NULL, preferred_cardtemplate_id INTEGER, machine_id , creation_date , preferred_sortorder BLOB); ");
   136 // end preferences table
   146 // end preferences table
   137 
   147 
   138 
   148 // predictive search table
       
   149 // columns
       
   150 _LIT(KPredSearchFirstNameAsNumber, "first_name_as_number");
       
   151 _LIT(KPredSearchLastNameAsNumber, "last_name_as_number");
       
   152 _LIT(KPredSearchCompanyNameAsNumber, "company_name_as_number");
       
   153 _LIT(KPredSearchContactId, "contact_id");
       
   154 // Do not store names. They can be looked up from contact table.
       
   155 // Do not store phone number. It can be searched from comm-address table.
       
   156 
       
   157 // parameters
       
   158 _LIT(KPredSearchFirstNameAsNumberParam, ":first_name_as_number");
       
   159 _LIT(KPredSearchLastNameAsNumberParam, ":last_name_as_number");
       
   160 _LIT(KPredSearchCompanyNameAsNumberParam, ":company_name_as_number");
       
   161 _LIT(KPredSearchContactIdParam, ":contact_id");
       
   162 
       
   163 // create statements
       
   164 _LIT(KPredSearchCreateStmnt,
       
   165 "CREATE TABLE predictivesearch (first_name_as_number VARCHAR(255) NULL,\
       
   166  last_name_as_number VARCHAR(255) NULL,\
       
   167  company_name_as_number VARCHAR(255) NULL, contact_id INTEGER);");
       
   168  
       
   169 // create table index
       
   170 _LIT(KPredSearchCreateIndex,
       
   171 "CREATE INDEX index_last_name_as_number \
       
   172 on predictivesearch (last_name_as_number, first_name_as_number );");
       
   173  
       
   174 _LIT(KPredSearchCreateView1,
       
   175 "CREATE VIEW view1 AS SELECT contact_id, last_name_as_number, first_name_as_number  FROM predictivesearch \
       
   176 WHERE (first_name_as_number LIKE \"%% 1%%\") OR (last_name_as_number LIKE \"%% 1%%\")");
       
   177 
       
   178 _LIT(KPredSearchCreateView2,
       
   179 "CREATE VIEW view2 AS SELECT contact_id, last_name_as_number, first_name_as_number FROM predictivesearch \
       
   180 WHERE (first_name_as_number LIKE \"%% 2%%\") OR (last_name_as_number LIKE \"%% 2%%\")");
       
   181 
       
   182 _LIT(KPredSearchCreateView3,
       
   183 "CREATE VIEW view3 AS SELECT contact_id, last_name_as_number, first_name_as_number FROM predictivesearch \
       
   184 WHERE (first_name_as_number LIKE \"%% 3%%\") OR (last_name_as_number LIKE \"%% 3%%\")");
       
   185 
       
   186 _LIT(KPredSearchCreateView4,
       
   187 "CREATE VIEW view4 AS SELECT contact_id, last_name_as_number, first_name_as_number FROM predictivesearch \
       
   188 WHERE (first_name_as_number LIKE \"%% 4%%\") OR (last_name_as_number LIKE \"%% 4%%\")");
       
   189 
       
   190 _LIT(KPredSearchCreateView5,
       
   191 "CREATE VIEW view5 AS SELECT contact_id, last_name_as_number, first_name_as_number FROM predictivesearch \
       
   192 WHERE (first_name_as_number LIKE \"%% 5%%\") OR (last_name_as_number LIKE \"%% 5%%\")");
       
   193 
       
   194 _LIT(KPredSearchCreateView6,
       
   195 "CREATE VIEW view6 AS SELECT contact_id, last_name_as_number, first_name_as_number FROM predictivesearch \
       
   196 WHERE (first_name_as_number LIKE \"%% 6%%\") OR (last_name_as_number LIKE \"%% 6%%\")");
       
   197 
       
   198 _LIT(KPredSearchCreateView7,
       
   199 "CREATE VIEW view7 AS SELECT contact_id, last_name_as_number, first_name_as_number FROM predictivesearch \
       
   200 WHERE (first_name_as_number LIKE \"%% 7%%\") OR (last_name_as_number LIKE \"%% 7%%\")");
       
   201 
       
   202 _LIT(KPredSearchCreateView8,
       
   203 "CREATE VIEW view8 AS SELECT contact_id, last_name_as_number, first_name_as_number FROM predictivesearch \
       
   204 WHERE (first_name_as_number LIKE \"%% 8%%\") OR (last_name_as_number LIKE \"%% 8%%\")");
       
   205 
       
   206 _LIT(KPredSearchCreateView9,
       
   207 "CREATE VIEW view9 AS SELECT contact_id, last_name_as_number, first_name_as_number FROM predictivesearch \
       
   208 WHERE (first_name_as_number LIKE \"%% 9%%\") OR (last_name_as_number LIKE \"%% 9%%\")");
       
   209 
       
   210 _LIT(KPredSearchCreateView0,
       
   211 "CREATE VIEW view0 AS SELECT contact_id, last_name_as_number, first_name_as_number FROM predictivesearch \
       
   212 WHERE (first_name_as_number LIKE \"%% 0%%\") OR (last_name_as_number LIKE \"%% 0%%\")");
       
   213 
       
   214 _LIT(KPresenceContactId, "contact_id");
       
   215 _LIT(KPresenceAccountUri, "account_uri");
       
   216 _LIT(KPresenceServiceName, "service_name");
       
   217 _LIT(KPresenceStatus, "status");
       
   218 _LIT(KPresenceStatusMsg, "status_message");
       
   219 _LIT(KPresenceContactIdParam, ":contact_id");
       
   220 _LIT(KPresenceAccountUriParam, ":account_uri");
       
   221 _LIT(KPresenceServiceNameParam, ":service_name");
       
   222 _LIT(KPresenceStatusParam, ":status");
       
   223 _LIT(KPresenceStatusMsgParam, ":status_message");
       
   224 _LIT(KPresenceCreateStmnt,
       
   225 "CREATE TABLE presence (contact_id INTEGER NOT NULL,\
       
   226 account_uri VARCHAR(255),service_name VARCHAR(255),\
       
   227 status INTEGER, status_msg VARCHAR(255),\
       
   228 CONSTRAINT contactid_fk FOREIGN KEY (contact_id) REFERENCES contact(contact_id) ON DELETE CASCADE);"); 
   139 // Condition strings for searching id
   229 // Condition strings for searching id
   140 _LIT(KSelectCondition_SearchForEqual,   "%S == :SeekId");
   230 _LIT(KSelectCondition_SearchForEqual,   "%S == :SeekId");
   141 
   231 
   142 // SQLITE_SEQUENCE table stuff for getting last row_id
   232 // SQLITE_SEQUENCE table stuff for getting last row_id
   143 _LIT(KSelectLastIdSqlStmnt, "SELECT seq FROM SQLITE_SEQUENCE WHERE name = 'contact';");
   233 _LIT(KSelectLastIdSqlStmnt, "SELECT seq FROM SQLITE_SEQUENCE WHERE name = 'contact';");
   253 	ENumberOfFastAccessFields,
   343 	ENumberOfFastAccessFields,
   254 	ENoSuchFastAccessField = -1
   344 	ENoSuchFastAccessField = -1
   255 	};
   345 	};
   256 
   346 
   257 const TInt KFirstIndex = 0;
   347 const TInt KFirstIndex = 0;
       
   348 
       
   349 #endif // #ifndef DBSQLCONSTANTS_H