?
Solved

Data transfer from SQL Server to Oracle database

Posted on 2010-09-09
4
Medium Priority
?
531 Views
Last Modified: 2012-05-10
Hi,
Can someone provide me with the advice\or post url what is the best way to transfer data
from SQL Server to Oracle database using VB.NET.
I have instaled Oracle Client 11.x which supports OracleBulkCopy but for some reason I face with the problem when i try to write data to server . The error is as follows:
"ORA-01738 missing IN keyword".
It breaks in line "copy.WriteToServer(dt)".
Now, since I could not resolve my problem I am trying to workarround the same and find different solution if possibe (even solution for the current problem where OracleBulkCopy is used would be great )
By the way I have two same tables I try to move date both on SQL Server and Oracle side.
Thank you...


(see vb code below)
Public Sub Retrieve_Records()
        Dim conn1 As New SqlConnection(My.Settings.MyCon)
        conn1.Open()

        Dim cmd1 As New System.Data.SqlClient.SqlCommand()
        cmd1.Connection = conn1
        cmd1.CommandType = CommandType.Text
        cmd1.CommandText = "select partija, sektor, saldo from IFRS_partije"
        cmd1.Parameters.Add("@datum_val", SqlDbType.NVarChar)
        cmd1.Parameters("@datum_val").Value = Me.DateTimePicker1.Value.ToString("yyyy.mm.dd")
        cmd1.CommandTimeout = 0
        Dim rdr As SqlDataReader = cmd1.ExecuteReader
        Dim dt As New DataTable("IFRS_partije")
        dt.Load(rdr)
        rdr.Close()
        conn1.Close()

        Using cn As New OracleConnection(connectStr)
            cn.Open()
            Dim cmd As New OracleCommand
            cmd.Connection = cn
            cmd.CommandType = CommandType.Text
            cmd.CommandText = "DELETE FROM POMOCNA_IFRS_NOVA"
            cmd.ExecuteNonQuery()

            Using copy As New OracleBulkCopy(connectStr)
                copy.DestinationTableName = "POMOCNA_IFRS_NOVA"
                copy.WriteToServer(dt)
            End Using
        End Using
        MessageBox.Show("Successfully inserted on Oracle!", "Status", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1)
    End Sub

Open in new window

0
Comment
Question by:alsam
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 33643171
When moving data between two different data sources, I prefer to use SSIS to do that job.  If you don't understand SSIS, there would be a learning curve involved.  That syntax error doesn't make an sense.  
0
 
LVL 1

Author Comment

by:alsam
ID: 33644281
thank you for your reply...
I have no exiprience with SSIS but definitelly I will go in deep after I searched the web about this topic.
Can I ask you what did you mean by telling that syntax error does not make any sense?
Do you see any "unlogic" in my vb code....For some reason I can not find out why this error message is returned....Have you ever before move data from SQL Server to Oracle using bulkcopy ... do you have any useful advice for me how maybe to solve the problem....
Anyway Thank you for your time and effort
0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 1500 total points
ID: 33646613
The "IN" keyword is usually for something like this:

SELECT * FROM Production.Product WHERE ProductID IN (1, 2, 3, 4)

I don't see how that relates to the work that the OracleBulkCopy would need to do.
0
 
LVL 1

Author Closing Comment

by:alsam
ID: 33700065
Ok,
I have make this working prefectly.... I had problem with grants in oracle db....
Thank you
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question