Обсуждение: function example?
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
am 29.10.2005, um 20:39:23 -0700 mailte Matthew Peter folgendes: > 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. http://www.postgresql.org/docs/8.0/static/plpgsql-statements.html#PLPGSQL-STATEMENTS-EXECUTING-DYN HTH, Andreas -- Andreas Kretschmer (Kontakt: siehe Header) Heynitz: 035242/47212, D1: 0160/7141639 GnuPG-ID 0x3FFF606C http://wwwkeys.de.pgp.net === Schollglas Unternehmensgruppe ===
Thanks I did read that when looking into EXECUTE, which I'd rather not use. As I said, I would rather not use plpgsql if possible. All I want to do is 1) pass in some variables, 2) reference them, and 3) have a working query which 4) supports SELECTs, and lastly 5) isn't plpgsql but pg_native syntax. --- "A. Kretschmer" <andreas.kretschmer@schollglas.com> wrote: > am 29.10.2005, um 20:39:23 -0700 mailte Matthew > Peter folgendes: > > 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. > > http://www.postgresql.org/docs/8.0/static/plpgsql-statements.html#PLPGSQL-STATEMENTS-EXECUTING-DYN > > HTH, Andreas > -- > Andreas Kretschmer (Kontakt: siehe Header) > Heynitz: 035242/47212, D1: 0160/7141639 > GnuPG-ID 0x3FFF606C http://wwwkeys.de.pgp.net > === Schollglas Unternehmensgruppe === > > ---------------------------(end of > broadcast)--------------------------- > TIP 4: Have you searched our list archives? > > http://archives.postgresql.org > __________________________________ Yahoo! Mail - PC Magazine Editors' Choice 2005 http://mail.yahoo.com