From: Kumar <sgnerd@yahoo.com.sg>
To: psql <pgsql-sql@postgresql.org>
Subject: Using UNION inside a cursor
Date: Thu, 30 Oct 2003 14:23:48 +0530
Message-ID: <007c01c39ec4$5af992f0$7502a8c0@hdsc.com> (raw)
Dear Friends,
I am working on Postgresql 7.3.4 on RH Linux Server 7.3.
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 = \'AA\' )
UNION
(SELECT * FROM history WHERE obs_type = \'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 = \'AA\' )
UNION
(SELECT * FROM history WHERE obs_type = \'TA\');
Where I am wrong. Please shed some light,
Regards
Kumar
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
Subject: Re: Using UNION inside a cursor
In-Reply-To: <007c01c39ec4$5af992f0$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