SQLite Table Exists
Terence Heaford
t.heaford at icloud.com
Wed May 6 11:49:28 EDT 2015
> On 6 May 2015, at 16:00, Mike Kerner <MikeKerner at roadrunner.com> 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(tTableName,"'","''") into tTableName
put merge("SELECT name FROM sqlite_master WHERE type = 'table' AND name = '[[tTableName]]'") into tSQL
put revDataFromQuery(tab, return, the uDB of stack "THFinancials", tSQL) into tData
if tData = tTableName then
return true
else
return false
end if
end doesTableExist
Yours actually returns the table name if it exists whereas my suggestion returned the count of either 0 or 1.
I have adopted your suggestion because it actually returns the table name originally passed in.
All the best
Terry
More information about the use-livecode
mailing list