create or replace procedure sp_test(name varchar2)
as
feng varchar := '12'
begin 
  insert into ruan values(1,name);
  insert into ruan values(2,feng);
  dbms_output.put_line('333');
  exception
   when others then goto fu;
end;

解决方案 »

  1.   

    修改为:
    create or replace procedure sp_test(name varchar2)
    as
    begin 
      feng varchar := '12';
      <<fu>>
      insert into ruan values(1,name);
      insert into ruan values(2,feng);
      dbms_output.put_line('333');
      exception
       when others then goto fu;
    end;
    还是有这个错误出现
    Compilation errors for PROCEDURE SYS.SP_TESTError: PLS-00103: Encountered the symbol "VARCHAR" when expecting one of the following:
           
              := . ( @ % ;
           The symbol "." was substituted for "VARCHAR" to continue.
    Line: 4
    Text: feng varchar := '12';
      

  2.   

    create or replace procedure sp_test(name varchar2)
    as
    begin 
      feng varchar2(10) := '12';
      <<fu>>
      insert into ruan values(1,name);
      insert into ruan values(2,feng);
      dbms_output.put_line('333');
      exception
       when others then goto fu;
    end;,
    PL/SQL中,只有VARCHAR2类型,没有VARCHAR类型
      

  3.   

    create or replace procedure sp_test(name varchar2)
    is
    declare feng varchar2;
    begin
    .....
    end
      

  4.   

    create or replace procedure sp_test(name varchar2(10))
    as
    begin 
      feng varchar2(10) := '12';
      <<fu>>
      insert into ruan values(1,name);
      insert into ruan values(2,feng);
      dbms_output.put_line('333');
      exception
       when others then goto fu;
    end;,
    刚才忘记了改变存储过程变量中的变量类型赋长度
      

  5.   

    不是的,我用的是8I,有varchar这个数据类型的,
      feng varchar := '12';
    这样申明还是不行,到底问题出在哪里啊?
      

  6.   

    用 czj68586(阿草) 的试试,
    多试试就知道问题出在哪!
    还是不行.
    就逐行注释,知道找到问题的语句.
      

  7.   

    阿草的第二次回复中有误,参数中的varchar不能定义长度
      

  8.   

    create or replace procedure sp_test(name in varchar2)
    is 
      feng varchar2(10) := '12';
    begin 
      dbms_output.put_line('333');
    end;这样使对的,已经测试过了
      

  9.   

    surf88(无心化雨) ( ) 这样是对了。但是我就是想不通,在。。replace procedure sp_test(name in varchar2)这里申明变量的时候不用定义长度,而在下面为什么要定义长度了呢?
      

  10.   

    oracle8.1.7以上版本在in 和out的参数都是不能定义长度的,这里只能定义数据类型
    而下面的feng是参数,是你存储过程中使用到的参数,这个是需要定义长度的