TIBCScript, execute block and execute statement

Discussion of open issues, suggestions and bugs regarding IBDAC (InterBase Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Fabrice
Posts: 45
Joined: Tue 07 Sep 2010 09:44

TIBCScript, execute block and execute statement

Post by Fabrice » Mon 13 Oct 2014 16:08

Hello,

I would like to execute script to alter a primary key of my firebird 2.5 database like :
http://www.firebirdfaq.org/faq176/

Code: Select all

EXECUTE BLOCK RETURNS (stmt VARCHAR(1000)) AS
BEGIN
FOR
select 'alter table '||r.rdb$relation_name ||' drop constraint '||r.rdb$constraint_name||';'
from rdb$relation_constraints r
where (r.rdb$constraint_type='PRIMARY KEY')
into :stmt
DO begin suspend; execute statement :stmt; end
END
It's work like a charm using a SQL command like Flamerobin "execute SQL Statement".

But it's doesn't work with TIBCScript. I have tried a lot of ways.
It is like this component ignore the content of parameter "execute statement" !
So it's doesn't execute the ALTER command...

Any idea ?

Best regards,
Fabrice

ViktorV
Devart Team
Posts: 3168
Joined: Wed 30 Jul 2014 07:16

Re: TIBCScript, execute block and execute statement

Post by ViktorV » Wed 15 Oct 2014 12:14

TIBCScript is not designed for execution of queries that return resulting strings.
Since such a query is used in your sample, the text after "suspend" is ignored.
To successfully execute your query, use the TIBCQuery component.
You can also place an IBDAC dataset component (TIBCQuery, TIBCTable) onto the form and assign its name to the TIBCScript.DataSet property.

Fabrice
Posts: 45
Joined: Tue 07 Sep 2010 09:44

Re: TIBCScript, execute block and execute statement

Post by Fabrice » Wed 15 Oct 2014 16:43

Hello,

Thank you for your answer.

But I have found a solution which seems to work fine :

Code: Select all

EXECUTE BLOCK
as
DECLARE VARIABLE statm VARCHAR(1000);
begin
 select 'ALTER TABLE '||r.rdb$relation_name
 ||' DROP CONSTRAINT '||r.rdb$constraint_name
 from rdb$relation_constraints r
 where (r.rdb$constraint_type='PRIMARY KEY') )
 into :statm;
 EXECUTE statement :statm;
end

ViktorV
Devart Team
Posts: 3168
Joined: Wed 30 Jul 2014 07:16

Re: TIBCScript, execute block and execute statement

Post by ViktorV » Thu 16 Oct 2014 05:38

It is good to see that the problem has been solved. Feel free to contact us if you have any further questions.

Post Reply