DECLARE
TYPE ref_cursor IS REF CURSOR;
v_ref_cursor ref_cursor;
CURSOR cur_get_order IS
SELECT organization_id,
organization_code
FROM mtl_parameters;
rec_cur_get_ordline_details cur_get_order%ROWTYPE;
v_sql VARCHAR2(200);
p_chr_code VARCHAR2(20) := 'SZK';
p_num_id NUMBER := NULL;
BEGIN
v_sql := ' select organization_id, organization_code from mtl_parameters where organization_code = :p_code';
IF p_num_id IS NOT NULL THEN
v_sql := v_sql || ' and organization_id = :p_id ';
ELSE
v_sql := v_sql || ' and nvl( :p_id, 1 ) = 1 ';
END IF;
dbms_output.put_line(v_sql);
OPEN v_ref_cursor FOR v_sql
USING p_chr_code, p_num_id;
LOOP
FETCH v_ref_cursor
INTO rec_cur_get_ordline_details;
EXIT WHEN v_ref_cursor%NOTFOUND;
dbms_output.put_line(rec_cur_get_ordline_details.organization_id);
END LOOP;
CLOSE v_ref_cursor;
END;
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/13975809/viewspace-1769211/
,如需转载,请注明出处,否则将追究法律责任。