|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Iam trying to make a trigger for backup table. When a delete operation for table1, it will copy deleted data to table2.
table1: create table1 (id int4, name text); table2: create table2 (id int4, name text); function execute by trigger: create function backup_func() returns OPAQUE as ' begin insert into tabel2(id, nama) values (OLD.id, OLD.nama); end; ' language 'plpgsql'; trigger for table1: create trigger mytrigger after delete on tabel1 for each row execute procedure backup_func(); then insert some data: insert into table1 (id, name) values (1, 'Mao Tze Dong'); insert into table1 (id, name) values (2, 'Hitler'); All above operations are doing fine. but when deleting data in table1 an error occor: ![]() delete from table1 where id = 2; ERROR: control reaches end of trigger procedure without RETURN please help.. how to make a trigger for a table so that when the table do delete operation it can backup into anoter table? thanks Last edited by bambanghendra : August 22nd, 2001 at 02:35 AM. |
|
#2
|
||||
|
||||
|
I have never written a trigger in Postgresql. The documentation says:
"...they must return either NULL or a record/row containing exactly the structure of the table the trigger was fired for." Based on your error message and the documentation above, would adding a RETURN NULL; before the end; statement solve your problem? Postgresql does not appear to like that your trigger doesn't have a return value. This is just a guess. http://www.postgresql.org/idocs/ind...ql-trigger.html |
|
#3
|
|||
|
|||
|
Thanks dcaillouet
Quote:
Yes... a function shoud have a return value ![]() But RETURN OLD or RETURN NEW will be fine. |
![]() |
| Viewing: Dev Shed Forums > Databases > PostgreSQL Help > what wrong???? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|