在BEGIN与END之间不能这样写:
我给你一个存储过程你看看语法:
CREATE OR REPLACE PROCEDURE "GETSERIES" (
    vl_name IN VARCHAR2,
    vl_id   IN VARCHAR2,
    vl_len  IN INTEGER,
    vl_out OUT VARCHAR2
 )
IS
    cnt  INTEGER;
    temp INTEGER;
    vl_zz VARCHAR(30);
BEGIN
    SELECT count(*) INTO temp FROM t_sysinfo WHERE
        rtrim(INFONAME)=rtrim(vl_name);
    IF (temp<>0) THEN
    BEGIN
      SELECT info INTO temp FROM t_sysinfo WHERE rtrim(INFONAME)=rtrim(vl_name);
      temp:=temp+1;
      UPDATE t_sysinfo SET info=temp WHERE rtrim(infoname)=rtrim(vl_name);
    END;
    ELSE
    BEGIN
     temp:=1;
     INSERT INTO t_sysinfo(infoname,info) VALUES(vl_name,to_char(temp));
    END;
    END IF;    SELECT
concat(substr('00000000000000000000',1,20-length(to_char(temp))),to_char(temp))               c into  vl_zz      FROM dual;    if vl_id is not null  then
       SELECT
       concat(RTRIM(vl_id),substr(vl_zz,21-vl_len+length(RTRIM(vl_id)),vl_len)) c         into vl_out
       FROM dual;
    else
        SELECT
        substr(vl_zz,21-vl_len,vl_len) c into vl_out
        FROM dual;
    end if;
END;

解决方案 »

  1.   

    这个只能在9i中可以,用来返回纪录集。
    8i中,语句必须是PL/SQL语句。
    如:select aa into a from bb;
      

  2.   

    我刚学时也犯过一样的错,3yugui(亿硅) 说的让我高兴: 
      这个只能在9i中可以,用来返回纪录集。
     
      

  3.   

    给你一个使用游标的存储过程的例子,供参考!,也可以直接套用!create or replace procedure test
    as
      type ref_cursor is ref cursor;
      cursor_test ref_cursor;
      my_name test.name%type;
    begin
      open cursor_library for
           select name from test;
      loop
           fetch cursor_test into my_name;
           exit when cursor_test%notfound;
      end loop;
      close cursor_test;
    end test;
    /
      

  4.   

    SORRY 刚才的存储过程有错误,应该这样!create or replace procedure test
    as
      type ref_cursor is ref cursor;
      cursor_test ref_cursor;
      my_name test.name%type;
    begin
      open cursor_test for
           select name from table;
      loop
           fetch cursor_test into my_name;
           exit when cursor_test%notfound;
      end loop;
      close cursor_test;
    end test;
    /
      

  5.   

    select into 就可以了。
    不过你返回的记录太多了。听楼上的吧,等你的系统update到9i的时候再试试。