谢谢各位大侠create or replace procedure IDCARD(p_OldID varchar2) return varchar2 is  type TIArray is table of integer;
  type TCArray is table of char(1);
  Result varchar2(50);
  W      TIArray;
  A      TCArray;
  S      integer;
begin
  if p_OldID is null then
     return '';
  end if;
  if Length(p_OldID) <> 15 then
    return p_OldID;
  end if;
  W      := TIArray(7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2, 1);
  A      := TCArray('1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2');
  Result := SubStr(p_OldID, 1, 6) || '19' || SubStr(p_OldID, 7, 9);  S := 0;
  begin
    for i in 1 .. 17 loop
      S := S + to_number(SubStr(Result, i, 1)) * W(i);
    end loop;
  exception
    when others then
      return '';
end;
S := S mod 11;
Result := Result || A(s + 1);
return(Result);
end IDCARD;谢谢各位大侠PROCEDURE BOCM.IDCARD 编译错误错误:PLS-00103: 出现符号 "RETURN"在需要下列之一时:
        ; is with authid as
          cluster order using external deterministic parallel_enable
          pipelined
       符号 "authid在 "RETURN" 继续之前已插入。
行:1
文本:create or replace procedure IDCARD(p_OldID varchar2) return varchar2 is谢谢各位大侠

解决方案 »

  1.   

    过程没有return的,只有在参数里写out,建议你把过程改成函数吧:
    create or replace function IDCARD(p_OldID varchar2) return varchar2 is   type TIArray is table of integer; 
      type TCArray is table of char(1); 
      Result varchar2(50); 
      W      TIArray; 
      A      TCArray; 
      S      integer; 
    begin 
      if p_OldID is null then 
        return ''; 
      end if; 
      if Length(p_OldID) <> 15 then 
        return p_OldID; 
      end if; 
      W      := TIArray(7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2, 1); 
      A      := TCArray('1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2'); 
      Result := SubStr(p_OldID, 1, 6) || '19' || SubStr(p_OldID, 7, 9);   S := 0; 
      begin 
        for i in 1 .. 17 loop 
          S := S + to_number(SubStr(Result, i, 1)) * W(i); 
        end loop; 
      exception 
        when others then 
          return ''; 
    end; 
    S := S mod 11; 
    Result := Result || A(s + 1); 
    return(Result); 
    end IDCARD;
      

  2.   

    procedure 改为 function 就OK啦。
      

  3.   

    或者把:Result定义为out 参数。
    改为:
    create or replace procedure IDCARD(p_OldID in varchar2,o_outpara OUT VARCHAR2)  is。
    看看
      

  4.   

    procedure 不能用  return  --sqlserver 可以这么用
    可以用out 参数可以用function