On Thu, Jan 25, 2007 at 10:35:23AM -0500, Anderson, James H (IT) wrote:
> I need a way to drop a table only if that table exists. How would I do
> that?

You'd think this would work:

SELECT CASE WHEN
    (SELECT count(*) FROM sqlite_master WHERE
        type = 'table' AND name = 'foo') > 0
    THEN (DROP TABLE foo) END;

but it doesn't (it yields a syntax error).

In fact, inserts and updates inside a select case when all yield syntax
errors.

W.r.t. to dropping a table inside a select case when, well, you should
know whether the schema to begin with, so that makes sense.

Nico
-- 

-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------

Reply via email to