<div style="text-align: left;">Hello everybody! I'm newbie to plpgsql syntax. Can anyone tell where I'm getting
wrong?<br/><br />CREATE OR REPLACE FUNCTION tr_audit() RETURNS TRIGGER AS $tr_audit$<br /> BEGIN<br /> IF
(TG_OP= 'UPDATE') THEN<br /> ...<br /> NEW.id = nextval(TG_TABLE_NAME || '_id_seq'::regclass);<br />
INSERT INTO TG_TABLE_NAME SELECT NEW.*;<br /> ELSIF (TG_OP = 'INSERT') THEN<br /> ...<br /> END
IF;<br/><br /> RETURN NULL;<br /> END;<br />$tr_audit$ LANGUAGE 'plpgsql';<br /><br />returns<br /><br
/>ERROR: syntax error at or near "$1"<br />LINE 1: INSERT INTO $1 SELECT $2 .*<br /> ^<br
/>QUERY: INSERT INTO $1 SELECT $2 .*<br />CONTEXT: SQL statement in PL/PgSQL function "tr_audit" near line 8<br
/><br/>I tried some variants using INSERT INTO '|| TG_TABLE_NAME ||' SELECT NEW.* and quote_ident(TG_TABLE_NAME) with
noluck! Unfortunately searches on the Net and old threads on this forum didn't help me.<br /><br />Hope someone can do
this!<br/><br />Thanks in advance,<br /><br />Tiziano.</div><br /><hr />Windows Live Spaces <a
href="http://pushthebutton2006.spaces.live.com/"target="_new">Push the Button! Crea il tuo blog e condividi le tue
esperienzecol mondo!</a>