From: | Scott Holmes <sholmes(at)pacificnet(dot)net> |
---|---|
To: | pgsql-general(at)postgresql(dot)org (PG-General) |
Subject: | Getting closer with functions, but... |
Date: | 2000-07-13 03:58:11 |
Message-ID: | 200007130358.UAA15337@scotts.mynetwork.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
This function works but is not selective enough. The tg_argv[] are pointers
to the arguments passed. And they do work correctly.
CREATE FUNCTION del_stxnoted () RETURNS opaque AS '
declare
fname text;
rkey text;
BEGIN
fname := tg_argv[0];
rkey := ''old.'' || tg_argv[1];
delete from stxnoted where record_key = old.wher;
return old;
END;'
LANGUAGE 'plpgsql';
What I need can be accomplished with a rather massive if/then series:
if fname = "location" then
delete from stxnoted where filename = "location" and record_key = old.wher;
end if
if fname = "events" then
delete from stxnoted where filename = "events" and record_key = old.evntnmbr;
end if
... ( maybe 100 different tables )...
It seems the sql statement needs old.field or new.field to provide a value.
Unfortunately, my first value, fname, is not a field value but a table name
and my second value may have one of several field names.
Is there a syntax that will allow me to build an sql statement for use in
theis funcation (ie delete from stxnoted where filename = fname and record_key
= rkey).
Thanks, Scott
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2000-07-13 04:32:11 | Re: Getting closer with functions, but... |
Previous Message | Joseph Shraibman | 2000-07-13 03:51:31 | Re: select for update not locking properly. |