pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Kumar <sgnerd@yahoo.com.sg>
To: Christoph Haller <ch@rodos.fzk.de>
Cc: pgsql-sql@postgresql.org
Subject: Re: Using UNION inside a cursor
Date: Thu, 30 Oct 2003 16:19:21 +0530
Message-ID: <00d601c39ed3$7da18010$7502a8c0@hdsc.com> (raw)
References: <200310300926.KAA04661@rodos>

Hi Christoph Haller,

Thanks you very much. It worked.

----- Original Message ----- 
From: "Christoph Haller" <ch@rodos.fzk.de>
To: ""Kumar"" <sgnerd@yahoo.com.sg>
Cc: <pgsql-sql@postgresql.org>
Sent: Thursday, October 30, 2003 3:56 PM
Subject: Re: [SQL] Using UNION inside a cursor


> >
> > 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: <00d601c39ed3$7da18010$7502a8c0@hdsc.com>
Permalink:  ../00d601c39ed3$7da18010$7502a8c0@hdsc.com/
Also on:    postgresql.org/message-id/00d601c39ed3$7da18010$7502a8c0@hdsc.com

 · 

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: sgnerd@yahoo.com.sg, ch@rodos.fzk.de
  Subject: Re: Using UNION inside a cursor
  In-Reply-To: <00d601c39ed3$7da18010$7502a8c0@hdsc.com>

* 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