SQLite Table Exists

Mike Kerner MikeKerner at roadrunner.com
Tue May 5 10:28:11 EDT 2015


You can also use PRAGMA, or revDatabaseTableNames(), or SELECT name FROM
sqlite_master WHERE type='table' AND name='table_name';

On Tue, May 5, 2015 at 9:41 AM, Mike Bonner <bonnmike at gmail.com> wrote:

> oh, and you can add a limit 1 to make it faster. (no sense in selecting a
> whole tables data)
>
> On Tue, May 5, 2015 at 7:39 AM, Mike Bonner <bonnmike at gmail.com> wrote:
>
> > Probably the easiest way is a select:
> >
> > put "select * from tablename" into tSql
> > revexecutesql tDbId,tSql
> >
> > if the result contains "no such table tablename" its not there.
> >
> > On Tue, May 5, 2015 at 2:23 AM, Terence Heaford <t.heaford at icloud.com>
> > wrote:
> >
> >> Is there a LC function for checking if a table exists in an sqlite
> >> database or do I have to do something like this?
> >>
> >>
> >> function doesTableExist tTableName
> >>    put replaceText(tTableName,"'","''") into tTableName
> >>    put merge(“SELECT count() FROM sqlite_master WHERE type = 'table' AND
> >> name= '[[tTableName]]'") into tSQL
> >>    put revDataFromQuery(tab, return, myDB, tSQL) into tCount
> >>    if tCount = 1 then
> >>       return true
> >>    else
> >>       return false
> >>    end if
> >> end doesTableExist
> >>
> >>
> >> All the best
> >>
> >>
> >> Terry
> >> _______________________________________________
> >> use-livecode mailing list
> >> use-livecode at lists.runrev.com
> >> Please visit this url to subscribe, unsubscribe and manage your
> >> subscription preferences:
> >> http://lists.runrev.com/mailman/listinfo/use-livecode
> >
> >
> >
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>



-- 
On the first day, God created the heavens and the Earth
On the second day, God created the oceans.
On the third day, God put the animals on hold for a few hours,
   and did a little diving.
And God said, "This is good."



More information about the use-livecode mailing list