Link to home
Start Free TrialLog in
Avatar of praveen1981
praveen1981Flag for India

asked on

Bulk update from dotnet to oracle

Hi

I have 2000 rows in a csv file with three columns , i want to update these in to oracle database table based on certain condition , i can do this by using looping which is not optimised, can you please suggest me for optimised code or query to update this.
Avatar of santhimurthyd
santhimurthyd
Flag of United States of America image

Construct the Adhoc querry using Stringbuilder and insert the record as single short with Transaction scope

StringBuilder sb = new StringBuilder();
sb.Append("insert into TableName values('" + Val1+"','" + val2 + "','"+ val3 +"')");
sb.Append("insert into TableName values('" + Val1+"','" + val2 + "','"+ val3 +"')");
sb.Append("insert into TableName values('" + Val1+"','" + val2 + "','"+ val3 +"')");

then send the whole record as single to insert
Avatar of slightwv (䄆 Netminder)
slightwv (䄆 Netminder)

>>then send the whole record as single to insert

You cannot chain commands like this in Oracle.

I believe you will need array binding:
http://www.oracle.com/technetwork/issue-archive/2009/09-sep/o59odpnet-085168.html
Avatar of praveen1981

ASKER

Construct the Adhoc querry using Stringbuilder and insert the record as single short with Transaction scope

StringBuilder sb = new StringBuilder();
sb.Append("insert into TableName values('" + Val1+"','" + val2 + "','"+ val3 +"')");
sb.Append("insert into TableName values('" + Val1+"','" + val2 + "','"+ val3 +"')");
sb.Append("insert into TableName values('" + Val1+"','" + val2 + "','"+ val3 +"')");

then send the whole record as single to insert

can you please elobarate these, how can we send this whole to the stored Procedure  from dotnet
To send the input to Storeprocedure construct the string with the SP details as follows

StringBuilder sb = new StringBuilder();
sb.Append("exec <<OracleStoreProcedure>>('" + Val1+"','" + val2 + "','"+ val3 +"')\n");
sb.Append("exec <<OracleStoreProcedure>>('" + Val1+"','" + val2 + "','"+ val3 +"')\n");
sb.Append("exec <<OracleStoreProcedure>>('" + Val1+"','" + val2 + "','"+ val3 +"')\n");

@santhimurthyd

Again,

You cannot chain commands together like this in Oracle and pass the string to a single 'execute' method.

If you are going to keep suggesting this as a viable approach please post a simple working test showing it.
ASKER CERTIFIED SOLUTION
Avatar of slightwv (䄆 Netminder)
slightwv (䄆 Netminder)

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi
This solution is fine, but i have used the xml file as input to the stored procedure to update the bulk data.

Thanks for your solution.