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: returning a value from code executed under DBMS_SQL

Re: returning a value from code executed under DBMS_SQL

From: Paul Wagner <wagner_at_cs.umn.edu>
Date: 1 Apr 1999 21:39:53 GMT
Message-ID: <7e0p39$iu5$1@news1.tc.umn.edu>


This is exactly what I needed - thanks to Gerard and to Rudy Zung, who also pointed me in this direction.

Paul

Gerard M. Averill <e-mail.address_at_my.sig> wrote:
>The idea of using a package variable would work, but is not necessary. By
>using a bind parameter you can retrieve the value of an expression in the
>dynamic block:
>
>PROCEDURE example IS
> global_var INTEGER;
> block_string VARCHAR;
> cursor_handle INTEGER;
> cursor_result INTEGER;
>BEGIN
> ...
> block_string := 'DECLARE ' ||
> ' X INTEGER := 3; ' ||
> 'BEGIN ' ||
> ' X := 1; ' ||
> ' :result := X; ' || -- Added this
> 'END;' ;
> -- run it through dbms_sql
> cursor_handle := DBMS_SQL.OPEN_CURSOR;
> DBMS_SQL.PARSE(cursor_handle, block_string, DBMS_SQL.NATIVE); -- Added this
> DBMS_SQL.BIND_VARIABLE(cursor_handle 'result', 0);
> cursor_result := DBMS_SQL.EXECUTE(cursor_handle);
> DBMS_SQL.VARIABLE_VALUE(cursor_handle, 'result', global_var); -- Added this
> DBMS_SQL.CLOSE_CURSOR(cursor_handle);
> ...
>END;
>
>Hope this helps.
>Gerard
>
>----
>Gerard M. Averill, Researcher
>CHSRA, University of Wisconsin - Madison
>GAverill<at>chsra<dot>wisc<dot>edu

--

*    *    *    *    *    *    *    *    *    *    *    *    *    *    *    *
* Paul J. Wagner                School   - wagner_at_cs.umn.edu               *
* Computer Science Department   Work     - wagnerp_at_uwstout.edu             *
* University of Minnesota                                                  *
*    *    *    *    *    *    *    *    *    *    *    *    *    *    *    *
Received on Thu Apr 01 1999 - 15:39:53 CST

Original text of this message

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