-------转载请注明出处,同时欢迎大家转载--------
块
declare
username varchar2(20);
begin
select t.ename into username from emp t where rownum=1;
dbms_output.put_line(username);
end;
2 oracle 中case when 用法
3 oracle 中loop循环的用法
declare
q number :=0;
begin
loop
q:=q+1;
dbms_output.put_line('q='||q);
exit when q=10;
end loop;
end;
4.loop循环中另外的一种退出方法
declare
q number :=0 ;
begin
loop
q:=q+ 1;
dbms_output.put_line( 'q='||q);
if q=10
then
exit;
end if ;
end loop ;
dbms_output.put_line('hello i barek'); ---exit跳出后这句号会执行
end;
5.loop循环中另外的一种
declare
q number := 8;
begin
while q < 100 loop
q := q + 1;
dbms_output.put_line( 'hello world good ');
end loop;
end;
6.loop 的for用法
declare
q number := 8;
begin
for c in 1..10 loop --- 要想从10到1 要在 in 的后面加上 reverse
dbms_output.put_line('c is '||c);
dbms_output.put_line('hello world good ');
end loop;
end;
7.goto语句的用法
declare
sal number ;
begin
select t.sal into sal from emp t where rownum=1 ;
if sal<20000
then
goto a;
else
goto b;
end if;
<<a>>
dbms_output.put_line('this is a');
<<b>>
dbms_output.put_line('this is b');
end;