Writing a user defined function

From: Suresh_ <suiyengar(at)yahoo(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Writing a user defined function
Date: 2008-07-18 16:07:37
Message-ID: 18532591.post@talk.nabble.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


Hello,
I am trying to code a simple udf in postgres. How do I write sql commands
into pl/sql ? The foll. code doesnt work.

CREATE OR REPLACE FUNCTION udf()
RETURNS integer AS $$
BEGIN
for i in 1..2000 loop
for j in 1...10000 loop
end loop;
begin work;
declare cust scroll cursor for select * from tpcd.customer;
FETCH FORWARD 5 FROM cust;
end loop;
CLOSE cust;
COMMIT work;
return 1;
end;
$$ LANGUAGE plpgsql;

select udf();

thanks,
Suresh
--
View this message in context: http://www.nabble.com/Writing-a-user-defined-function-tp18532591p18532591.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Scara Maccai 2008-07-18 16:12:31 Re: TODO list and "hyphen"
Previous Message Martijn van Oosterhout 2008-07-18 16:03:49 Re: Reducing memory usage of insert into select operations?