Danke, hab das ganze nun in einen EXECUTE BLOCK gepackt. Damit klappt es:
Code:
SET TERM !! ;
EXECUTE BLOCK AS
declare variable CName varchar(2000);
BEGIN
execute statement 'select distinct(RDB$CONSTRAINT_NAME) from RDB$CHECK_CONSTRAINTS where RDB$TRIGGER_NAME in (
select RDB$TRIGGER_NAME from RDB$TRIGGERS where RDB$RELATION_NAME = ''KUNDE'' and RDB$TRIGGER_SOURCE = ''CHECK (AFIELD between 1 and 4)'')' into :CName;
if (:CName <> '') then
execute statement 'ALTER TABLE KUNDE DROP CONSTRAINT ' || Trim(:CName) || ';';
END!!
SET TERM ; !!
Jetzt wundert mich nur der Hinweis aus der Firebird Hilfe, der sagt, dass ich keine DDL strings mit EXECUTE STATEMENT ausführen soll. Warum nicht? Ist das hier schlimm?
Zitat:
Although this form of EXECUTE STATEMENT can also be used with all kinds of DDL strings (except CREATE/DROP DATABASE), it is generally very, very unwise to use this trick in order to circumvent the no-DDL rule in PSQL.