一个很简单的存储过程。我测试了2个。一个查询的一个插入的。create or replace procedure test1 as
code test.tid%type;
begin
 select tid into code from test where tid='1';
end;create or replace procedure test2 as
begin
 insert into test(tid) values('2');
end;
这样2个简单的存储过程。
用exec执行。
无论是不是带参数的那种。
用as或is(我搞不清用as和is的区别),最后执行都报
ORA-00900: 无效 SQL 语句。
oracle9i和oracle10g都试过。有没有人知道这是个什么问题啊。
求教

解决方案 »

  1.   


    --as和is没区别的as是mssql库中的写法,is是oralce特有的,oracle也支持as
    --你的test1写法是没问题的,只是如果tid='1'的记录是0条或多条,则会有错
    --执行方式,如果在begin end 块,则不要加exec
    exec test1;
    /
    exec test2;
    /
    --如,在begin end中
    begin
      test1;
    end;
    /
    begin
      test2;
    end;
    /
      

  2.   

    test1我测试过OK。我觉得as和is是一样的,定义的两种不同的表达。
      

  3.   

    as, is都可以,这不是问题.
    看上去没有问题,我也实际测过。tony@ORA11GR2> create table test(tid varchar2(100));表已创建。tony@ORA11GR2> create or replace procedure test1 as
      2  code test.tid%type;
      3  begin
      4   select tid into code from test where tid='1';
      5  end;
      6  /过程已创建。tony@ORA11GR2> create or replace procedure test2 as
      2  begin
      3   insert into test(tid) values('2');
      4  end;
      5
      6  /过程已创建。tony@ORA11GR2> insert into test values('1');已创建 1 行。tony@ORA11GR2> exec test1PL/SQL 过程已成功完成。tony@ORA11GR2> exec test2PL/SQL 过程已成功完成。tony@ORA11GR2>
      

  4.   

    你用exec执行,是在sqlplus中吧?
    否则要用如下形式
    begin
      test2;
    end;