Articles Oracle Forms, PL/SQL, Java, J2EE
Because I like anything which is "dynamic", I have played with the DBMS_SQL package.
My goal was to send any Select order to a procedure and get a collection of records and a datastructure to manipulate these records.
So, this is the trick:
|
CREATE OR REPLACE PACKAGE PKG_DYNAMIC IS
PROCEDURE dynamic_cursor
LN$Lig PLS_INTEGER := 0 ; v VARCHAR2(4000) ; source_cursor INTEGER; BEGIN -- retrieve the columns of the query -- dbms_sql.parse(c, PC$Query , dbms_sql.NATIVE); d := dbms_sql.execute(c); dbms_sql.describe_columns(c, col_cnt, rec_tab);
For i in rec_tab.first .. rec_tab.last Loop PT$Cols(i)(1) := rec_tab(i).col_name ; -- name End loop ; dbms_sql.close_cursor(c);
dbms_sql.parse(source_cursor, PC$Query, dbms_sql.NATIVE);
ELSE
IF dbms_sql.is_open(source_cursor) THEN RAISE; END; END PKG_DYNAMIC ; |
|
SQL> desc fd.queries
NUM QUERY |
|
SQL> set serveroutput on PL/SQL procedure successfully completed. SQL> |