Subject | Re: [firebird-support] Checking if a table exists ... |
---|---|
Author | Niki Ivanchev |
Post date | 2004-03-31T12:17:46Z |
Lucas Franzen wrote:
Niki
>Anand,You can create table - compile stored procedure and then drop it /table/ :-)
>
>
>akashelkar schrieb:
>
>
>
>>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?
>>
>>
>
>Query the system tables:
>
>Tables:
>-------
>SystemTable = RDB$RELATIONS
>Tablename = RDB$RELATIONS.RDB$RELATION_NAME
>
>Add. Where = RDB$RELATIONS.RDB$SYSTEM_FLAG = '0' AND
> RDB$VIEW_BLR IS NULL
>
>Views:
>------
>SystemTable = RDB$RELATIONS
>Tablename = RDB$RELATIONS.RDB$RELATION_NAME
>
>Add. Where = RDB$RELATIONS.RDB$SYSTEM_FLAG = '0' AND
> RDB$VIEW_BLR IS NOT NULL
>
>
>Procedures:
>------------
>SystemTable = RDB$PROCEDURES
>ProcName = RDB$PROCEDURES.RDB$PROCEDURE_NAME
>
>Add. Where = RDB$PROCEDURES.RDB$SYSTEM_FLAG = '0'
>
>
>But: inside a stored procedure this isn't very helpful since what to do
>with the information then?
>
>If the table exists do a select?
>
>This will fail, since if it doesn't exist, the procedure won't compile ;-)
>
>Luc.
>
>
>
>
>
>Yahoo! Groups Links
>
>
>
>
>
>
>
>
>
Niki