写过程,返回出参就行了。另外
select s_sms_t_khdx.currval from dual;
也是你要的值

解决方案 »

  1.   

    谢谢,s_sms_t_khdx.currval,我怎么就没想起来用它呢~
    另外怎么把一个变量返回出来啊?我是ORACLE入门者,见笑了!
      

  2.   

    create or replace procedure aaa(v_id out number) as
    ls_xlh int;
    begin
    select s_sms_t_khdx.nextval into ls_xlh from dual;
    insert into sms_t_khdx(n_xlh,c_sjh,c_dxnr) values(ls_xlh,'13673377870','hello') ;--here   
    --begin
    v_id := ls_xlh;
    --end
    end;
      

  3.   

    返回参数。参考Microsft的MSDN的帮助。
      

  4.   

    OracleConnection conn = new OracleConnection(); 
    conn.ConnectionString = "Data Source=best;User ID=system;Password=manager"; 
    conn.Open(); 
    OracleCommand cmd =new OracleCommand();
    cmd.CommandText="smsinsert(??如果传这个变量怎么得到返回的值呢??)";
    cmd.CommandType=System.Data.CommandType.StoredProcedure;
    conn.Close();
      

  5.   

    我不知道如何把SQL语句中的变量返回到,应用程序(c#)中啊?
    求哪位大哥再指点一下
      

  6.   

    create or replace procedure smsinsert(n_id out number) as
    ls_xlh int;
    begin
    select s_sms_t_khdx.nextval into ls_xlh from dual;
    insert into sms_t_khdx(n_xlh,c_sjh,c_dxnr) values(ls_xlh,'13673377870','hello') ;
    n_id := ls_xlh;
    end;
    --------------------------------------
    OracleConnection conn = new OracleConnection(); 
    conn.ConnectionString = "Data Source=best;User ID=system;Password=manager"; 
    conn.Open(); 
    OracleCommand cmd =new OracleCommand();
    cmd.CommandText="smsinsert(??如果传这个变量怎么得到返回的值呢??)";
    cmd.CommandType=System.Data.CommandType.StoredProcedure;
    conn.Close();怎么把上面的ORACLE过程中的变量n_id返回到C#程序中呢?
      

  7.   

    OleDbCommand myCommand = new OleDbCommand();
    myCommand.Connection = OpenDB_Conn;

    OleDbParameter p1 ;
    //ÊÕ¼¯Èë²Î
    for ( int i = 0; i< inParameter.Length ;i++)
    {
    p1 = new OleDbParameter();
    p1.Direction=System.Data.ParameterDirection.Input;
    p1.Value = (string)inParameter[i];
    myCommand.Parameters.Add(p1);
    } //&Ecirc;&Otilde;&frac14;&macr;&sup3;&ouml;&sup2;&Icirc;
    for ( int i = 0; i< outParameter.Length ;i++)
    {
    OleDbParameter p2 = new OleDbParameter("", OleDbType.VarChar,30);
    p2.Direction = System.Data.ParameterDirection.Output;
    myCommand.Parameters.Add(p2);

    }
    myCommand.CommandType = System.Data.CommandType.StoredProcedure; myCommand.CommandText = storeName; try
    {
    myCommand.ExecuteNonQuery(); //&Ecirc;&Otilde;&frac14;&macr;&sup3;&ouml;&sup2;&Icirc;&micro;&Auml;&Ouml;&micro;
    for ( int i = 0; i < outParameter.Length; i++ )
    {
    outParameter[i] = myCommand.Parameters[i + inParameter.Length].Value.ToString();
    } }