function example?

From: Matthew Peter <survivedsushi(at)yahoo(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: function example?
Date: 2005-10-30 03:39:23
Message-ID: 20051030033923.87914.qmail@web35210.mail.mud.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Could someone help me and give me a basic example of
how to write a similiar functional function to the one
below that would use a dynamic table and update a
column only if it held a value.

I've been reading around and can't seem to find the
answer I'm looking for. I just need a simple examle to
build upon. I would rather not use plpgsql if
possible. Tom mentioned the other pl's don't need
EXECUTE or something like that and would prefer clean
syntax if possible.

Thanks a bunch

CREATE OR REPLACE FUNCTION updatefoo(tbl
varchar, data mydata, myid bigint) RETURNS
boolean AS $$
DECLARE
BEGIN
update ${tbl} set
f1 = mydata.f1
IF mydata.f2 IS NOT NULL THEN
,f2 = mydata.f2
END IF;
WHERE id = myid;

IF NOT FOUND THEN
return false;
END IF;
return true;
END
$$ LANGUAGE ?;



__________________________________
Yahoo! Mail - PC Magazine Editors' Choice 2005
http://mail.yahoo.com

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2005-10-30 05:33:57 Re: Installation trouble -- oops
Previous Message Steve Crawford 2005-10-30 03:20:34 Re: Installation trouble -- oops