Re: Using UNION inside a cursor

Поиск
Список
Период
Сортировка
От Christoph Haller
Тема Re: Using UNION inside a cursor
Дата
Msg-id 200310300926.KAA04661@rodos
обсуждение исходный текст
Ответ на Using UNION inside a cursor  ("Kumar" <sgnerd@yahoo.com.sg>)
Ответы Re: Using UNION inside a cursor  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-sql
> 
> 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 



В списке pgsql-sql по дате отправления:

Предыдущее
От: "Kumar"
Дата:
Сообщение: Using UNION inside a cursor
Следующее
От: "Kumar"
Дата:
Сообщение: Re: Using UNION inside a cursor