Page 1 of 1

TIBCScript, execute block and execute statement

Posted: Mon 13 Oct 2014 16:08
by Fabrice
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

Re: TIBCScript, execute block and execute statement

Posted: Wed 15 Oct 2014 12:14
by ViktorV
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.

Re: TIBCScript, execute block and execute statement

Posted: Wed 15 Oct 2014 16:43
by Fabrice
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

Re: TIBCScript, execute block and execute statement

Posted: Thu 16 Oct 2014 05:38
by ViktorV
It is good to see that the problem has been solved. Feel free to contact us if you have any further questions.