set serveroutput on;
--引用型变量
declare
2 pname emp.ename%type;
3 psal emp.sal%type;
4 begin
5 select ename,sal into pname,psal from emp
6 where empno=7844;
7 dbms_output.put_line(pname||'的薪水是'||psal||'元');
8 end;
9 /
--记录型变量
declare
2 emp_rec emp%rowtype;
3 begin
4 select * into emp_rec from emp where empno = 7499;
5 dbms_output.put_line(emp_rec.ename||'的薪水是:'||emp_rec.sal);
6 end;
7 /
--if语句
set serveroutput on;
accept num prompt '请输入一个数字:';--num为地址
declare
pnum number := #
begin
if pnum = 0 then dbms_output.put_line('您输入数字为0');
elsif pnum = 1 then dbms_output.put_line('您输入数字为1');
elsif pnum = 2 then dbms_output.put_line('您输入数字为2');
else dbms_output.put_line('其他数字');
end if;
end;
/