Forum OpenACS Q&A: Postgres TRIGGER Parameters?
I'm creating a common TRIGGER function that needs the *value* of a table column. The name of the table column differs with each table, but its value in each case represents an oacs object_id. From the doc I've found, the TRIGGER function accesses its passed parameters from the TG_ARGV array. I have verified that TG_ARGV and TG_ARGV do contain the values I pass. Now, I need the column value that resides in OLD.TG_ARGV, or equivalently, TG_ARGV.TG_ARGV.
I'm defining the TRIGGER as:
create trigger cmd_object_delete_trig after delete on cmd for each row execute procedure object_delete(cmd,cmd_id);Where arg0 (in this case 'cmd') is a table name, and arg1 (here 'cmd_id') is a column name.
I'm defining the TRIGGER FUNCTION as (debugging only at this time so I can get the syntax correct):
create or replace function object_delete() returns trigger as ' begin raise notice ''TRIGGERED object_delete BEGIN: table=%, column=%'',TG_ARGV, TG_ARGV; raise notice ''TRIGGERED object_delete (CONT): object_id=%'',OLD.TG_ARGV; -- ^^^^^ Error is bold on line above ^^^^^ -- Delete directly assigned acs permissions -- delete from acs_permissions where object_id = OLD.TG_ARGV; -- Delete acs object -- perform acs_object__delete(OLD.TG_ARGV); raise notice ''TRIGGERED object_delete END: returning OK (NULL)''; return NULL; end; ' language 'plpgsql';As you can see, I'm attempting to access the column's value. I'm presently getting the following error. I have tried several different forms with various (unsuccessful) result.
WARNING: plpgsql: ERROR during compile of object_delete near line 3 Error: Ns_PgExec: result status: 7 message: ERROR: parse error at or near "["