|
1 // Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // SQL DDL statements |
|
15 // |
|
16 // |
|
17 |
|
18 #include "UQ_STD.H" |
|
19 |
|
20 // Class CSqlCreateTableStatement |
|
21 |
|
22 CDbIncremental* CSqlCreateTableStatement::ExecuteL(CDbDatabase& aDatabase,TDbTextComparison,TInt& aStep) |
|
23 { |
|
24 aDatabase.CreateTableL(iName,iColumns,0); |
|
25 aStep=0; |
|
26 return 0; |
|
27 } |
|
28 |
|
29 // Class CSqlDropTableStatement |
|
30 |
|
31 CDbIncremental* CSqlDropTableStatement::ExecuteL(CDbDatabase& aDatabase,TDbTextComparison,TInt& aStep) |
|
32 { |
|
33 return aDatabase.DropTableL(iName,aStep); |
|
34 } |
|
35 |
|
36 // Class CSqlAlterTableStatement |
|
37 |
|
38 CSqlAlterTableStatement::~CSqlAlterTableStatement() |
|
39 { |
|
40 iDrop.Close(); |
|
41 } |
|
42 |
|
43 CDbIncremental* CSqlAlterTableStatement::ExecuteL(CDbDatabase& aDatabase,TDbTextComparison,TInt& aStep) |
|
44 { |
|
45 CDbColSet* set=CDbColSet::NewLC(); |
|
46 aDatabase.ColumnsL(*set,iName); |
|
47 TInt todrop=iDrop.Count(); |
|
48 for (TDbColSetIter iter(*set);iter;++iter) |
|
49 { |
|
50 TInt ii=-1; |
|
51 for (;;) |
|
52 { |
|
53 if (++ii==todrop) |
|
54 { |
|
55 iAdd.AddL(*iter); |
|
56 break; |
|
57 } |
|
58 if (iter->iName.CompareF(iDrop[ii])==0) |
|
59 { |
|
60 iDrop.Remove(ii); |
|
61 --todrop; |
|
62 break; |
|
63 } |
|
64 } |
|
65 } |
|
66 if (todrop!=0) |
|
67 __LEAVE(KErrNotFound); |
|
68 CleanupStack::PopAndDestroy(); // set |
|
69 return aDatabase.AlterTableL(iName,iAdd,aStep); |
|
70 } |
|
71 |
|
72 // Class CSqlCreateIndexStatement |
|
73 |
|
74 CDbIncremental* CSqlCreateIndexStatement::ExecuteL(CDbDatabase& aDatabase,TDbTextComparison aComparison,TInt& aStep) |
|
75 { |
|
76 iKey.SetComparison(aComparison); |
|
77 return aDatabase.CreateIndexL(iName,iTable,iKey,aStep); |
|
78 } |
|
79 |
|
80 // Class CSqlDropIndexStatement |
|
81 |
|
82 CDbIncremental* CSqlDropIndexStatement::ExecuteL(CDbDatabase& aDatabase,TDbTextComparison,TInt& aStep) |
|
83 { |
|
84 return aDatabase.DropIndexL(iName,iTable,aStep); |
|
85 } |