2

Oracle関数からretrun値を抽出する必要があります。

これは関数です:

FUNCTION set_idoc
    (Pidoctyp       in varchar2,    -- tip idoc-a
     Pdirect        in varchar2,    -- smjer idoc-a
     Psgln01        in varchar2,    -- identifikator pošiljatelja
     Prgln01        in varchar2,    -- identifikator primatelja
     Pdtdc01        in varchar2,    -- datum i vrijeme kreiranja poruke
     Pbodi01        in varchar2)    -- identifikator
return number is

Lidoc_num       NUMBER;
Lind_obr        AGR3PL_IDOC.ind_obr%TYPE;
BEGIN

    SELECT SEQ_IDOC.nextval, DECODE(Pdirect, '1', 'U', 'P')
      INTO Lidoc_num, Lind_obr
      FROM DUAL;

    INSERT INTO AGR3PL_IDOC (idoc_num, direct, idoctyp, sgln01, rgln01, dtdc01, bodi01, ind_obr)
    VALUES (Lidoc_num, Pdirect, Pidoctyp, Psgln01, Prgln01, Pdtdc01, Pbodi01, Lind_obr);

    return Lidoc_num;
EXCEPTION
    when others then raise;
END; 

したがって、Lidoc_num値を抽出する必要があります

私はこのように試しました:

System.Data.OracleClient.OracleParameter Lidoc_num = new  System.Data.OracleClient.OracleParameter();
Lidoc_num.Direction = ParameterDirection.ReturnValue;
  Lidoc_num.Size = 16;
                        com1.Parameters.Add(Lidoc_num);

                        //Predaj parametre funkciji i vrati broj dokumneta iz baze
                        com1.CommandText = "TRB01.set_idoc('DOC','1','"
                                                           + sender + "','"
                                                           + reciver + "','"
                                                           + cre_date + "','"
                                                           + bod_ID + "')";
                        com1.ExecuteNonQuery();

                        Lidoc_num = com1.Parameters[0].Value;

しかし、何もないので、どうすればこれを行うことができますか

よろしくお願いします!!

4

1 に答える 1

3

解決せよ!! 次のようにする必要があります。

System.Data.OracleClient.OracleParameter prm = new System.Data.OracleClient.OracleParameter();
                prm.Direction = ParameterDirection.ReturnValue;
                prm.DbType = DbType.AnsiString;
                prm.Size = 16;
                com1.Parameters.Add(prm);


                com1.CommandText = "TRB01.set_idoc('DOC','1','"
                                                   + sender + "','"
                                                   + reciver + "','"
                                                   + cre_date + "','"
                                                   + bod_ID + "')";
                com1.ExecuteNonQuery();

                Lidoc_num = com1.Parameters[0].Value.ToString();
于 2012-05-28T08:47:13.023 に答える