Thread: Determining if table exists before dropping

Determining if table exists before dropping

From
"Dwayne Miller"
Date:
Is there any way of wrapping a DROP TABLE statement within a test in a
psql script?  I've constructed a script that should DROP a table if it
exists before trying to CREATE the table.  I'm passing this script in as
a command from a C program using PQsendQuery().  And the first DROP
statement results in an error being returned when the TABLE does not
exist.  The rest of the statements are ignored.  psql processes the
script to completion even though an error is generated.  I would like
the script to return an error if some other error was encountered.

Perhaps there is a way to treat this error as a warning?

Tks,
Dwayne