--
--Create by vivek on 20031217 for testing Dynamic cursor
PROCEDURE customer_name
IS
v_ename VARCHAR2 (20);
v_curs exec_sql.curstype;
v_rows INTEGER;
v_select VARCHAR2 (10000) := 'select customer_name from ra_customers where customer_id in (' || :customer_id || ') ';
BEGIN
v_curs := exec_sql.open_cursor;
exec_sql.parse (v_curs, v_select);
exec_sql.define_column (v_curs, 1, v_ename, 20);
v_rows := exec_sql.EXECUTE (v_curs);
WHILE exec_sql.fetch_rows (v_curs) > 0 LOOP
exec_sql.column_value (v_curs, 1, v_ename);
MESSAGE ('Customer Name ' || v_ename, NULL);
text_io.put_line ('Ename = ' || v_ename);
END LOOP;
MESSAGE (' ', NULL);
exec_sql.close_cursor (v_curs);
EXCEPTION
WHEN exec_sql.package_error THEN
text_io.put_line ('ERROR (' || TO_CHAR (exec_sql.last_error_code) || '): ' || exec_sql.last_error_mesg);
MESSAGE (('ERROR (' || TO_CHAR (exec_sql.last_error_code) || '): ' || exec_sql.last_error_mesg), NULL);
exec_sql.close_cursor (v_curs);
WHEN exec_sql.invalid_connection THEN
text_io.put_line ('ERROR: Not currently connected to a database');
MESSAGE (('ERROR: Not currently connected to a database'), NULL);
END customer_name;
Wednesday, December 17, 2008
Subscribe to:
Comments (Atom)