2

I am creating a table in BB 10 cascades like

  const QString query("CREATE TABLE IF NOT EXISTS push (seqnum INTEGER PRIMARY KEY AUTOINCREMENT, pushdate TEXT, type TEXT, pushtime TEXT,alertId TEXT, extension TEXT, content BLOB, unread INTEGER);");

now how can i check if table created/existed already? Is there any query for that?

help me, Thanks

Sharath
  • 315
  • 1
  • 3
  • 13

1 Answers1

0

Try SELECT count(*) FROM sqlite_master WHERE type='table' AND name='table_name';

This will return 0, if the table doesn't exist, 1 if it does.

Leo Chapiro
  • 13,678
  • 8
  • 61
  • 92
  • QSqlQuery sqlQuery(query, SQLConnection()); and sqlQuery.next() returns the number? if you dint mind can you please post complete method...i am new to BB 10 – Sharath Oct 09 '13 at 11:38
  • In BB10 you can use bool QSqlQuery::exec ( const QString & query ); This will return false, if the table doesn't exist, true if it does: http://developer.blackberry.com/native/reference/cascades/qsqlquery.html#exec – Leo Chapiro Oct 09 '13 at 11:59
  • but it is returning Zero always, I am like this int exits=sqlQuery.next(); – Sharath Oct 09 '13 at 12:02