oracle

本文通过几个具体的示例介绍了PL/SQL的基础用法,包括变量声明与赋值、条件判断、循环操作及简单的数据库操作等。这些示例涵盖了基本的编程结构,并展示了如何在Oracle数据库环境下使用PL/SQL进行数据处理。
set serveroutput on
declare
name VARCHAR2(20):='faafaf';
begin
dbms_output.put_line(name);
end;
/




一定就单引号,多个空格也不行。


select ... into 语句赋值,其结果必须是一行,不能多行或无纪录。


select ename from scott.emp where empno=7934;


declare
name varchar2(50) default 'null';
begin
select ename into name from scott.emp where empno='7934';
dbms_output.put_line(name);
end;
/




课本P193
declare
m number;
n number;
begin
m:=10;
n:=20;
if m-n>=0 then
dbms_output.put_line(m||'>'||n);
end if;
dbms_output.put_line(m||'<'||n);
end;


课本P195
case 语句


declare
xf number;
begin
select sal into xf from scott.emp where empno=7934;
case
when xf>2500 then
dbms_output.put_line('你的钱好多啊');


when xf>1500 then
dbms_output.put_line('你的钱好多啊2');
else
dbms_output.put_line('你的钱好多啊3');
end case;
dbms_output.put_line('wc');
end;
/




create table scott.temp(id number);
declare
i integer:=1;
begin
loop
insert into scott.temp values (i);
exit when i=10;
i:=i+1;
end loop;
end;


select * from scott.tmep;
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值