当前位置: 代码迷 >> 数据仓库 >> 那位大神帮小弟我看看?那里有异常
  详细解决方案

那位大神帮小弟我看看?那里有异常

热度:129   发布时间:2016-05-05 16:09:28.0
那位大神帮我看看?那里有错误?
create or replace procedure ChangeInfo(tnum in number) as
  SqlStr varchar(250);
 begin
  case 
  when tnum= 1 then
  SqlStr:='select tt.owner,tt.object_name from test_table tt where tt.owner=''v''';
  when tnum= 2 then
  SqlStr:='select tt.owner,tt.object_name from test_table tt where tt.owner=''a''';
  when tnum= 3 then
  SqlStr:='select tt.owner,tt.object_name from test_table tt where tt.owner=''b''';
  else 
  SqlStr:='select tt.owner,tt.object_name from test_table tt where tt.owner not in (''v'',''a'',''b'')';
  end;
   
  dbms_output.put_line(SqlStr);
 end ;
Compilation errors for PROCEDURE CASIC.CHANGEINFO

Error: PLS-00103: 出现符号 ";"在需要下列之一时:
  case
  符号 "case" 被替换为 ";" 后继续。
Line: 13
Text: end;


------解决方案--------------------
create or replace procedure ChangeInfo(tnum in number) as
SqlStr varchar(250);
 begin
case
when tnum= 1 then
SqlStr:='select tt.owner,tt.object_name from test_table tt where tt.owner=''v''';
when tnum= 2 then
SqlStr:='select tt.owner,tt.object_name from test_table tt where tt.owner=''a''';
when tnum= 3 then
SqlStr:='select tt.owner,tt.object_name from test_table tt where tt.owner=''b''';
else
SqlStr:='select tt.owner,tt.object_name from test_table tt where tt.owner not in (''v'',''a'',''b'')';
 end case ;

dbms_output.put_line(SqlStr);
end ;
  相关解决方案