cursor return null

Started by Ramesh Tover 11 years ago2 messagesgeneral
Jump to latest
#1Ramesh T
rameshparnanditech@gmail.com

Hello,
in postgres function (id bigint ),the following code not return
any value with artNums ,But when i do select statement ony it's output the
values with out include cursor

i.e,cursor problem ..?

please let me know what should i do to getvalues from cursor, but i dont
where i missing

function (id bigint )

DECLARE
PartNums varchar (10000);
artNums CURSOR for
SELECT p.PART_NUM part_num
FROM lineitem sol, part p
WHERE sol.ORDER_ID = id AND p.PART_ID = sol.PART_ID;

BEGIN
FOR cPart IN artNums LOOP
BEGIN
PartNums := PartNums || cPart.part_num || ', ';
END;

#2David G. Johnston
david.g.johnston@gmail.com
In reply to: Ramesh T (#1)
Re: cursor return null

rameshparnanditech wrote

Hello,
in postgres function (id bigint ),the following code not return
any value with artNums ,But when i do select statement ony it's output
the
values with out include cursor

i.e,cursor problem ..?

please let me know what should i do to getvalues from cursor, but i dont
where i missing

function (id bigint )

DECLARE
PartNums varchar (10000);
artNums CURSOR for
SELECT p.PART_NUM part_num
FROM lineitem sol, part p
WHERE sol.ORDER_ID = id AND p.PART_ID = sol.PART_ID;

BEGIN
FOR cPart IN artNums LOOP
BEGIN
PartNums := PartNums || cPart.part_num || ', ';
END;

You have two BEGIN statements and no "END LOOP" statement...you need to read
the documentation and learn the correct syntax for using CURSORS and FOR
loops.

You should also post the entire function and not just excerpts to minimize
the risk of copy/paste problems and not reporting your reality.

David J.

--
View this message in context: http://postgresql.1045698.n5.nabble.com/cursor-return-null-tp5812219p5812246.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general