Read-only archive of the All About Symbian forum (2001–2013) · About this archive

Database programming?

1 replies · 1,888 views · Started 17 November 2002

Any experts on Symboan OS database programming? I know how to write a simple db handling that uses fixed table structure and hard coded field names. How can I extend this to be more dynamic, i.e. user could add and delete fields and change their labels?

The sdk contains function to change the tables and to query the existing tables. The following functions, defined in RDbDatabase, should help you to get the current state of the database.

[code:1]CDbTableNames* TableNamesL() const;
CDbColSet* ColSetL(const TDesC& aName) const;
CDbIndexNames* IndexNamesL(const TDesC& aTable) const;[/code:1]
This will give you an indication of all the user defined tables and fields. After that, you can use the following functions to change the database when the user adds/deletes/renames fields or tables.

[code:1]TInt AlterTable(const TDesC& aName,const CDbColSet& aNewDef);
TInt CreateIndex(const TDesC& aName,const TDesC& aTable,const CDbKey& aKey);
TInt DropIndex(const TDesC& aName,const TDesC& aTable);
TInt DropTable(const TDesC& aName);[/code:1]