Oracle's Stored Procedure Programming Lecture 5: Store the result of a select query into a variable

 

Store the result of the select query into a variable, you can store multiple columns in multiple variables at the same time, there must be one

  record, otherwise throw an exception (if no record throws NO_DATA_FOUND)

 


 

example: 

 

create or replace procedure test01 is

 

 

 v_empno number(10);--create variable to store employee number

 v_ename varchar2(10);--create variable to store employee name

 

begin

     SELECT empno,ename into v_empno,v_ename FROM emp where emp.empno=7782;

     dbms_output.put_line(v_empno||'----'||v_ename);--print variable 

 

 

end test01;

 

 

 

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326570278&siteId=291194637