a grammar
my_name emp.ename%type;
Indicates that the data type of my_name is consistent with the data type of the ename field in the emp table.
two code
--引用型变量
set serverout on
declare
--定义引用型变量:查询并打印7839的姓名和薪水
--pname varchar2(20);
--psal number;
pname emp.ename%type;
psal emp.sal%type;
begin
--得到7839的姓名和薪水
select ename,sal into pname,psal from emp where EMPNO =7839;
--打印姓名和薪水
DBMS_OUTPUT.put_line(pname||'的薪水是'||psal);
end;
/
Three running results
King's salary is 5000
PL/SQL procedure completed successfully.