Re: cursor return null

From: David G Johnston <david(dot)g(dot)johnston(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: cursor return null
Date: 2014-07-21 17:28:39
Message-ID: 1405963719554-5812246.post@n5.nabble.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message David G Johnston 2014-07-21 17:56:22 Re: Why would I need to explicitly cast a string literal to text?
Previous Message David G Johnston 2014-07-21 17:16:19 Re: statement_timeout doesn't work