pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Christoph Haller <ch@rodos.fzk.de>
To: sgnerd@yahoo.com.sg
Cc: pgsql-sql@postgresql.org
Subject: Re: Using UNION inside a cursor
Date: Thu, 30 Oct 2003 10:26:17 MET
Message-ID: <200310300926.KAA04661@rodos> (raw)
In-Reply-To: <007c01c39ec4$5af992f0$7502a8c0@hdsc.com>

> 
> Dear Friends,
> 
> I am working on Postgresql 7.3.4 on RH Linux Server 7.3.=20
> 
> I have problem in executing the following procedure
> 
> CREATE OR REPLACE FUNCTION list_history()
>   RETURNS refcursor AS
> 'DECLARE
>  ref   REFCURSOR;
> BEGIN
>  OPEN ref FOR
>  (SELECT  * FROM history  WHERE obs_type =3D \'AA\' )
>  UNION=20
>  (SELECT  * FROM  history  WHERE   obs_type =3D \'TA\');
> 
>  RETURN ref;
> END;'
>   LANGUAGE 'plpgsql' VOLATILE;
> 
> While executing this I got the following error
> 
> WARNING:  plpgsql: ERROR during compile of list_history near line 5
> ERROR:  syntax error at "("
> 
> While I execute the following code it is working fine and fetches values.
>  (SELECT  * FROM history  WHERE obs_type =3D \'AA\' )
>  UNION=20
>  (SELECT  * FROM  history  WHERE   obs_type =3D \'TA\');
> 
> Where I am wrong. Please shed some light,
> 
> Regards
> Kumar
> 
My suspicion is the plpgsql parser doesn't accept the opening 
parenthesis. What happens on 

  OPEN ref FOR SELECT * FROM (
  (SELECT  * FROM history  WHERE obs_type =3D \'AA\' )
  UNION=20
  (SELECT  * FROM  history  WHERE   obs_type =3D \'TA\')
  ) ;

Regards, Christoph 




view thread (6+ messages)  latest in thread

Message-ID: <200310300926.KAA04661@rodos>
Permalink:  ../200310300926.KAA04661@rodos/
Also on:    postgresql.org/message-id/200310300926.KAA04661@rodos

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: ch@rodos.fzk.de, sgnerd@yahoo.com.sg
  Subject: Re: Using UNION inside a cursor
  In-Reply-To: <200310300926.KAA04661@rodos>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox