Re: SQLite Table Exists

2015-05-06 Thread Terence Heaford
> On 6 May 2015, at 16:00, Mike Kerner wrote: > > Neither the PRAGMA nor the SELECT name FROM sqlite_master WHERE > type='table' AND name='table_name' rely on that function. I have used your suggestion to modify my original function to: function doesTableExist tTableName put replaceText(tTa

Re: SQLite Table Exists

2015-05-06 Thread Mike Kerner
Neither the PRAGMA nor the SELECT name FROM sqlite_master WHERE type='table' AND name='table_name' rely on that function. On Wed, May 6, 2015 at 2:35 AM, Terence Heaford wrote: > Thanks to everyone who has responded. > > If the built in LC routine revDatabaseTableNames is not reliable I need to

Re: SQLite Table Exists

2015-05-05 Thread Terence Heaford
Thanks to everyone who has responded. If the built in LC routine revDatabaseTableNames is not reliable I need to use something similar to that provided in my first post. I can’t see why that should not be reliable? All the best Terry ___ use-livecode

Re: SQLite Table Exists

2015-05-05 Thread Dr. Hawkins
On Tue, May 5, 2015 at 10:55 AM, Richard Gaskin wrote: > Dr. Hawkins wrote: > > On Tue, May 5, 2015 at 7:27 AM, Richard Gaskin wrote: > > > >> The example given in the Dictionary entry for the > >> revDatabaseTableNames function may do what you need: > >> > >>if tTableName is among the lines

Re: SQLite Table Exists

2015-05-05 Thread Richard Gaskin
Dr. Hawkins wrote: > On Tue, May 5, 2015 at 7:27 AM, Richard Gaskin wrote: > >> The example given in the Dictionary entry for the >> revDatabaseTableNames function may do what you need: >> >>if tTableName is among the lines of \ >>revDatabaseTableNames(sgDatabaseId) then > > But be cau

Re: SQLite Table Exists

2015-05-05 Thread Terence Heaford
> On 5 May 2015, at 14:41, Mike Bonner wrote: > > oh, and you can add a limit 1 to make it faster. (no sense in selecting a > whole tables data) What is returned if the table contains no data? All the best Terry ___ use-livecode mailing list use-

Re: SQLite Table Exists

2015-05-05 Thread Terence Heaford
> On 5 May 2015, at 15:41, Peter Haworth wrote: > > If you need to create the table > if it doesn't exist, you could CREATE TABLE IF NOT EXISTS. Was just looking for a generalised method of determining if a table exists without having to create the table. Thanks Terry _

Re: SQLite Table Exists

2015-05-05 Thread Dr. Hawkins
On Tue, May 5, 2015 at 7:27 AM, Richard Gaskin wrote: > The example given in the Dictionary entry for the revDatabaseTableNames > function may do what you need: > >if tTableName is among the lines of \ >revDatabaseTableNames(sgDatabaseId) then > But be cautious--I've found that the l

Re: SQLite Table Exists

2015-05-05 Thread Peter Haworth
Hi Terry, I'm curious as to why you need to do this. If you need to create the table if it doesn't exist, you could CREATE TABLE IF NOT EXISTS. Pete lcSQL Software On May 5, 2015 1:23 AM, "Terence Heaford" wrote: > Is there a LC function for checking if a table exists in an sqlite > database or

Re: SQLite Table Exists

2015-05-05 Thread Mike Kerner
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 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,

Re: SQLite Table Exists

2015-05-05 Thread Richard Gaskin
Terence Heaford 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 = 'ta

Re: SQLite Table Exists

2015-05-05 Thread Mike Bonner
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 wrote: > Probably the easiest way is a select: > > put "select * from tablename" into tSql > revexecutesql tDbId,tSql > > if the result contains "no such table

Re: SQLite Table Exists

2015-05-05 Thread Mike Bonner
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 wrote: > Is there a LC function for checking if a table exists in an sqlite > d

SQLite Table Exists

2015-05-05 Thread Terence Heaford
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= '[[tTable