Page 1 of 1

Statements in TSQLProcessor seems not work

Posted: 29.01.2015, 15:18
by louis
Hello,
I need to change a Primary Key by adding a new Field in a table.

Unfortunatelly when I created the table I forget to set a name for the primary key :oops:

Now I need to drop the primary key to recreate it with more fields but I don't know the name of the primary key, and the statement
ALTER TABLE MYTABLE DROP CONSTRAINT MYINTEG_000
is not usable because I have more database file and the name of Primary keys is different per database file.

I tried to execute statement like this on a TSQLProcessor
SET TERM !!;
EXECUTE BLOCK RETURNS (stmt VARCHAR(1000)) AS
BEGIN
FOR
SELECT 'ALTER TABLE MYTABLE DROP CONSTRAINT ' ||
rdb$constraint_name
from
rdb$relation_constraints
where
rdb$relation_name = "MYTABLE"
AND rDB$CONSTRAINT_TYPE = 'PRIMARY KEY'
into :stmt
DO begin suspend; execute statement :stmt; end
END!!

set term ; !!
seems to work but, even if I don't have error messages, the primary key is not dropped. :cry:

How I can solve?

Thanks

Louis.