Oracle Sql 控制流程

Connected to Oracle Database 11g Enterprise Edition Release 11.1.0.6.0
Connected as SCOTT@ORCL

SQL> set serveroutput on
SQL> declare
2 var_name1 varchar2(50)
3 var_name2 varchar2(50)
4 begin
5 var_name1:='East';
6 var_name2:='xiaoke';
7 if length(var_name1) > length(var_name2) then
dbms_output.put_line('字符串“'||var_name1||'”的长度比字符串“'||var_name2||'”的长度小');
end if;
8 end;
9 /

declare
var_name1 varchar2(50)
var_name2 varchar2(50)
begin
var_name1:='East';
var_name2:='xiaoke';
if length(var_name1) > length(var_name2) then
end;

ORA-06550: 第 4 行, 第 1 列:
PLS-00103: 出现符号 "VAR_NAME2"在需要下列之一时:
:= ; not null default
character
符号 ";" 被替换为 "VAR_NAME2" 后继续。
ORA-06550: 第 5 行, 第 1 列:
PLS-00103: 出现符号 "BEGIN"在需要下列之一时:
:= ; not null default
character
符号 ";" 被替换为 "BEGIN" 后继续。
ORA-06550: 第 9 行, 第 1 列:
PLS-00103: 出现符号 "END"在需要下列之一时:
( begin case declare exit
for goto if loop mod null pragma raise return select update
while with <an identifier>
<a double-quoted delimited-identifier> <a bind variable> <<
continue

SQL> set serveroutput on
SQL> declare
2 var_name1 varchar2(50);
3 var_name2 varchar2(50);
4 begin
5 var_name1:='East';
6 var_name2:='xiaoke';
7 if length(var_name1) > length(var_name2) then
8 dbms_output.put_line('字符串“'||var_name1||'”的长度比字符串“'||var_name2||'”的长度小');
9 end if;
10 end;
11 /

PL/SQL procedure successfully completed
SQL> set serveroutput on
SQL> declare
2 age int:=55;

5 /

declare
age int:=55;
begin age >=56 then

ORA-06550: 第 4 行, 第 11 列:
PLS-00103: 出现符号 "="在需要下列之一时:
:= . ( @ % ;

SQL> set serveroutput on
SQL> declare
2 age int:=56;
3 begin
4 if then

end iif then

end if;;
5 /

declare
age int:=56;
begin
if then

ORA-06550: 第 5 行, 第 5 列:
PLS-00103: 出现符号 "THEN"在需要下列之一时:
( - + case mod new not
null <an identifier> <a double-quoted delimited-identifier>
<a bind variable> continue avg count current exists max min
prior sql stddev sum variance execute forall merge time
timestamp interval date
<a string literal with character set specification>
<a number> <a single-quoted SQL string> pipe
<一个带有字符集说明的可带引号的字符串文字>
<一个可带引号的 SQL 字符串> purge

SQL> set serveroutput on
SQL> declare
2 age int:=56;
3 begin
4 if then

end i/
5 /

declare
age int:=56;
begin
if then

ORA-06550: 第 5 行, 第 5 列:
PLS-00103: 出现符号 "THEN"在需要下列之一时:
( - + case mod new not
null <an identifier> <a double-quoted delimited-identifier>
<a bind variable> continue avg count current exists max min
prior sql stddev sum variance execute forall merge time
timestamp interval date
<a string literal with character set specification>
<a number> <a single-quoted SQL string> pipe
<一个带有字符集说明的可带引号的字符串文字>
<一个可带引号的 SQL 字符串> purge

SQL> set serveroutput on
SQL> declare
2 age int:=56;
3 begin
4 if age >56 then
dbms_output.put_line('您可以退休了!');
end i
5
6 /

declare
age int:=56;
begin
if age >56 then

ORA-06550: 第 8 行, 第 0 列:
PLS-00103: 出现符号 "end-of-file"在需要下列之一时:
( begin case
declare exit for goto if loop mod null pragma raise return
select update while with <an identifier>
<a double-quoted delimited-identifier> <a bind variable> <<
continue close current delete fetch lock insert open rollback
savepoint set sql execute commit forall merge pipe purge

SQL> set serveroutput on
SQL> declare
2 age int:=56;
3 begin
4 if age >56 then
5 dbms_output.put_line('您可以退休了');
6 else
7 dbms_output.put_line('您小于56岁,不可以退休');
8 end if;
9 end;
10 /

您小于56岁,不可以退休

PL/SQL procedure successfully completed

SQL> set serveroutput on
SQL> declare
2 month int:=10;
3 begin
4 if age

end if;

end if;
5 /

declare
month int:=10;
begin
f age

ORA-06550: 第 5 行, 第 3 列:
PLS-00103: 出现符号 "AGE"在需要下列之一时:
:= . ( @ % ;

SQL> set serverouput on
Cannot SET SERVEROUPUT

SQL> set serveroutput on
SQL> declare
2 month int:=10;
3 begin
4 if month>=0 and month<=3 then
5 dbms_output.put_line('春季');
6 elsif month >=4 and month<=6 then
7 dbms_output.put_line('夏季');
8 if month >= 7 and month <= 9 then
9 db ms_output.put_line('秋季');
10 if month>=10 and month<=12 then
11 dbms_output.put_line('冬季');
12 else
13 dbms_output.put_line('对不起月份不合法');
14 end if;
15 end;
16 /

declare
month int:=10;
begin
if month>=0 and month<=3 then
dbms_output.put_line('春季');

if month >= 7 and month <= 9 then

if month>=10 and month<=12 then
dbms_output.put_line('冬季');
else
dbms_output.put_line('对不起月份不合法');
end if;
end;

ORA-06550: 第 6 行, 第 30 列:
PLS-00103: 出现符号 ";"在需要下列之一时:
:= . ( % ;

SQL>set serveroutput on
2 declare
3 month int:=10;

et serveroutput on
declare
month int:=10

ORA-00900: 无效 SQL 语句

SQL> set serveroutput on
SQL> declare
2 month int:=10;
3 if month>=1 and month<=3 then
4 dbms_output.put_line('chun');
5 elsif month>=4 and month<=6 then
6 dbms_output.put_line('xia');
7 else
8 dbms_output.put_line('buhefa0');
9 end if;
10 end;
11 /

declare
month int:=10;
if month>=1 and month<=3 then
dbms_output.put_line('chun');
elsif month>=4 and month<=6 then
dbms_output.put_line('xia');
else
dbms_output.put_line('buhefa0');
end if;
end;

ORA-06550: 第 4 行, 第 1 列:
PLS-00103: 出现符号 "IF"在需要下列之一时:
begin function pragma
procedure subtype type <an identifier>
<a double-quoted delimited-identifier> current cursor delete
exists prior

SQL>
SQL> set serveroutput on
SQL> declare
2 month int:=10;
3 begin
4 if month>=1 and month<=3 then
5 dbms_output.put_line('chun');
6 elsif month>=4 and month<=6 then
7 dbms_output.put_line('xia');
8 else
9 dbms_output.put_line('buhefa0');
10 end if;
11 end;
12 /

buhefa0

PL/SQL procedure successfully completed

SQL>

posted @ 2017-09-04 16:07  进击的大黄瓜  阅读(1213)  评论(0编辑  收藏  举报