Search Postgresql Archives

function example?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
       subscribe-nomail command to majordomo@xxxxxxxxxxxxxx so that your
       message can get through to the mailing list cleanly

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux