oracle

来源:互联网 发布:jav网络机顶盒v8固件 编辑:程序博客网 时间:2024/06/16 11:05
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;
0 0