Batch Insert Using Oracle
I am having a performance issue with network traffic. Can anyone tell me how to if possible to make batch inserts to a Oracle Database.
Thanks
Absolutely, It's called batching.
There is a code sample in
ORACLE_HOME/jdbc/demo/samples/oci8/basic-samples/SetExecuteBatch.java
The feature is not specific to the OCI driver, it works with the KPRB driver within JServer.
Matthieu
Similar Messages
-
Hi,
We are currently having problems saving data using Weblogic 6.1 sp1 and Oracle
8.1.6. we are using Weblogic JDBC Drivers for Oracle. The data we are saving is to
the extent of 25-50,00 records. When we are trying to this we are getting transaction
timeout errors since this saver process is taking more than 30 seconds which is out
rimeout limit.
Can we do this using Batch updates?? Any code snippets or pointers will be grealty
appreciated.
Thank YOu,
SanjeevCan you be more specific?
- What do you want to do exactly?
- What are your OS and Reports versions?
At first, it sounds a bit strange to use Reports for batch updates. A pl/sql procedure may be more suitable.
You can schedule a report in several ways, e.g. via CRON on Unix (see RWRUN command in the 9iDS Help)).
You can do the same via the database using the SRW package (see http://download-west.oracle.com/docs/html/A92102_01/pbr_evnt.htm#1005558 )
You can use the Reports Queue Manager. -
Batch insert from object variable
Any way to do this excluding the foreach loop container? I have millions of rows and if it goes through them 1 by 1 it will take hours maybe days. How can you do a batch insert from an object variable without putting the sql task inside
a foreach loop container?
thanks,
Mike
MikeI know how to use the dataflow task but it will not work with what I am trying to do as far as I know. The script I am running is against a netezza box that creates temp tables and then returns a data set that I store in an object variable.
I then want to take the data from that object variable and batch insert it into a table. The only way I can see this being done is by looping through the record set in a foreach loop while mapping the fields to variables and inserting records one
at a time like I am doing in the screenshot above. This takes way to long to do. I am trying to figure out a way to do a batch insert using the data in this object variable. Is this possible? I am using SSIS Version
10.50.1600.1
thanks,
Mike
Hi Mike,
Provide more details why you cannot use the data flow task for the processing.
Let me repeat . Loading millions of records in object variable will not work.
SSIS Tasks Components Scripts Services | http://www.cozyroc.com/ -
I am new to using Oracle, and I am trying to create an add/insert stored pr
I am new to using Oracle, and I am trying to create an add/insert stored procedure for a table. The PROD_CD and PLAN_CD fields in my table can have no value (empty or null) Can you please check my code and let me know what I am doing wrong?
Table definition:
CREATE TABLE DCWEB.USER_PLAN_PREFERENCE
USERID VARCHAR2(40) NOT NULL,
PROD_CD VARCHAR2(9) NULL,
PLAN_CD VARCHAR2(9) NULL,
STATE_LST VARCHAR2(2) NOT NULL,
STATE_NM VARCHAR2(40) NOT NULL,
LST_UPDATE_TS TIMESTAMP(6) DEFAULT CURRENT_TIMESTAMP NOT NULL
ALTER TABLE DCWEB.USER_PLAN_PREFERENCE
ADD CONSTRAINT USER_PLAN_PREFERENCE_XPK PRIMARY KEY (USERID, PROD_CD, PLAN_CD);
-- Grant/Revoke object privileges
grant select, insert, update, delete on DCWEB.USER_PLAN_PREFERENCE to HIGGIB1;
Stored Procedure Definition:
procedure setUserPlanPref (
userid in varchar2,
prod_cd in varchar2,
plan_cd in varchar2,
state_lst in varchar2,
state_nm in varchar2
is
currentTimestamp timestamp := current_timestamp;
begin
insert into user_plan_preference (userid, prod_cd, plan_cd, state_lst, state_nm, lst_update_ts)
values (upper(userid), upper(prod_cd), upper(plan_cd), upper(state_lst), upper(state_nm), currentTimestamp);
commit;
exception
when dup_val_on_index then
begin
update user_plan_preference up set
up.userid = upper(userid),
up.prod_cd = upper(prod_cd),
up.plan_cd = upper(plan_cd),
up.state_lst = upper(state_lst),
up.state_nm = upper(state_nm),
up.lst_update_ts = currentTimestamp
where up.userid = upper(userid)
and up.prod_cd = upper(prod_cd)
and up.plan_cd = upper(plan_cd);
commit;
exception
when others then
rollback;
end;
when others then
rollback;
end;
end;
INPUT DATA
I am unable to insert a record calling the stored procedure with values: DCWEB4578, , 2P, CA, CALIFORNIA but when I change to the string "NULL", the insert succeeds. When I try to call the stored procedure to update the inserted record with values: DCWEB4578, "NULL", 2P, CO, COLORODO the update does not happen since I still see the original record in the table. Please advise. Thanks in advance for your help.938319 wrote:
I am new to using OracleWelcome to the forum: please read the FAQ and forum sticky threads (if you haven't done so already), and ensure you've updated your profile with a real handle instead of "938319".
You'll get a faster, more effective response to your questions by including as much relevant information as possible upfront. This should include:
<li>Full APEX version
<li>Full DB/version/edition/host OS
<li>Web server architecture (EPG, OHS or APEX listener/host OS)
<li>Browser(s) and version(s) used
<li>Theme
<li>Template(s)
<li>Region/item type(s)
With APEX we're fortunate to have a great resource in apex.oracle.com where we can reproduce and share problems. Reproducing things there is the best way to troubleshoot most issues, especially those relating to layout and visual formatting. If you expect a detailed answer then it's appropriate for you to take on a significant part of the effort by getting as far as possible with an example of the problem on apex.oracle.com before asking for assistance with specific issues, which we can then see at first hand.
Thanks for posting the complete code, it makes it so much easier to understand the problem, but always post code wrapped in tags<tt>\...\</tt> tags to preserve formatting and special characters.
and I am trying to create an add/insert stored procedure for a table.Does this have anything to do with APEX, for which this is the forum? General SQL & PL/SQL matters should be directed to the {forum:id=75} forum.
The PROD_CD and PLAN_CD fields in my table can have no value (empty or null) Can you please check my code and let me know what I am doing wrong?This:
commit;
exception
when others then
rollback;
end;
when others then
rollback;Remove it all.
Commits should be issued by end user/client software on completion of a transaction. This means <tt>commit;</tt> should almost never appear in PL/SQL code. The main exception to this is in <tt>dbms_job/secheduler</tt> scheduled processes that have no client or UI. If this code is executed from APEX, then APEX issues more than enough commits anyway.
exceptions are just a way of ensuring your code is buggy.<tt>when others</tt> exceptions are just a way of ensuring your code is buggy.
INPUT DATA
I am unable to insert a record calling the stored procedure with values: DCWEB4578, , 2P, CA, CALIFORNIA but when I change to the string "NULL", the insert succeeds. When I try to call the stored procedure to update the inserted record with values: DCWEB4578, "NULL", 2P, CO, COLORODO the update does not happen since I still see the original record in the table. Please advise. Thanks in advance for your help.With the <tt>commit</tt>s and <tt>when others...</tt> removed from the code you'll have a chance of seeing what's actually happening. Note that the entire procedure can be simplified by writing as a MERGE</tt> statement. -
Can select, but cannot insert into oracle tables using php.
I am having trouble inserting data into a tables in oracle using PHP. I can insert into the tables using baninst1, but nothing else. I can't even insert using the tables' owner. Every time I try I get the ORA-00492 error of table or view does not exist. However, I can run a select statement just fine. So far, baninst1 is the only user that can actually do inserts. I've triple checked all the table grants and everything is fine. Also, I can copy/paste the exact insert statement into SQL*Plus and it works with the correct user. It doesn't have to be baninst1. I've tried everything I can think of. I've tried putting the table name in quotes, adding the schema name to the table, checking public synonyms, but everything appears to be ok. I would greatly appreciate any suggestions others may have.
I'm using PHP 5.2.3 with an oracle 9i DB.Here is the code that doesn't work. It works only with baninst1, no other username will work and all I do is change the my_username/my_password to something different. This is one example function where I try to do an insert, but it doesn't work on any of the tables I try.
Thanks for looking.
class Oracle {
private $oracleUser = "my_username";
private $oraclePassword = "my_password";
private $oracleDB = "MY_DB";
private $c = null;
function Connect() {
if ( !($this->c = ocilogon( $this->oracleUser, $this->oraclePassword, $this->oracleDB ) ) )
return false;
return true;
function AddNewTest($testName, $course, $section, $term, $maxAttempts, $length, $startDate, $startTime, $endDate, $endTime)
$result = "";
if( $this->c == null )
$this->Connect();
$splitIndex = strpos($course, " ");
$subjectCode = substr($course, 0, $splitIndex);
$courseNumber = substr($course, $splitIndex + 1);
$insertStatment = "insert into szbtestinfo(szbtestinfo_test_name,
szbtestinfo_course_numb,
szbtestinfo_section,
szbtestinfo_max_attempts,
szbtestinfo_length_minutes,
szbtestinfo_start,
szbtestinfo_end,
szbtestinfo_id,
szbtestinfo_subj_code,
szbtestinfo_eff_term)
values( '" . $testName .
"', '" . $courseNumber .
"', '" . $section .
"', " . $maxAttempts .
", " . $length .
", to_date('" . $startDate . " " . $startTime . "', 'MM/DD/YYYY HH24:MI')" .
", to_date('" . $endDate . " " . $endTime . "', 'MM/DD/YYYY HH24:MI')" .
", szsnexttest.nextval" .
", '" . $subjectCode .
"', '" . $term . "')";
//return $insertStatment;
$s = OCIParse($this->c, $insertStatment);
try
$result = OCIExecute($s);
catch(exception $e)
return $result;
} -
What is the best way of insertion using structured or binary type in oracle
what is the best way of insertion using structured or binary type in oracle xml db 11g database
SQL*Loader.
-
Insert into oracle DB using vb2005
I have a form that has click button1. The problem with this code is after insert command something should be inserted into oracle DB but nothing there(so how to execute insert command and commit it using VB2005), any suggestion should refer to the code.
Imports System
Imports System.Data ' VB.NET
Imports Oracle.DataAccess.Client ' ODP.NET Oracle data provider
Imports Excel = Microsoft.Office.Interop.Excel
Public Class Form1
'System.Data.OracleClient lets you access Oracle databases.
Public con As System.Data.OracleClient.OracleConnection = New System.Data.OracleClient.OracleConnection() 'Oracle.DataAccess.Client.OracleConnection()
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim xlApp As Excel.Application
Dim xlWorkBook As Excel.Workbook
Dim xlWorkSheet As Excel.Worksheet
Dim range As Excel.Range
Dim rCnt As Integer
Dim cCnt As Integer
Dim Obj As Object
xlApp = New Excel.ApplicationClass
xlApp.Visible = True
xlWorkBook = xlApp.Workbooks.Open("c:\employee.xls")
xlWorkSheet = xlWorkBook.Worksheets("sheet1")
range = xlWorkSheet.UsedRange
For rCnt = 2 To range.Rows.Count
For cCnt = 1 To range.Columns.Count
Obj = CType(range.Cells(rCnt, cCnt), Excel.Range)
'MsgBox(Obj.value)
Next
Next
xlWorkBook.Close()
xlApp.Quit()
releaseObject(xlApp)
releaseObject(xlWorkBook)
releaseObject(xlWorkSheet)
End Sub
Private Sub releaseObject(ByVal obj As Object)
Try
System.Runtime.InteropServices.Marshal.ReleaseComObject(obj)
obj = Nothing
Catch ex As Exception
obj = Nothing
Finally
GC.Collect()
End Try
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim daOracle As New OracleDataAdapter
Dim InsertCommand As New OracleCommand
daOracle.InsertCommand = New OracleCommand
'1.Create connection object to Oracle database
Dim con As OracleConnection = New OracleConnection()
Try
'2.Specify connection string
con.ConnectionString = ("Data Source=mgra;User Id=tmar; Password=grams")
'3. Open the connection through ODP.NET
con.Open()
Catch ex As Exception
'4.display if any error occurs
MsgBox(ex.Message, Microsoft.VisualBasic.MsgBoxStyle.Exclamation, "OraScan")
'3.Create command object to perform a query against the database:
Dim cmdQuery As String = "SELECT * FROM employee"
InsertCommand.CommandText = "insert into meta_objecttypes values(4,'table','table','ERStudio','Demo')"
daOracle.InsertCommand = InsertCommand
' Create the OracleCommand object to work with select
Dim cmd As OracleCommand = New OracleCommand(cmdQuery)
cmd.Connection = con
cmd.CommandType = CommandType.Text
'get the DataReader object from command object
Dim rdr As OracleDataReader = cmd.ExecuteReader(CommandBehavior.CloseConnection)
cmd.ExecuteNonQuery()
'check if it has any row
While rdr.Read()
rdr.Close()
End While
Finally
' Close and Dispose OracleConnection object
con.Close()
con.Dispose()
End Try
End Sub
End ClassFor best results, please repost this to the ODP.NET forum.
-
BLOB insertion in Oracle 10g database using ojdbc14 (10g drivers)
Hello!
I have a situation where I am trying to insert a blob data into oracle 10g database using oracle thin
10g drivers, <b>ojdbc14.jar</b> in <b>weblogic 8.1 sp2</b>. I have the following error happening very intermittently.
<u><b>java.sql.SQLException: OALL8 is in an inconsistent state.</b></u>
And this is leading to the <u><b>"No more data to read from socket"</b></u> error when I am trying to
insert the BLOB into the database. I have gone through the bug list of SP2 and have realised there is the
following issue fixed in SP3.
<b>CR124933</b>
<b>An Oracle BLOB sometimes used a pooled connection after the connection pool determined that
the connection was available for reassignment.
Code was added to ensure the BLOB is completely processed before closing the pool connection or
ending the transaction.</b>
I believe the problem arises when we try to insert BLOB into database using a refreshed connection
from the pool.We have upgraded weblogic 8.1 from SP2 to SP4 service pack inorder to come over the above problem.
But this still continues to behave intermittently.
We put ojdbc14.jar in our classpath and Weblogic startup classpath looks like the following :-
WLS_CLASSPATH=${WLS_DOMAIN_DIR}/appslib/server.jar:$PRE_CLASSPATH:${WLS_WEBLOGIC_HOME}/server/lib/weblogic.jar:
${WLS_WEBLOGIC_HOME}/server/lib/ojdbc14.jar:${WLS_WEBLOGIC_HOME}/server/lib:${WLS_JAVA_HOME}/lib/tools.jar:
${WLS_JAVA_HOME}/jre/lib/rt.jar:${WLS_WEBLOGIC_HOME}/server/lib/webservices.jar:${WLS_CONFIG_DIR}:
${WLS_CUSTLIB_DIR}:${WLS_BIN_DIR}:$POST_CLASSPATH
export WLS_CLASSPATH
CLASSPATH=${WLS_CLASSPATH}:${APP_CLASSPATH}
export CLASSPATH
After upgrade to SP4, there are new ojdbc14_g.jar(debug jar) and orai18n.jar jars in the ${WLS_WEBLOGIC_HOME}/server/ext/jdbc/oracle/10g directory added.
Please let me know if I need to update classpath with the new 10g jars in the ext/lib directory or any suggestions
to insert BLOB using the ojdbc14 10G drivers, Weblogic 8.1 environment would be appreciated.
Following is the stack trace of the errors that I recieve:
<Oct 6, 2005 1:29:36 PM EDT> <Error> <JDBC> <BEA-001112> <Test "select count(*) from DUAL" set up for pool
"MHUBPoolStage" failed with exception: "java.sql.SQLException: OALL8 is in an inconsistent state".>
<Oct 6, 2005 1:29:36 PM EDT> <Info> <JDBC> <BEA-001128> <Connection for pool "MHUBPoolStage" closed.>
<Oct 6, 2005 1:29:36 PM EDT> <Info> <JDBC> <BEA-001067> <Connection for pool "MHUBPoolStage" refreshed.>
<Oct 6, 2005 1:29:36 PM EDT> <Info> <EJB> <BEA-010051>
java.rmi.RemoteException: TransactionRequestManager.requestTransaction():
Caught PersistnceException com.mortgagehub.busobj.PersistenceException: -5258: No more data to read from socket
Please let me know if there is anything that I am missing.
Thanks
Pradeep Gpradeep g wrote:
Hello!
I have a situation where I am trying to insert a blob data into oracle 10g database using oracle thin
10g drivers, <b>ojdbc14.jar</b> in <b>weblogic 8.1 sp2</b>. I have the following error happening very intermittently.
> <u><b>java.sql.SQLException: OALL8 is in an inconsistent state.</b></u>
And this is leading to the <u><b>"No more data to read from socket"</b></u> error when I am trying to
insert the BLOB into the database. I have gone through the bug list of SP2 and have realised there is the
following issue fixed in SP3.
> <b>CR124933</b>
<b>An Oracle BLOB sometimes used a pooled connection after the connection pool determined that
the connection was available for reassignment.
Code was added to ensure the BLOB is completely processed before closing the pool connection or
ending the transaction.</b>
> I believe the problem arises when we try to insert BLOB into database using a refreshed connection
from the pool.We have upgraded weblogic 8.1 from SP2 to SP4 service pack inorder to come over the above problem.
But this still continues to behave intermittently.
We put ojdbc14.jar in our classpath and Weblogic startup classpath looks like the following :-
> WLS_CLASSPATH=${WLS_DOMAIN_DIR}/appslib/server.jar:$PRE_CLASSPATH:${WLS_WEBLOGIC_HOME}/server/lib/weblogic.jar:
${WLS_WEBLOGIC_HOME}/server/lib/ojdbc14.jar:${WLS_WEBLOGIC_HOME}/server/lib:${WLS_JAVA_HOME}/lib/tools.jar:
${WLS_JAVA_HOME}/jre/lib/rt.jar:${WLS_WEBLOGIC_HOME}/server/lib/webservices.jar:${WLS_CONFIG_DIR}:
${WLS_CUSTLIB_DIR}:${WLS_BIN_DIR}:$POST_CLASSPATH
export WLS_CLASSPATH
CLASSPATH=${WLS_CLASSPATH}:${APP_CLASSPATH}
export CLASSPATH
> After upgrade to SP4, there are new ojdbc14_g.jar(debug jar) and orai18n.jar jars in the ${WLS_WEBLOGIC_HOME}/server/ext/jdbc/oracle/10g directory added.
> Please let me know if I need to update classpath with the new 10g jars in the ext/lib directory or any suggestions
to insert BLOB using the ojdbc14 10G drivers, Weblogic 8.1 environment would be appreciated.
> Following is the stack trace of the errors that I recieve:
> <Oct 6, 2005 1:29:36 PM EDT> <Error> <JDBC> <BEA-001112> <Test "select count(*) from DUAL" set up for pool
"MHUBPoolStage" failed with exception: "java.sql.SQLException: OALL8 is in an inconsistent state".>
<Oct 6, 2005 1:29:36 PM EDT> <Info> <JDBC> <BEA-001128> <Connection for pool "MHUBPoolStage" closed.>
<Oct 6, 2005 1:29:36 PM EDT> <Info> <JDBC> <BEA-001067> <Connection for pool "MHUBPoolStage" refreshed.>
<Oct 6, 2005 1:29:36 PM EDT> <Info> <EJB> <BEA-010051>
java.rmi.RemoteException: TransactionRequestManager.requestTransaction():
Caught PersistnceException com.mortgagehub.busobj.PersistenceException: -5258: No more data to read from socket
Please let me know if there is anything that I am missing.
> Thanks
> Pradeep GHi. This is something we'd like to diagnose. How is your application
getting using and closing pool connections? The initial symptom
seems to be an internal oracle problem... Are you using standard
JDBC or oracle-specific calls?
Joe -
Insert into Oracle Database using C#
Hi Everyone,
I am trying to take data from text box and list box and then insert them to Oracle database:
Text box data:
Oracle = EMPLOYEE_NAME
C# = tbEmployeeName
List box data:
Oracle = EMPLOYEE_GENDER
C# = lbEmployeeGender
Here is my code in C#, can you guys help me with insert statement:
string oradb = "Data Source= oraDB;User Id=sm;Password=mypassword;";
OracleConnection conn = new OracleConnection(oradb);
conn.Open();
OracleCommand cmd = new OracleCommand();
cmd.Connection = conn;
cmd.CommandText = "Insert into USER.EMPLOYEE VALUES (tbEmployeeName.Text, lbEmployeeGender.Text)";
int rowsUpdated = cmd.ExecuteNonQuery();
if (rowsUpdated == 0)
MessageBox.Show("Record not inserted");
else
MessageBox.Show("Success!");
conn.Dispose();
Thanks!989630 wrote:
Hi Everyone,
I am trying to take data from text box and list box and then insert them to Oracle database:
Text box data:
Oracle = EMPLOYEE_NAME
C# = tbEmployeeName
List box data:
Oracle = EMPLOYEE_GENDER
C# = lbEmployeeGender
Here is my code in C#, can you guys help me with insert statement:
string oradb = "Data Source= oraDB;User Id=sm;Password=mypassword;";
OracleConnection conn = new OracleConnection(oradb);
conn.Open();
OracleCommand cmd = new OracleCommand();
cmd.Connection = conn;
cmd.CommandText = "Insert into USER.EMPLOYEE VALUES (tbEmployeeName.Text, lbEmployeeGender.Text)";
int rowsUpdated = cmd.ExecuteNonQuery();
if (rowsUpdated == 0)
MessageBox.Show("Record not inserted");
else
MessageBox.Show("Success!");
conn.Dispose();
Thanks!Hi,
You'll want to read up on using parameters (also known as bind variables) - these are critical for scalability in an OLTP-type system and helping guard against SQL Injection attacks. There's many sources out there, but here's a link to the Parameter Binding section in the ODP.NET Developer's Guide which is probably a good thing to become familiar with:
http://docs.oracle.com/cd/E11882_01/win.112/e23174/featOraCommand.htm#i1007242
Here's your sample using bind variables:
string oradb = "Data Source= oraDB;User Id=sm;Password=mypassword;";
OracleConnection conn = new OracleConnection(oradb);
conn.Open();
OracleCommand cmd = new OracleCommand();
cmd.Connection = conn;
// Perform insert using parameters (bind variables)
cmd.CommandText = "Insert into USER.EMPLOYEE VALUES (:1, :2)";
// Here's one way to use parameters aka bind variables:
// Create parameters to hold values from front-end
cmd.Parameters.Add(new OracleParameter("1",
OracleDbType.Varchar2,
tbEmployeeName.Text,
ParameterDirection.Input));
cmd.Parameters.Add(new OracleParameter("2",
OracleDbType.Varchar2,
lbEmployeeGender.Text,
ParameterDirection.Input));
int rowsUpdated = cmd.ExecuteNonQuery();
if (rowsUpdated == 0)
MessageBox.Show("Record not inserted");
else
MessageBox.Show("Success!");
conn.Dispose();
// don't forget to perform any clean-up as necessaryNote that I've just typed this into a text editor and not verified, so please excuse any typos you may find.
Also, I've allowed the default of OracleCommand.BindByName=false as I prefer that, though others certainly prefer setting it to "true". See the docs for what this means if you are not sure.
Regards,
Mark -
Bulk insert into oracle using ssis
Hi ,
Can someone please suggest me the way to Bulk insert data into oracle database? I'm using oledb which doesnt support bulk insert into oracle.
Pls note I cant use Oracle ATTUnity as it requires enterprise edition but i have only Standard edition and hence that option is ruled out.
Is there any other way that I can accompolish BULK insert?
Please help me out.
Thanks,
PrabhuHi Prabhu,
I am very late to help you solve the query but following is the solution to 'Bulk Insert into Oracle' that worked for me.
To use below code for SSIS 2008 R2 in a
Script Task component you would need following API references.
Prerequisites:
1. C:\Program Files (x86)\Microsoft SQL Server\100\SDK\Assemblies\Microsoft.SQLServer.DTSRuntimeWrap.dll
2. Install "Oracle Data Provider For .NET 11.2.0.1.0" and add a reference to
Oracle.DataAccess.dll.
Microsoft SQL Server Integration Services Script Task
Write scripts using Microsoft Visual C# 2008.
The ScriptMain is the entry point class of the script.
* Description : SQL to Oracle Bulk Copy/Insert
* Created By : Mitulkumar Brahmbhatt
* Created Date: 08/14/2014
* Modified Date Modified By Description
using System;
using System.Data;
using Microsoft.SqlServer.Dts.Runtime;
using System.Windows.Forms;
using Oracle.DataAccess.Client;
using Microsoft.SqlServer.Dts.Runtime.Wrapper;
using System.Data.OleDb;
namespace ST_6e18a76102dd4312868504c4ef95279d.csproj
[System.AddIn.AddIn("ScriptMain", Version = "1.0", Publisher = "", Description = "")]
public partial class ScriptMain : Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase
#region VSTA generated code
enum ScriptResults
Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success,
Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure
#endregion
public void Main()
ConnectionManager cm;
IDTSConnectionManagerDatabaseParameters100 cmParams;
OleDbConnection oledbConn;
DataSet ds = new DataSet();
string sql;
try
/********** Pull Sql Source Data into a Dataset *************/
cm = Dts.Connections["SRC_CONN"];
cmParams = cm.InnerObject as IDTSConnectionManagerDatabaseParameters100;
oledbConn = (OleDbConnection)cmParams.GetConnectionForSchema() as OleDbConnection;
sql = @"Select * from [sourcetblname]'';
OleDbCommand sqlComm = new OleDbCommand(sql, oledbConn);
OleDbDataAdapter da = new OleDbDataAdapter(sqlComm);
da.Fill(ds);
cm.ReleaseConnection(oledbConn);
/***************** Bulk Insert to Oracle *********************/
cm = Dts.Connections["DEST_CONN"];
cmParams = cm.InnerObject as IDTSConnectionManagerDatabaseParameters100;
string connStr = ((OleDbConnection)cmParams.GetConnectionForSchema() as OleDbConnection).ConnectionString;
cm.ReleaseConnection(oledbConn);
sql = "destinationtblname";
using (OracleBulkCopy bulkCopy = new OracleBulkCopy(connStr.Replace("Provider=OraOLEDB.Oracle.1", "")))
bulkCopy.DestinationTableName = sql;
bulkCopy.BatchSize = 50000;
bulkCopy.BulkCopyTimeout = 20000;
bulkCopy.WriteToServer(ds.Tables[0]);
/***************** Return Result - Success *********************/
Dts.TaskResult = (int)ScriptResults.Success;
catch (Exception x)
Dts.Events.FireError(0, "BulkCopyToOracle", x.Message, String.Empty, 0);
Dts.TaskResult = (int)ScriptResults.Failure;
finally
ds.Dispose();
Mitulkumar Brahmbhatt | Please mark the post(s) that answered your question. -
How to insert data from *.dmp file to oracle 11g using Oracle SQL Develope
hi
i backup my database using PL/SQL developer and made *.dmp file
how to insert data from *.dmp file to oracle 11g using Oracle SQL Developer 2.1.1.64
and how to make *.dmp file from sql*plus ?
thanks in advancePl/Sql developer has a config window, there you choose the exec to do the import/export.
Find it and his home version, it may be exp or expdp, the home version is the version of the client where the exp executable is.
Then use the same version of imp or impdp to execute the import, you do not need to use Oracle SQL Developer 2.1.1.64. If you want to use it, you must have the same version in the oracle home that exp/imp of sql developer use. -
How to run batch file from oracle forms 9i
Hi everyone.
i have a data in csv file. i want to upload it to my database. i am using sql loader for it.
i have made a batch file which run the sql loader and transfer my data to database.
How to run batch file from oracle forms 9i.
when i press the button, nothing uploads in my database. (when i simply run the batch file it works).
here is my code
Begin
HOST('C:\temp\batchfile.bat');
message('done');
end;
Thanks in advance
regards
sajidthis is my log file, when i run manually.
SQL*Loader: Release 10.2.0.1.0 - Production on Thu Jul 1 23:27:53 2010
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Control File: file_to_upload.ctl
There are 2 data files:
Data File: sk.csv
Bad File: sk.bad
Discard File: none specified
(Allow all discards)
Data File: sk1.csv
Bad File: sk1.bad
Discard File: none specified
(Allow all discards)
Number to load: ALL
Number to skip: 0
Errors allowed: 50
Bind array: 64 rows, maximum of 256000 bytes
Continuation: none specified
Path used: Conventional
Table KHAN, loaded from every logical record.
Insert option in effect for this table: APPEND
Column Name Position Len Term Encl Datatype
SR FIRST * , O(") CHARACTER
DATES NEXT * , O(") CHARACTER
AGENT NEXT * , O(") CHARACTER
COUNTRY NEXT * , O(") CHARACTER
TRANSACTIONS NEXT * , O(") CHARACTER
PKR NEXT * , O(") CHARACTER
USD NEXT * , O(") CHARACTER
BANK NEXT * , O(") CHARACTER
Table KHAN:
11088 Rows successfully loaded.
0 Rows not loaded due to data errors.
0 Rows not loaded because all WHEN clauses were failed.
0 Rows not loaded because all fields were null.
Space allocated for bind array: 132096 bytes(64 rows)
Read buffer bytes: 1048576
Total logical records skipped: 0
Total logical records read: 11088
Total logical records rejected: 0
Total logical records discarded: 0
Run began on Thu Jul 01 23:27:53 2010
Run ended on Thu Jul 01 23:27:54 2010
Elapsed time was: 00:00:00.63
CPU time was: 00:00:00.17 -
Hello,
While migrating from Kodo 3.4 to Kodo 4.1, I noticed significant drop in
insert performance. I traced it down to some strange batching behavior.
While most of the PCs were committed with batched inserts one particular
class refused to batch and would insert row by row resulting in 10 times
performance drop.
There is nothing special about the class. Its hierarchy is mapped on base
its table except for one of the lowest members which is mapped vertically.
Thank you very much
Alex Roytman
Peace Technology, Inc.
301-206-9696x103See my post "My experience migrating Kodo 3.4 to 4.1"
"Stefan Hansel" <[email protected]> wrote in message
news:[email protected]..
Abe White wrote:
This case is being handled elsewhere, but for the benefit of others:
Kodo 4 works around a date/timestamp batching bug in some Oracle drivers
by not batching rows with date/timestamp columns.-------------
Abe could you get a bit deeper into it ?
It sounds like kodo 3 was batching that rows and had no problem with it ?
We only ship with the suggested oracle driver 10.2.0.1.0.
50% of our customers use oracle, so it would be a pity if performance
drops.
Alex ... it sounds like you successfully migrated to kodo4.
Could you give a short summery on how 'difficult' it was in the end ?
From the docs it sounds very easy (except the sentence 'Many
confniguration
properties and defaults have changed.') but from the newsgroups it sounds
as if
you'd struggle a bit.
I'm about to schedule our migration for the first quarter of 2007 and any
hint
helping use to estimate the time will help us.
If you compare with migration from kodo 2 to 3 ... is it easier or worse ? -
How to control number of records in batch insert by eclipselink
Hi,
We are using eclipselink(2.2) to persist objects and we use following configuration -
<property name="eclipselink.jdbc.batch-writing" value="Oracle-JDBC" />
<property name="eclipselink.jdbc.batch-writing.size" value="5" />
however the number of records inserted is much more than 5( I have seen 5000 records being inserted ). How can we control the number of records inserted once?
Thanks.Binding can be configured using the "eclipselink.jdbc.bind-parameters" property, and is on by default - it should be on for jdbc batch writing.
Batch writing defaults to 100 statements, so I am not sure why it would include all statements in one batch unless it is not batching at all. If you set the logs to finest or all it should print of the values it is using for each property, and also show the SQL and statments it is executing. Can you turn on logging and post portions of the logs, particularly the part showing the transaction in question (though maybe only 6 lines of consecutive inserts).
Logging is controlled through the "eclipselink.logging.level" properties.
Best Regards,
Chris -
Are batch inserts supported in cx_oracle?
Oracle's JDBC package provides for batch inserting to increase performance. I've used it in writing an ETL tool in Java. I would like to do the same in Python, but I can't find anything that mentions the same batch insert capability in cx_oracle. Any ideas?
Have you tried http://www.oracle.com/technology/pub/articles/prez-python-queries.html?
Look for "Many at Once" section.
Przemek
Maybe you are looking for
-
IPod touch 4th generation will not connect to Uverse internet
When Uverse internet was setup in my home my 64 gb IPOD touch 3rd generation stopped connecting to internet. I've turned my wifi off and on (that doesn't work), I've tried rebooting the IPOD by turning it completely off then turning back on. I've m
-
Invoice not updated for Service and limit items
Hi All, For service and limit we are not able to see the invoice document in the "Related Documents" tab in the Purchase order. For material I am able to find the entry in the tab but the invoice statistics data is not getting updated for service POu
-
How can I transfer my notes from my iphone5 to my iphone6
Just bough a new iphone6 and want to transfer my notes from my old iphone5 over to the new phone. Anyone out there know how to do this?
-
I have had no kernel panics or unexpected shutdowns of my computer. Whenever I start the computer normally and enter my password, I get the following popup: The only problem is, there was no odd shut down nor did I ever shut it down because of a prob
-
How to Create a session in Servlet
will somone show me the code to create a session in servlet? if a session can be created in servlet file, it can be used all the jsp files in a same web ? Thanks!!!