plsqld的学习

declare --声明变量

begin --开始

dbms_output.put_line('hello world'); --程序块
end; --结束


--plsql变量的声明

declare
myName char;
age number(8,2);

married boolean:=true;

ename emp.ename%type;

emp_rec emp%rowtype;

begin

dbms_output.put_line('hello world');


end;


--查询 工号为 7839的员工 并把它的姓名打印出来


declare
e_ename emp.ename%type;
e_sal emp.sal%type;
begin
select e.ename,e.sal into e_ename,e_sal from emp e where e.empno=7839 ;

dbms_output.put_line(e_ename||'的薪水是'||e_sal);

end;



--plsql行类型


declare

emp_rec emp%rowtype;

begin
select * into emp_rec from emp e where e.empno=7839;


dbms_output.put_line(emp_rec.ename||'的薪水是'||emp_rec.sal);

end;


--接受键盘输入 plsql if else elsif 的用法

accept num prompt '请输入一个数据';

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;


oracle for循环的用法

for pname in (select ename from emp)


loop


end loop;
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值