Subject Re: [IBO] How to check if a table exists?
Author Lucas Franzen
Paul Irwin schrieb:
>
> How can I check if a table exists? I'm using native IBO. I suppose I could
> execute a query to see if it exists in a system table, but I want to know if
> there is another easier way.

Two ideas:

1.
function CheckForTable ( aTable: String ): Boolean;
begin
with CheckTableQry do
begin
SQL.Clear;
SQL.Add ( 'SELECT * FROM ' + aTable );
try
Prepare;
Result := TRUE;
except
Result := FALSE;
end
end;
end;

2. (what you didn't want to (even if I would prefer this one))
function CheckForTable ( aTable: String ): Boolean;
begin
with qryCheckForTable do
begin
// SQL = SELECT RDB$RELATION_NAME FROM RDB$RELATIONS
// WHERE RDB$RELATION_NAME = :TN
if not Prepared then Prepare;
ParamByName ( 'TN' ).AsString := aTable;
Open;
Result := NOT isEmpty; // or: Result := NOT EOF, or ....
Close;
end;
end;



>
> Thanks,
>
> Paul Irwin
>
>
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/