Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: Dynamic SQL

Re: Dynamic SQL

From: Stéphane ROMANET <sromanet53_at_hotmail.com>
Date: Mon, 4 Nov 2002 11:06:18 +0100
Message-ID: <aq5h1d$8rq$1@news-reader11.wanadoo.fr>


CREATE OR REPLACE PROCEDURE EXEC_DYN_SELECT ( Field3_Value INTEGER ) IS

    CURSOR C1 IS

        SELECT
            Field1,
            Field2
        FROM
            Table1
        WHERE
            Field3 = Field3_Value;

BEGIN
    DBMS_OUTPUT.ENABLE ( 10000 );
    FOR R1 IN C1
    LOOP
-- Display the result on the SQL RESULT SCREEN --

        DBMS_OUTPUT.PUT_LINE ( 'Field1 = ' || R1.Field1 || ' And Field2 = ' || R1.Field2 );

    END LOOP;
END ; This is one of the solutions ... this is for the case of a where clause dynamic ...

Of course there's many other ways to make more dynamic queries within a PL SQL proc. All depends on what dynamism you want ...

If you want, let us knowing more about what you want to do .

Cheers,

Stef

"Jet" <jet_ming_chan_at_hotmail.com> a écrit dans le message de news: c789f9ad.0211020057.443a2190_at_posting.google.com...
> How to Create A Procudure/Function which Execute Dynamic SQL Select
> Statement And Return A Cursor
Received on Mon Nov 04 2002 - 04:06:18 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US