首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > 数据库开发 >

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

2012-03-30 
那位大神帮我看看?那里有错误?create or replace procedure ChangeInfo(tnum in number) asSqlStr varchar

那位大神帮我看看?那里有错误?
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 ;

热点排行