Re: cursor return null - Mailing list pgsql-general

From David G Johnston
Subject Re: cursor return null
Date
Msg-id 1405963719554-5812246.post@n5.nabble.com
Whole thread Raw
In response to cursor return null  (Ramesh T <rameshparnanditech@gmail.com>)
List pgsql-general
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.


pgsql-general by date:

Previous
From: David G Johnston
Date:
Subject: Re: statement_timeout doesn't work
Next
From: David G Johnston
Date:
Subject: Re: Why would I need to explicitly cast a string literal to text?