Subject | Re: [firebird-support] Checking if a table exists ... |
---|---|
Author | Lucas Franzen |
Post date | 2004-03-31T12:17:13Z |
Anand,
akashelkar schrieb:
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.
akashelkar schrieb:
> How can I check, inside a stored procedure as well as from anQuery the system tables:
> application, if a specific table or view or procedure or any other
> object exists in the database?
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.