Hi, I have written a trigger in plperl (I could not use pgsql due to the nature of the trigger). I know CREATE CONSTRAINT TRIGGER is not intended for general use, but it is pretty important that this trigger be run on commit of the transaction, as it needs to use data in other tables that can only be considered final on commit. When I run the trigger then this error appears in the logs: postgres FATAL: BeginInternalSubTransaction: unexpected state END It is caused by the first call to the spi_exec_query($sql) function. Would I be correct in assuming that plperl language triggers are not capable of running from a CREATE CONSTRAINT TRIGGER command? When the trigger is set up as a normal per row trigger then it executes without any problems. Many thanks Chris -------------------------------- Chris Coleman Programmer Information Systems Room PKL1 Phone 369 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ This e-mail is confidential and may be read only by the intended recipient. If you are not the intended recipient, please do not forward, copy or take any action based on it and, in addition, please delete this email and inform the sender. We cannot be sure that this e-mail or its attachments are free from viruses. In keeping with good computing practice, please ensure that you take adequate steps to check for any viruses. Before replying or sending any email to us, please consider that the internet is inherently insecure and is an inappropriate medium for certain kinds of information. We reserve the right to access and read all e-mails and attachments entering or leaving our systems. Registered office: Eurocom House, Ashbourne Road, Derby DE22 4NB Company number: 01574696.