摘要自 Oracle性能控制艺术
DECLARE
l_ename emp.ename%TYPE :='SCOTT';
l_empno emp.empno%TYPE;
l_cursor INTEGER;
l_retval INTEGER;
BEGIN
l_cursor:=dbms_sql.open_cursor;
dbms_sql.parse(1_cursor,'SELECT empno FROM emp WHERE ename=:ename',1);
dbms_sql.define_column(l_cursor,1,l_empno);
dbms_sql.bind_variable(1_cursor,':ename',l_ename);
l_retval:=dbms_sql.execute(l_cursor);
IF dbms_sql.fetch_rows(l_cursor) >0
THEN
dbms_sql.column_value(l_cursor,1,l_empno);
END IF;
dbms_sql.close_cursor(l_cursor);
END;