-3

odp.net を使用して C# で Oracle オブジェクト タイプをクラスとしてマッピングした後、クラスをストアド プロシージャに戻して、数値データを持つすべての属性のテーブルにデータを挿入します。例外はありません。以下のようにコードが添付されています。Oracle 9i と asp.net v2 を使用しています。

新しい観察: 変数の型がnumber(1)の場合、以下と同じ構造で適切に挿入されますが、Number、Number(4)、Number(3,2)などの他のケースでは、すべての値がnullになります。

以下の例では、以下の列は挿入後に空です:

  1. オンオーダー
  2. ON_VERSION
  3. ON_VERSION1
  4. ON_VERSION

しかし、他の変数は完全に挿入されます。

  • Oracle DB の関数にアイテムを送信すると、数字が含まれません。タイプ構造:

    create or replace type CMMT_OBJECTS_TYPE is object( OV_FIX_REF_NO VARCHAR2(40), ON_ORDER NUMBER(4), OV_OBJECT_NAME VARCHAR2(100), OV_CATEGORY VARCHAR2(12), OV_SCOPE VARCHAR2(12), OV_TYPE VARCHAR2(12), OV_LASTUPD_USER VARCHAR2(40), OV_LASTUPD_PROG VARCHAR2(40)、OD_LASTUPD DATE、OV_LOCATION VARCHAR2(40)、OV_REMARKS VARCHAR2(4000)、ON_VERSION NUMBER(10,3)、ON_VERSION1 NUMBER(10,3)、OV_OBJECT_CLASSIFICATION VARCHAR2(5)、OV_OBJECT_OVREGECTION VARCHAR2(5) VARCHAR2(3)、ON_VERSION2 NUMBER、ON_VERSION3 VARCHAR2(20) ); /

odp.net で自動生成されたコード

    //

    ------------------------------------------------------------------------------
    // <auto-generated>
    //     This code was generated by a tool.
    //     Runtime Version:2.0.50727.3643
    //
    //     Changes to this file may cause incorrect behavior and will be lost if
    //     the code is regenerated.
    // </auto-generated>
    //------------------------------------------------------------------------------

    namespace xxxBIZ {
        using System;
        using Oracle.DataAccess.Client;
        using Oracle.DataAccess.Types;
        using System

.Xml.Serialization;
    using System.Xml.Schema;


    public class CMMT_OBJECTS_TYPE : INullable, IOracleCustomType, IXmlSerializable {

        private bool m_IsNull;

        private string m_OV_SCOPE;

        private string m_OV_REMARKS;

        private string m_OV_LASTUPD_USER;

        private Decimal m_ON_VERSION1;

        private bool m_ON_VERSION1IsNull;

        private string m_OV_FIX_REF_NO;

        private string m_OV_OBJECT_REGION;

        private string m_OV_OBJECT_NAME;

        private string m_OV_CATEGORY;

        private Decimal m_ON_ORDER;

        private bool m_ON_ORDERIsNull;

        private System.DateTime m_OD_LASTUPD;

        private bool m_OD_LASTUPDIsNull;

        private string m_OV_LASTUPD_PROG;

        private string m_OV_LOCATION;

        private string m_ON_VERSION3;

        private Decimal m_ON_VERSION2;

        private bool m_ON_VERSION2IsNull;

        private Decimal m_ON_VERSION;

        private bool m_ON_VERSIONIsNull;

        private string m_OV_OBJECT_TYPE;

        private string m_OV_TYPE;

        private string m_OV_OBJECT_CLASSIFICATION;

        public CMMT_OBJECTS_TYPE() {
            // TODO : Add code to initialise the object
            this.m_ON_VERSION1IsNull = true;
            this.m_ON_ORDERIsNull = true;
            this.m_OD_LASTUPDIsNull = true;
            this.m_ON_VERSION2IsNull = true;
            this.m_ON_VERSIONIsNull = true;
        }

        public CMMT_OBJECTS_TYPE(string str) {
            // TODO : Add code to initialise the object based on the given string 
        }

        public virtual bool IsNull {
            get {
                return this.m_IsNull;
            }
        }

        public static CMMT_OBJECTS_TYPE Null {
            get {
                CMMT_OBJECTS_TYPE obj = new CMMT_OBJECTS_TYPE();
                obj.m_IsNull = true;
                return obj;
            }
        }

        [OracleObjectMappingAttribute("OV_SCOPE")]
        public string OV_SCOPE {
            get {
                return this.m_OV_SCOPE;
            }
            set {
                this.m_OV_SCOPE = value;
            }
        }

        [OracleObjectMappingAttribute("OV_REMARKS")]
        public string OV_REMARKS {
            get {
                return this.m_OV_REMARKS;
            }
            set {
                this.m_OV_REMARKS = value;
            }
        }

        [OracleObjectMappingAttribute("OV_LASTUPD_USER")]
        public string OV_LASTUPD_USER {
            get {
                return this.m_OV_LASTUPD_USER;
            }
            set {
                this.m_OV_LASTUPD_USER = value;
            }
        }

        [OracleObjectMappingAttribute("ON_VERSION1")]
        public Decimal ON_VERSION1 {
            get {
                return this.m_ON_VERSION1;
            }
            set {
                this.m_ON_VERSION1 = value;
            }
        }

        public bool ON_VERSION1IsNull {
            get {
                return this.m_ON_VERSION1IsNull;
            }
            set {
                this.m_ON_VERSION1IsNull = value;
            }
        }

        [OracleObjectMappingAttribute("OV_FIX_REF_NO")]
        public string OV_FIX_REF_NO {
            get {
                return this.m_OV_FIX_REF_NO;
            }
            set {
                this.m_OV_FIX_REF_NO = value;
            }
        }

        [OracleObjectMappingAttribute("OV_OBJECT_REGION")]
        public string OV_OBJECT_REGION {
            get {
                return this.m_OV_OBJECT_REGION;
            }
            set {
                this.m_OV_OBJECT_REGION = value;
            }
        }

        [OracleObjectMappingAttribute("OV_OBJECT_NAME")]
        public string OV_OBJECT_NAME {
            get {
                return this.m_OV_OBJECT_NAME;
            }
            set {
                this.m_OV_OBJECT_NAME = value;
            }
        }

        [OracleObjectMappingAttribute("OV_CATEGORY")]
        public string OV_CATEGORY {
            get {
                return this.m_OV_CATEGORY;
            }
            set {
                this.m_OV_CATEGORY = value;
            }
        }

        [OracleObjectMappingAttribute("ON_ORDER")]
        public Decimal ON_ORDER {
            get {
                return this.m_ON_ORDER;
            }
            set {
                this.m_ON_ORDER = value;
            }
        }

        public bool ON_ORDERIsNull {
            get {
                return this.m_ON_ORDERIsNull;
            }
            set {
                this.m_ON_ORDERIsNull = value;
            }
        }

        [OracleObjectMappingAttribute("OD_LASTUPD")]
        public System.DateTime OD_LASTUPD {
            get {
                return this.m_OD_LASTUPD;
            }
            set {
                this.m_OD_LASTUPD = value;
            }
        }

        public bool OD_LASTUPDIsNull {
            get {
                return this.m_OD_LASTUPDIsNull;
            }
            set {
                this.m_OD_LASTUPDIsNull = value;
            }
        }

        [OracleObjectMappingAttribute("OV_LASTUPD_PROG")]
        public string OV_LASTUPD_PROG {
            get {
                return this.m_OV_LASTUPD_PROG;
            }
            set {
                this.m_OV_LASTUPD_PROG = value;
            }
        }

        [OracleObjectMappingAttribute("OV_LOCATION")]
        public string OV_LOCATION {
            get {
                return this.m_OV_LOCATION;
            }
            set {
                this.m_OV_LOCATION = value;
            }
        }

        [OracleObjectMappingAttribute("ON_VERSION3")]
        public string ON_VERSION3 {
            get {
                return this.m_ON_VERSION3;
            }
            set {
                this.m_ON_VERSION3 = value;
            }
        }

        [OracleObjectMappingAttribute("ON_VERSION2")]
        public Decimal ON_VERSION2 {
            get {
                return this.m_ON_VERSION2;
            }
            set {
                this.m_ON_VERSION2 = value;
            }
        }

        public bool ON_VERSION2IsNull {
            get {
                return this.m_ON_VERSION2IsNull;
            }
            set {
                this.m_ON_VERSION2IsNull = value;
            }
        }

        [OracleObjectMappingAttribute("ON_VERSION")]
        public Decimal ON_VERSION {
            get {
                return this.m_ON_VERSION;
            }
            set {
                this.m_ON_VERSION = value;
            }
        }

        public bool ON_VERSIONIsNull {
            get {
                return this.m_ON_VERSIONIsNull;
            }
            set {
                this.m_ON_VERSIONIsNull = value;
            }
        }

        [OracleObjectMappingAttribute("OV_OBJECT_TYPE")]
        public string OV_OBJECT_TYPE {
            get {
                return this.m_OV_OBJECT_TYPE;
            }
            set {
                this.m_OV_OBJECT_TYPE = value;
            }
        }

        [OracleObjectMappingAttribute("OV_TYPE")]
        public string OV_TYPE {
            get {
                return this.m_OV_TYPE;
            }
            set {
                this.m_OV_TYPE = value;
            }
        }

        [OracleObjectMappingAttribute("OV_OBJECT_CLASSIFICATION")]
        public string OV_OBJECT_CLASSIFICATION {
            get {
                return this.m_OV_OBJECT_CLASSIFICATION;
            }
            set {
                this.m_OV_OBJECT_CLASSIFICATION = value;
            }
        }

        public virtual void FromCustomObject(Oracle.DataAccess.Client.OracleConnection con, System.IntPtr pUdt) {
            Oracle.DataAccess.Types.OracleUdt.SetValue(con, pUdt, "OV_SCOPE", this.OV_SCOPE);
            Oracle.DataAccess.Types.OracleUdt.SetValue(con, pUdt, "OV_REMARKS", this.OV_REMARKS);
            Oracle.DataAccess.Types.OracleUdt.SetValue(con, pUdt, "OV_LASTUPD_USER", this.OV_LASTUPD_USER);
            if ((ON_VERSION1IsNull == false)) {
                Oracle.DataAccess.Types.OracleUdt.SetValue(con, pUdt, "ON_VERSION1", this.ON_VERSION1);
            }
            Oracle.DataAccess.Types.OracleUdt.SetValue(con, pUdt, "OV_FIX_REF_NO", this.OV_FIX_REF_NO);
            Oracle.DataAccess.Types.OracleUdt.SetValue(con, pUdt, "OV_OBJECT_REGION", this.OV_OBJECT_REGION);
            Oracle.DataAccess.Types.OracleUdt.SetValue(con, pUdt, "OV_OBJECT_NAME", this.OV_OBJECT_NAME);
            Oracle.DataAccess.Types.OracleUdt.SetValue(con, pUdt, "OV_CATEGORY", this.OV_CATEGORY);
            if ((ON_ORDERIsNull == false)) {
                Oracle.DataAccess.Types.OracleUdt.SetValue(con, pUdt, "ON_ORDER", this.ON_ORDER);
            }
            if ((OD_LASTUPDIsNull == false)) {
                Oracle.DataAccess.Types.OracleUdt.SetValue(con, pUdt, "OD_LASTUPD", this.OD_LASTUPD);
            }
            Oracle.DataAccess.Types.OracleUdt.SetValue(con, pUdt, "OV_LASTUPD_PROG", this.OV_LASTUPD_PROG);
            Oracle.DataAccess.Types.OracleUdt.SetValue(con, pUdt, "OV_LOCATION", this.OV_LOCATION);
            Oracle.DataAccess.Types.OracleUdt.SetValue(con, pUdt, "ON_VERSION3", this.ON_VERSION3);
            if ((ON_VERSION2IsNull == false)) {
                Oracle.DataAccess.Types.OracleUdt.SetValue(con, pUdt, "ON_VERSION2", this.ON_VERSION2);
            }
            if ((ON_VERSIONIsNull == false)) {
                Oracle.DataAccess.Types.OracleUdt.SetValue(con, pUdt, "ON_VERSION", this.ON_VERSION);
            }
            Oracle.DataAccess.Types.OracleUdt.SetValue(con, pUdt, "OV_OBJECT_TYPE", this.OV_OBJECT_TYPE);
            Oracle.DataAccess.Types.OracleUdt.SetValue(con, pUdt, "OV_TYPE", this.OV_TYPE);
            Oracle.DataAccess.Types.OracleUdt.SetValue(con, pUdt, "OV_OBJECT_CLASSIFICATION", this.OV_OBJECT_CLASSIFICATION);
        }

        public virtual void ToCustomObject(Oracle.DataAccess.Client.OracleConnection con, System.IntPtr pUdt) {
            this.OV_SCOPE = ((string)(Oracle.DataAccess.Types.OracleUdt.GetValue(con, pUdt, "OV_SCOPE")));
            this.OV_REMARKS = ((string)(Oracle.DataAccess.Types.OracleUdt.GetValue(con, pUdt, "OV_REMARKS")));
            this.OV_LASTUPD_USER = ((string)(Oracle.DataAccess.Types.OracleUdt.GetValue(con, pUdt, "OV_LASTUPD_USER")));
            this.ON_VERSION1IsNull = Oracle.DataAccess.Types.OracleUdt.IsDBNull(con, pUdt, "ON_VERSION1");
            if ((ON_VERSION1IsNull == false)) {
                this.ON_VERSION1 = ((Decimal)(Oracle.DataAccess.Types.OracleUdt.GetValue(con, pUdt, "ON_VERSION1")));
            }
            this.OV_FIX_REF_NO = ((string)(Oracle.DataAccess.Types.OracleUdt.GetValue(con, pUdt, "OV_FIX_REF_NO")));
            this.OV_OBJECT_REGION = ((string)(Oracle.DataAccess.Types.OracleUdt.GetValue(con, pUdt, "OV_OBJECT_REGION")));
            this.OV_OBJECT_NAME = ((string)(Oracle.DataAccess.Types.OracleUdt.GetValue(con, pUdt, "OV_OBJECT_NAME")));
            this.OV_CATEGORY = ((string)(Oracle.DataAccess.Types.OracleUdt.GetValue(con, pUdt, "OV_CATEGORY")));
            this.ON_ORDERIsNull = Oracle.DataAccess.Types.OracleUdt.IsDBNull(con, pUdt, "ON_ORDER");
            if ((ON_ORDERIsNull == false)) {
                this.ON_ORDER = ((Decimal)(Oracle.DataAccess.Types.OracleUdt.GetValue(con, pUdt, "ON_ORDER")));
            }
            this.OD_LASTUPDIsNull = Oracle.DataAccess.Types.OracleUdt.IsDBNull(con, pUdt, "OD_LASTUPD");
            if ((OD_LASTUPDIsNull == false)) {
                this.OD_LASTUPD = ((System.DateTime)(Oracle.DataAccess.Types.OracleUdt.GetValue(con, pUdt, "OD_LASTUPD")));
            }
            this.OV_LASTUPD_PROG = ((string)(Oracle.DataAccess.Types.OracleUdt.GetValue(con, pUdt, "OV_LASTUPD_PROG")));
            this.OV_LOCATION = ((string)(Oracle.DataAccess.Types.OracleUdt.GetValue(con, pUdt, "OV_LOCATION")));
            this.ON_VERSION3 = ((string)(Oracle.DataAccess.Types.OracleUdt.GetValue(con, pUdt, "ON_VERSION3")));
            this.ON_VERSION2IsNull = Oracle.DataAccess.Types.OracleUdt.IsDBNull(con, pUdt, "ON_VERSION2");
            if ((ON_VERSION2IsNull == false)) {
                this.ON_VERSION2 = ((Decimal)(Oracle.DataAccess.Types.OracleUdt.GetValue(con, pUdt, "ON_VERSION2")));
            }
            this.ON_VERSIONIsNull = Oracle.DataAccess.Types.OracleUdt.IsDBNull(con, pUdt, "ON_VERSION");
            if ((ON_VERSIONIsNull == false)) {
                this.ON_VERSION = ((Decimal)(Oracle.DataAccess.Types.OracleUdt.GetValue(con, pUdt, "ON_VERSION")));
            }
            this.OV_OBJECT_TYPE = ((string)(Oracle.DataAccess.Types.OracleUdt.GetValue(con, pUdt, "OV_OBJECT_TYPE")));
            this.OV_TYPE = ((string)(Oracle.DataAccess.Types.OracleUdt.GetValue(con, pUdt, "OV_TYPE")));
            this.OV_OBJECT_CLASSIFICATION = ((string)(Oracle.DataAccess.Types.OracleUdt.GetValue(con, pUdt, "OV_OBJECT_CLASSIFICATION")));
        }

        public virtual void ReadXml(System.Xml.XmlReader reader) {
            // TODO : Read Serialized Xml Data
        }

        public virtual void WriteXml(System.Xml.XmlWriter writer) {
            // TODO : Serialize object to xml data
        }

        public virtual XmlSchema GetSchema() {
            // TODO : Implement GetSchema
            return null;
        }

        public override string ToString() {
            // TODO : Return a string that represents the current object
            return "";
        }

        public static CMMT_OBJECTS_TYPE Parse(string str) {
            // TODO : Add code needed to parse the string and get the object represented by the string
            return new CMMT_OBJECTS_TYPE();
        }
    }

    // Factory to create an object for the above class
    [OracleCustomTypeMappingAttribute("PENTACMS.CMMT_OBJECTS_TYPE")]
    public class CMMT_OBJECTS_TYPEFactory : IOracleCustomTypeFactory {

        public virtual IOracleCustomType CreateObject() {
            CMMT_OBJECTS_TYPE obj = new CMMT_OBJECTS_TYPE();
            return obj;
        }
    }
}

コードを挿入

 private void INSERT_INTO_CMMT_OBJECTS(CMMT_FIX_MASTER_TYPE fixMaster, DateTime dt)
{
    CMMT_OBJECTS_COL cmmt_obj_col = new CMMT_OBJECTS_COL();
    CMMT_OBJECTS_COLFactory objList = new CMMT_OBJECTS_COLFactory();
    CMMT_OBJECTS_TYPE[] objColl = (CMMT_OBJECTS_TYPE[])objList.CreateArray(DGV_OBJ_LIST.Rows.Count);

    for (int i = 0; i < DGV_OBJ_LIST.Rows.Count; i++)
    {
        TextBox TextBoxN_ORDER = (TextBox)DGV_OBJ_LIST.Rows[i].Cells[1].FindControl("N_ORDER");
        TextBox TextBoxV_OBJECT_NAME = (TextBox)DGV_OBJ_LIST.Rows[i].Cells[2].FindControl("V_OBJECT_NAME");
        DropDownList DrpV_TYPE = (DropDownList)DGV_OBJ_LIST.Rows[i].Cells[3].FindControl("V_TYPE");
        DropDownList DrpV_LOCATION = (DropDownList)DGV_OBJ_LIST.Rows[i].Cells[4].FindControl("V_LOCATION");
        DropDownList DrpV_OBJECT_CLASSIFICATION = (DropDownList)DGV_OBJ_LIST.Rows[i].Cells[5].FindControl("V_OBJECT_CLASSIFICATION");
        DropDownList DrpV_OBJECT_REGION = (DropDownList)DGV_OBJ_LIST.Rows[i].Cells[6].FindControl("V_OBJECT_REGION");
        TextBox TextBoxV_REMARKS = (TextBox)DGV_OBJ_LIST.Rows[i].Cells[7].FindControl("V_REMARKS");
        TextBox TextBoxN_VERSION = (TextBox)DGV_OBJ_LIST.Rows[i].Cells[8].FindControl("N_VERSION");
        TextBox TextBoxN_VERSION1 = (TextBox)DGV_OBJ_LIST.Rows[i].Cells[9].FindControl("N_VERSION1");
        TextBox TextBoxN_VERSION2 = (TextBox)DGV_OBJ_LIST.Rows[i].Cells[10].FindControl("N_VERSION2");
        TextBox TextBoxN_VERSION3 = (TextBox)DGV_OBJ_LIST.Rows[i].Cells[11].FindControl("N_VERSION3");

        objColl[i] = new CMMT_OBJECTS_TYPE();
        if(TextBoxN_ORDER.Text != "")
            objColl[i].ON_ORDER = Convert.ToInt32(TextBoxN_ORDER.Text);
        objColl[i].OV_OBJECT_NAME = TextBoxV_OBJECT_NAME.Text;
        objColl[i].OV_TYPE = DrpV_TYPE.SelectedValue;
        objColl[i].OV_LASTUPD_USER= smsUser.UserID;
        objColl[i].OV_LASTUPD_PROG = programName;
        objColl[i].OD_LASTUPD = dt;
        objColl[i].OD_LASTUPDIsNull = false;
        objColl[i].OV_LOCATION = DrpV_LOCATION.SelectedValue;
        objColl[i].OV_REMARKS = TextBoxV_REMARKS.Text;
        if(TextBoxN_VERSION.Text != "")
            objColl[i].ON_VERSION = Convert.ToInt32(TextBoxN_VERSION.Text);
        if (TextBoxN_VERSION1.Text != "")
            objColl[i].ON_VERSION1 = Convert.ToInt32(TextBoxN_VERSION1.Text);
        if (TextBoxN_VERSION2.Text != "")
            objColl[i].ON_VERSION2 = Convert.ToInt32(TextBoxN_VERSION2.Text);
        objColl[i].ON_VERSION3 = TextBoxN_VERSION3.Text;
        objColl[i].OV_OBJECT_CLASSIFICATION = DrpV_OBJECT_CLASSIFICATION.SelectedValue;
        objColl[i].OV_OBJECT_REGION = DrpV_OBJECT_REGION.SelectedValue;
    }
    cmmt_obj_col.Value = objColl;
    fixMaster.OC_CMMT_OBJECTS_COL = cmmt_obj_col;
}
4

1 に答える 1

-1

パラメータを実行した後、答えを見つけました

cmd.ExecuteNonQuery();

VS の odp.net によって生成された型クラスから ToCustomObject 関数が発生し、すべてのデータと数値に対してその関数で、数値またはデータパラメーターと同じ名前のパラメーターが bool 型として含まれています。この変数は列名で始まり、IsNull で終わります

OD_SUBMITTEDIsNull

DATA または Number 変数の値を設定した後、このパラメーターを true に設定する必要があります。

それで全部です :)

OD_SUBMITTEDIsNull = true;

于 2013-06-18T09:12:12.377 に答える