Subject | RE: [IBO] Tables and their existance |
---|---|
Author | Roger Pullen |
Post date | 2001-08-03T11:31:16Z |
Do something like this to see if a table exists:
function Tdmmain.TableExists(TableName: string): Boolean;
var
ibq: TIB_Query;
begin
ibq := TIB_Query.Create(nil);
with ibq do
try
IB_Connection := dmmain.mainconnection;
IB_Transaction := dmmain.trmain;
SQL.Add('Select * from RDB$RELATIONS where RDB$RELATION_NAME= ');
SQL.Add(QuotedStr(TableName));
Prepare;
Open;
Result := Not IsEmpty;
Close;
finally
Free;
end;
end;
If id does then just query number of records to see if it empty
Regards
Roger Pullen
-----Original Message-----
From: comesailing@... [mailto:comesailing@...]
Sent: 03 August 2001 12:18
To: IBObjects@yahoogroups.com
Subject: [IBO] Tables and their existance
Silly question.
What is the best way (in a program using ib_connection) of finding
whether a table exists and if so whether it is empty ?
I do it by trying to read a record and if the table does not exist or
is empty then of course there is an error. But this is clumsy, I
would rather do a test of each.
regards Dave.
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
function Tdmmain.TableExists(TableName: string): Boolean;
var
ibq: TIB_Query;
begin
ibq := TIB_Query.Create(nil);
with ibq do
try
IB_Connection := dmmain.mainconnection;
IB_Transaction := dmmain.trmain;
SQL.Add('Select * from RDB$RELATIONS where RDB$RELATION_NAME= ');
SQL.Add(QuotedStr(TableName));
Prepare;
Open;
Result := Not IsEmpty;
Close;
finally
Free;
end;
end;
If id does then just query number of records to see if it empty
Regards
Roger Pullen
-----Original Message-----
From: comesailing@... [mailto:comesailing@...]
Sent: 03 August 2001 12:18
To: IBObjects@yahoogroups.com
Subject: [IBO] Tables and their existance
Silly question.
What is the best way (in a program using ib_connection) of finding
whether a table exists and if so whether it is empty ?
I do it by trying to read a record and if the table does not exist or
is empty then of course there is an error. But this is clumsy, I
would rather do a test of each.
regards Dave.
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/