Re: 'union' in cursor?

From: Jurij Modic <jurij.modic_at_mf.sigov.mail.si>
Date: 1997/04/28
Message-ID: <33650e24.41883011_at_www.sigov.si>#1/1


Can you be a little more speciffic? Like what is the problem? Do you get any error message or you just dont get the result you wanted? Did you try to execute your UNION statement outside explicit cursor, e.i. in SQL Plus?

As an answer to your generic question about executing UNION statement in cursor, my answer is: AFAIK there should be no problem. Simple example:

DECLARE
   CURSOR cur1 IS

          SELECT 'abc' dummy FROM dual
           UNION
           SELECT 'xyz' dummy FROM dual;
BEGIN
    FOR rec1 IN cur1 LOOP

        DBMS_OUTPUT.PUT_LINE(rec1.dummy);     END LOOP;
END;
/

The result is (as expected):

 abc
xyz

PL/SQL procedure successfuly completed.

Regards,

Jurij Modic
Ministry of Finance, Republic of Slovenia, Ljubljana



On 28 Apr 1997 15:01:54 GMT, htpai_at_gwis2.circ.gwu.edu (Hsin-tang Pai) wrote:

>Hi! Folks:
>
>Does anyone ever try to declare a select union statement in a cursor?
>I did try it, but I fail.
>
>the_test cursor is
>select doc_id from document
>where documenttitle like '%TEST%'
> and doc_type = 20
>union
>select doc_id from document
>where doc_type = 20
>and doc_id in (select doc_id from segment
>where segmenttitle like '%TEST%');
>
>Can anyone tell me how to fix the problem?
>Thank you!
>
>Borren
>
>--
> . .
> . . . .

Jurij Modic					Republic of Slovenia
tel: +386 61 178 55 14			Ministry of Finance
fax: +386 61  21 45 84			Zupanciceva 3
e-mail: jurij.modic_at_mf.sigov.mail.si	Ljubljana 1000
Received on Mon Apr 28 1997 - 00:00:00 CEST

Original text of this message