Vous êtes sur la page 1sur 2

Oracle has advised, since 8i, that the LONG datatype no longer be used.

This demo is included for those still working with legacy system that contain the LONG data type.

emo Table !ith LONG

CREATE TABLE t1 (x INT, y LONG); INSERT INTO t1 VALUES (1, RPAD('*',100,'*')); INSERT INTO t1 VALUES (2, RPAD('*',100,'$')); INSERT INTO t1 VALUES (3, RPAD('*',100,'#')); COMMIT; CREATE GLOBAL TEMPORARY TABLE t2 (x INT, y CLOB) ON COMMIT DELETE ROWS; CREATE OR REPLACE PACKAGE uw_type IS

Load emo Table !ith LONG

emo Table !ith "LO#

"reate $%& "'$(O$ Type 'se the $%& "'$(O$ data type in )i rather than this construct.

TYPE t_ref_cursor IS REF CURSOR; END uw_type; / CREATE OR REPLACE PROCEDURE child ( p_NumRecs IN PLS_INTEGER, p_return_cur OUT uw_type.t_ref_cursor) IS BEGIN INSERT INTO t2 SELECT x, TO_LOB(y) FROM t1 WHERE x = p_NumRecs; OPEN p_return_cur FOR 'SELECT * FROM t2'; END child; /

"hild (tored *rocedure

*arent (tored *rocedure

CREATE OR REPLACE PROCEDURE parent (pNumRecs PLS_INTEGER) IS p_retcur uw_type.t_ref_cursor; at_rec t2%ROWTYPE; NumRows PLS_INTEGER; BEGIN -- clean out global temporary table COMMIT;

child(pNumRecs, p_retcur); SELECT COUNT(*) INTO NumRows FROM t2; FOR i IN 1 .. NumRows LOOP FETCH p_retcur INTO at_rec; dbms_output.put_line(at_rec.x || ' - ' || at_rec.y); END LOOP; END parent; / set serveroutput on
$un The emo

exec exec exec exec

parent(2) parent(3) parent(1) parent(2)