oracle11g - Array Binding with Oracle(11g) Db and c# -


i'm currentlty working on application need insert few thousands lines @ same time in oracle (11g) base(using odp.net). ("bulk insert style")

that's why trying use array binding technique oracle data base using odp.net.

here code : no error while running it, nothing happens either runs ever.

if has idea of problem come please tell me.

thanks help.

 private static void adddatatabletodatabase(datatable tablelog)     {         string[] type = new string[tablelog.rows.count];         datetime[] timestamp = new datetime[tablelog.rows.count];         string[] source = new string[tablelog.rows.count];         string[] appname = new string[tablelog.rows.count];         string[] action = new string[tablelog.rows.count];         string[] filetype = new string[tablelog.rows.count];         string[] usr = new string[tablelog.rows.count];         int?[] executiontime = new int?[tablelog.rows.count];         string[] addmetadata = new string[tablelog.rows.count];         string[] explanation = new string[tablelog.rows.count];           (int = 0; < tablelog.rows.count; i++)         {             type[i] = tablelog.rows[i][0].tostring();             timestamp[i] = (datetime)tablelog.rows[i][1];             source[i] = tablelog.rows[i][2].tostring();             appname[i] = tablelog.rows[i][3].tostring();             action[i] = tablelog.rows[i][4].tostring();             filetype[i] = tablelog.rows[i][5].tostring();             usr[i] = tablelog.rows[i][6].tostring();             int executiontimevalue;              if (int.tryparse(tablelog.rows[i][7].tostring(), out executiontimevalue))                  executiontime[i] = executiontimevalue;              addmetadata[i] = tablelog.rows[i][8].tostring();             explanation[i] = tablelog.rows[i][9].tostring();         }         string oracleconnectionstring = configurationmanager.connectionstrings["dmsconnection"].connectionstring;         (oracleconnectionstring);         oracle.dataaccess.client.oracleconnection conn = new oracle.dataaccess.client.oracleconnection(oracleconnectionstring);         conn.open();                     oracle.dataaccess.client.oraclecommand cmd = conn.createcommand();         cmd.commandtext = "insert log (type,timestamp,source,appname,action,filetype,usr,executiontime,addmetadata,explanation) values (:type, :timestamp, :source, :appname, :action, :filetype, :usr, :executiontime, :addmetadata, :explanation)";          oracle.dataaccess.client.oracleparameter type = new oracle.dataaccess.client.oracleparameter("type", oracle.dataaccess.client.oracledbtype.nvarchar2, 150, "type");         oracle.dataaccess.client.oracleparameter timestamp = new oracle.dataaccess.client.oracleparameter("timestamp", oracle.dataaccess.client.oracledbtype.date);         oracle.dataaccess.client.oracleparameter source = new oracle.dataaccess.client.oracleparameter("source", oracle.dataaccess.client.oracledbtype.nvarchar2, 150);         oracle.dataaccess.client.oracleparameter appname = new oracle.dataaccess.client.oracleparameter("appname", oracle.dataaccess.client.oracledbtype.nvarchar2, 150);         oracle.dataaccess.client.oracleparameter action = new oracle.dataaccess.client.oracleparameter("action", oracle.dataaccess.client.oracledbtype.nvarchar2, 150);         oracle.dataaccess.client.oracleparameter filetype = new oracle.dataaccess.client.oracleparameter("filetype", oracle.dataaccess.client.oracledbtype.nvarchar2, 150);         oracle.dataaccess.client.oracleparameter usr = new oracle.dataaccess.client.oracleparameter("usr", oracle.dataaccess.client.oracledbtype.nvarchar2, 150);         oracle.dataaccess.client.oracleparameter executiontime = new oracle.dataaccess.client.oracleparameter("executiontime", oracle.dataaccess.client.oracledbtype.int32);         oracle.dataaccess.client.oracleparameter addmetadata = new oracle.dataaccess.client.oracleparameter("addmetadata", oracle.dataaccess.client.oracledbtype.clob);         oracle.dataaccess.client.oracleparameter explanation = new oracle.dataaccess.client.oracleparameter("explanation", oracle.dataaccess.client.oracledbtype.clob);          type.direction = parameterdirection.input;         timestamp.direction = parameterdirection.input;         source.direction = parameterdirection.input;         appname.direction = parameterdirection.input;         action.direction = parameterdirection.input;         filetype.direction = parameterdirection.input;         usr.direction = parameterdirection.input;         executiontime.direction = parameterdirection.input;         addmetadata.direction = parameterdirection.input;         explanation.direction = parameterdirection.input;          cmd.parameters.add(type);         cmd.parameters.add(timestamp);         cmd.parameters.add(source);         cmd.parameters.add(appname);         cmd.parameters.add(action);         cmd.parameters.add(filetype);         cmd.parameters.add(usr);         cmd.parameters.add(executiontime);         cmd.parameters.add(addmetadata);         cmd.parameters.add(explanation);          cmd.parameters["type"].value = type;         cmd.parameters["timestamp"].value = timestamp;         cmd.parameters["source"].value = source;         cmd.parameters["appname"].value = appname;         cmd.parameters["action"].value = action;         cmd.parameters["filetype"].value = filetype;         cmd.parameters["usr"].value = usr;         cmd.parameters["executiontime"].value = executiontime;         cmd.parameters["addmetadata"].value = addmetadata;         cmd.parameters["explanation"].value = explanation;          cmd.executenonquery();         cmd.dispose();         conn.close();    } 

i found solution problem.

the code above works fine, problem use clob oracle data type. internal conversion string clob takes lot of time.

i ended truncating strings long , works fine , fast. (just few seconds insert 4000 records).


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -