CREATE OR REPLACE PROCEDURE UP_CAUSER_GetMaxId(user_id_info out number)
is
 TempID number;
 begin
 SELECT max(user_id)+1 into TempID FROM causer;
 IF (TempID IS NULL) then user_id_info:=-1;
 else 
 user_id_info:=TempID;
 END IF;
end;
这样的OUT参数为什么总在程序里报:“ORA-01036: 非法的变量名/编号”

解决方案 »

  1.   

    你的这个要求,用function不是很好吗?哈哈
      

  2.   

    这个存储过程表面上看没什么问题。
    问题关键是你如何调用它的?
      1  CREATE OR REPLACE PROCEDURE UP_CAUSER_GetMaxId(user_id_info out number)
      2  is
      3   TempID number;
      4   begin
      5   SELECT 1 into TempID FROM dual;
      6   IF (TempID IS NULL) then user_id_info:=-1;
      7   else
      8   user_id_info:=TempID;
      9   END IF;
     10* end;
     11  /过程已创建。SQL> set serveroutput on;
    SQL> declare 
      2  id number;
      3  begin
      4  up_causer_getmaxid(id);
      5  dbms_output.put_line(id);
      6  end;
      7  /
    1PL/SQL 过程已成功完成。
      

  3.   

    我是在C#里的调用它的。
    public static int getProc(string storedProcName, IDataParameter[] parameters)
        {
            using (OracleConnection connection = new OracleConnection(connectionString))
            {
                int result;
                int rowsAffected = 0;
                connection.Open();
                OracleCommand command = BuildIntCommand(connection, storedProcName, parameters);
                command.ExecuteNonQuery();
                result = Convert.ToInt32(command.Parameters["USER_ID_info"].Value);
                return result;
            }
        }
      

  4.   

    就是在command.ExecuteNonQuery();时
    OREACLE却说是:
    ORA-06550: 第 1 行, 第 37 列: 
    PLS-00103: 出现符号 "="在需要下列之一时:
    . ( * @ % & = -
      + ; < / > at in is mod not rem <an exponent (**)>
      <> or != or ~= >= <= <> and or like between || indicator
    符号 ".在 "=" 继续之前已插入。
      

  5.   

    嗬嗬,你少了参数的bind的部分。象下面这样:OracleParameter prm = new  OracleParameter("user_id_info",OracleDbType.number);
    prm3.Direction = ParameterDirection.Output;
    cmd.Parameters.Add(prm);
      

  6.   

    你在c#中调用出现的问题,问题不在oracle上
      

  7.   


    参数的bind的部分
    我放这个参数里的。
    BuildIntCommand(connection, storedProcName, parameters);
        private static OracleCommand BuildIntCommand(OracleConnection connection, string storedProcName, IDataParameter[] parameters)
        {
            OracleCommand command = BuildQueryCommand(connection, storedProcName, parameters);
            command.Parameters.Add(new OracleParameter("ReturnValue", OracleType.Int32, 4, ParameterDirection.ReturnValue, false, 0, 0, string.Empty, DataRowVersion.Default, null));
        }private static OracleCommand BuildQueryCommand(OracleConnection connection, string storedProcName, IDataParameter[] parameters)
        {
            OracleCommand command = new OracleCommand(storedProcName, connection);
            command.CommandType = CommandType.StoredProcedure;
            foreach (OracleParameter parameter in parameters)
            {
                command.Parameters.Add(parameter);
            }
            return command;
      

  8.   

    各位帮忙看一下,
    本来有试过在  :user_id_info 参数前加 “ :”,还是一样错!调用出现的问题:我想可能是的,但一直没有能看出那里错了。
      

  9.   

    参数的名字是ReturnValue,是不是有问题呀?ParameterDirection.ReturnValue?是应该是ParameterDirection.Output吧.ParameterDirection.ReturnValue好像是给function用的吧。
      

  10.   

    ParameterDirection.ReturnValue是给返回值用的。
    ParameterDirection.Output是给输出参数用的。
    是有区别的。
      

  11.   

    我没有环境测试,给你一个参照的URL:
    他的存储过程是SQL Server的,但是,我想,对你来说,重要的是调用的部分,而不是数据库的部分。
    http://msdn2.microsoft.com/ja-jp/library/59x02y99(VS.80).aspx