|
1 // Copyright (c) 2006-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 // |
|
15 |
|
16 |
|
17 #include "dbutility.h" |
|
18 #include "d32dbms.h" |
|
19 |
|
20 /** |
|
21 Check if the table exists in the database. |
|
22 @param aDatabase the database to use |
|
23 @param aTableName the table name to check |
|
24 @return ETrue if exists, otherwise, EFalse |
|
25 */ |
|
26 TBool DBUtility::IsTableExistsL(RDbDatabase& aDatabase, const TDesC& aTableName) |
|
27 { |
|
28 TBool result = EFalse; |
|
29 CDbTableNames* tableNames = aDatabase.TableNamesL(); |
|
30 CleanupStack::PushL(tableNames); |
|
31 if(tableNames) |
|
32 { |
|
33 const TInt count = tableNames->Count(); |
|
34 for(TInt i = 0; i < count; i++) |
|
35 { |
|
36 if((*tableNames)[i] == aTableName) |
|
37 { |
|
38 result = ETrue; |
|
39 break; |
|
40 } |
|
41 } |
|
42 } |
|
43 CleanupStack::PopAndDestroy(tableNames); |
|
44 return result; |
|
45 } |
|
46 |
|
47 /** |
|
48 Check if the specified index exists in the table. |
|
49 @param aDatabase the database to use |
|
50 @param aTableName the table name to use |
|
51 @param aIndexName the index name to check |
|
52 @return ETrue if the index exists, otherwise, EFalse |
|
53 */ |
|
54 TBool DBUtility::IsIndexExistsL(RDbDatabase& aDatabase, const TDesC& aTableName, const TDesC& aIndexName) |
|
55 { |
|
56 TBool result = EFalse; |
|
57 CDbIndexNames* indexNames = aDatabase.IndexNamesL(aTableName); |
|
58 CleanupStack::PushL(indexNames); |
|
59 if(indexNames) |
|
60 { |
|
61 const TInt count = indexNames->Count(); |
|
62 for(TInt i = 0; i < count; i++) |
|
63 { |
|
64 if((*indexNames)[i] == aIndexName) |
|
65 { |
|
66 result = ETrue; |
|
67 break; |
|
68 } |
|
69 } |
|
70 } |
|
71 CleanupStack::PopAndDestroy(indexNames); |
|
72 return result; |
|
73 } |