Assign SQL query results to PL/SQL variables
SQL> SQL> drop table emp; Table dropped.-- from w ww . ja va2 s . c o m SQL> create table emp( 2 empno number(4,0), 3 ename varchar2(10), 4 job varchar2(9), 5 mgr number(4,0), 6 hiredate date, 7 sal number(7,2), 8 comm number(7,2), 9 deptno number(2,0) 10 ); SQL> SQL> insert into emp values(7839, 'KING', 'PRESIDENT', null, to_date('17-11-1981','dd-mm-yyyy'), 5000, null, 10); SQL> insert into emp values(7698, 'BLAKE', 'MANAGER', 7839,to_date('1-5-1981','dd-mm-yyyy'), 2850, null, 30); SQL> insert into emp values(7782, 'CLARK', 'MANAGER', 7839,to_date('9-6-1981','dd-mm-yyyy'), 2450, null, 10); SQL> SQL> declare 2 v_name_tx VARCHAR2(256); 3 begin 4 select eName 5 into v_name_tx 6 from emp 7 where empNo=7839; 8 9 DBMS_OUTPUT.PUT_LINE(v_name_tx); 10 end; 11 / SQL>