Thanks for the prompt reply...
I tried what you suggested and I always get the error message:
"SQL error: no such column: table32"
Whether the table exists or not, I always get returned value of 1 from
sqlite3_exec().
The exact command that I use is:
SELECT count(*) FROM sqlite_master WHERE name=table32 AND type='table';
I also tried single quotes around the table32 name:
SELECT count(*) FROM sqlite_master WHERE name='table32' AND type='table';
And get no errors whether the table exists or not....
When I try the other method suggested ("SELECT NULL FROM sqlite_master WHERE
tbl_name = 'your-table';") I don�t get any error messages whether the table
exists or not. The return value is always 0.
I'm obviously missing where the error is being flagged, have you any more
pointers?
Sorry if I'm being dense here but I'm new to SQL databases.
Thanks again,
Richard.
-----Original Message-----
From: D. Richard Hipp [mailto:[EMAIL PROTECTED]
Sent: 13 February 2005 23:46
To: [email protected]
Subject: Re: [sqlite] Best way to check for existence of a table?
On Sun, 2005-02-13 at 22:58 +0000, Richard Boyd wrote:
>
>
> I need a way to check if a table exists from some C code.
SELECT count(*) FROM sqlite_master WHERE
name=<tablename> AND type='table';
--
D. Richard Hipp <[EMAIL PROTECTED]>
--
No virus found in this incoming message.
Checked by AVG Anti-Virus.
Version: 7.0.300 / Virus Database: 265.8.7 - Release Date: 10/02/2005
--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.300 / Virus Database: 265.8.7 - Release Date: 10/02/2005