Subject Re: [firebird-support] Checking if a table exists ...
Author Martijn Tonies
> At 11:33 AM 31/03/2004 +0000, you wrote:
> >How can I check, inside a stored procedure as well as from an
> >application, if a specific table or view or procedure or any other
> >object exists in the database?
>
> Tables and views:
> SELECT 1 FROM RDB$RELATIONS
> WHERE RDB$RELATION_NAME = ?
>
> SELECT 1 FROM RDB$PROCEDURES
> WHERE RDB$PROCEDURE_NAME = ?
>
> Returns 1 if the object exists, null if not.

Minor niggle:

Returns a resultset of 1 row, with value "1" if
it exists and returns no resultset if not.

COUNT(*)

Will return 1 if it exists and 0 if not


:-)

With regards,

Martijn Tonies