|
1 /* |
|
2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef C_CPSSQL_H |
|
20 #define C_CPSSQL_H |
|
21 #ifdef CONTENT_PUBLISHER_STORAGE_MT |
|
22 _LIT( KCPpathdatabase, "c:\\cpdatastorage.sq" ); |
|
23 #endif |
|
24 |
|
25 _LIT( KCPdatabase, "[20016B7B]cpdatastorage.sq" ); |
|
26 _LIT( KCPdatabaseDrive, "C:" ); |
|
27 _LIT8( KMdsSqlDbaConfig, |
|
28 "cache_size=10000; page_size=4096; encoding=\"UTF-8\";" ); |
|
29 |
|
30 //Create Tables |
|
31 _LIT( KSQLCreateMainTable, |
|
32 "CREATE TABLE CP_MAIN_TABLE( Id INTEGER PRIMARY KEY ,\ |
|
33 Publisher TEXT NOT NULL,\ |
|
34 Content_type TEXT NOT NULL,\ |
|
35 Content_id TEXT NOT NULL,\ |
|
36 Expiration_date BIGINT NOT NULL,\ |
|
37 Data BLOB, \ |
|
38 Action BLOB, \ |
|
39 UNIQUE( Publisher, Content_type, Content_id ));" ); |
|
40 |
|
41 _LIT( KSQLCreatePublisherTable, |
|
42 "CREATE TABLE CP_PUBLISHER_TABLE( Id INTEGER PRIMARY KEY ,\ |
|
43 Publisher TEXT NOT NULL,\ |
|
44 Content_type TEXT NOT NULL,\ |
|
45 Content_id TEXT NOT NULL, \ |
|
46 Data BLOB, \ |
|
47 UNIQUE( Publisher, Content_type, Content_id ));" ); |
|
48 |
|
49 //Create Indexes |
|
50 _LIT( KSQLIndexOnMain_Publisher, |
|
51 "CREATE INDEX Main_PublisherIndex ON CP_MAIN_TABLE(Publisher);" ); |
|
52 _LIT( KSQLIndexOnMain_Content_type, |
|
53 "CREATE INDEX Main_Content_typeIndex ON CP_MAIN_TABLE(Content_type);" ); |
|
54 |
|
55 _LIT( KSQLIndexOnPub_Content_type, |
|
56 "CREATE INDEX Pub_Content_typeIndex ON CP_PUBLISHER_TABLE(Content_type);" ); |
|
57 _LIT( KSQLIndexOnPub_Content_type_Content_id, |
|
58 "CREATE INDEX Pub_Content_type_Content_Id_Index ON CP_PUBLISHER_TABLE(Content_type,Content_id);" ); |
|
59 |
|
60 //Insert Data |
|
61 //Update Data |
|
62 _LIT( KSQLUpdateComplete, |
|
63 "UPDATE CP_MAIN_TABLE SET \ |
|
64 Data = :Data, Action = :Action WHERE Id = :Id " ); |
|
65 |
|
66 _LIT( KSQLUpdateData, |
|
67 "UPDATE CP_MAIN_TABLE SET \ |
|
68 Data = :Data WHERE Id = :Id " ); |
|
69 |
|
70 _LIT( KSQLUpdateAction, |
|
71 "UPDATE CP_MAIN_TABLE SET \ |
|
72 Action = :Action WHERE Id = :Id " ); |
|
73 |
|
74 _LIT( KSQLInsert, |
|
75 "INSERT INTO CP_MAIN_TABLE (Publisher,Content_type,Content_id,Expiration_date,Data,Action) VALUES ( \ |
|
76 :Publisher,\ |
|
77 :Content_type,\ |
|
78 :Content_id,\ |
|
79 :Expiration_date,\ |
|
80 :Data,\ |
|
81 :Action )" ); |
|
82 |
|
83 //Delete Data |
|
84 _LIT( KSQLDelete, "DELETE FROM CP_MAIN_TABLE WHERE " ); |
|
85 |
|
86 //Get Data |
|
87 _LIT( KSQLGetLastInsertId, "SELECT last_insert_rowid() " ); |
|
88 _LIT( KSQLGetList, |
|
89 "SELECT Id,Publisher,Content_type,Content_id,Expiration_date,Data,Action FROM CP_MAIN_TABLE WHERE " ); |
|
90 _LIT( KSQLGetIds, |
|
91 "SELECT Id,Publisher,Content_type,Content_id FROM CP_MAIN_TABLE WHERE " ); |
|
92 _LIT( KSQLGetAction, "SELECT Id, Action FROM CP_MAIN_TABLE WHERE " ); |
|
93 _LIT( KSQLGetPublisher, "Publisher = :Publisher" ); |
|
94 _LIT( KSQLGetContentType, "Content_type = :Content_type" ); |
|
95 _LIT( KSQLGetContentId, "Content_id = :Content_id" ); |
|
96 _LIT( KSQLGetId, "Id = :Id" ); |
|
97 _LIT( KAnd, " AND " ); |
|
98 |
|
99 _LIT( KSQLFetchId, |
|
100 "SELECT Id FROM CP_MAIN_TABLE WHERE Publisher =:Publisher AND Content_type=:Content_type AND Content_id =:Content_id" ); |
|
101 _LIT( KSQLFetchIds, |
|
102 "SELECT Publisher,Content_type,Content_id FROM CP_MAIN_TABLE WHERE Id =:Id" ); |
|
103 |
|
104 _LIT( KSQLPublisher, ":Publisher" ); |
|
105 _LIT( KSQLContent_type, ":Content_type" ); |
|
106 _LIT( KSQLContent_id, ":Content_id" ); |
|
107 _LIT( KSQLExpiration_date, ":Expiration_date" ); |
|
108 _LIT( KSQLData, ":Data" ); |
|
109 _LIT( KSQLAction, ":Action" ); |
|
110 _LIT( KSQLId, ":Id" ); |
|
111 |
|
112 _LIT( KSQLOrderRecent, " ORDER BY Id DESC" ); |
|
113 _LIT( KSQLOrderPublisher, " ORDER BY Publisher" ); |
|
114 _LIT( KSQLOrderContent, " ORDER BY Content_type" ); |
|
115 |
|
116 _LIT( KColumnId, "Id" ); |
|
117 _LIT( KColumnPublisher, "Publisher" ); |
|
118 _LIT( KColumnContent_type, "Content_type" ); |
|
119 _LIT( KColumnContent_id, "Content_id" ); |
|
120 _LIT( KColumnExpiration_date, "Expiration_date" ); |
|
121 _LIT( KColumnData, "Data" ); |
|
122 _LIT( KColumnAction, "Action" ); |
|
123 |
|
124 _LIT8( KList, "List" ); |
|
125 |
|
126 #endif //C_CPSSQL_H |