Oracle to SQL and BulkCopy

Hi Guys,
I have a VB.Net application that queries an Oracle database and then uses the sqlbulkcopy to move it to a Sql table. It works fine without column mapping. As soon as I try to map the columns it fails. Basically says that columns do not match.
This works ...
Using cmd As New OracleCommand(dSource.SQLStatement, dSource.OracleConnection)
cmd.CommandTimeout = 60
If cmd.CommandText.Contains("@ERProjectCode") Then cmd.Parameters.AddWithValue("@ERProjectCode", Job.Project)
cmd.Connection.Open()
Using dr As OracleDataReader = cmd.ExecuteReader()
Using s As New SqlBulkCopy(destConn, SqlBulkCopyOptions.Default, bcpTransaction)
s.DestinationTableName = Job.ApplicationDestinationTable
s.WriteToServer(dr)
s.Close()
End Using
End Using
cmd.Connection.Close()
End Using
This Fails ....
Using cmd As New OracleCommand(dSource.SQLStatement, dSource.OracleConnection)
cmd.CommandTimeout = 60
If cmd.CommandText.Contains("@ERProjectCode") Then cmd.Parameters.AddWithValue("@ERProjectCode", Job.Project)
cmd.Connection.Open()
Using dr As OracleDataReader = cmd.ExecuteReader()
Using s As New SqlBulkCopy(destConn, SqlBulkCopyOptions.Default, bcpTransaction)
'*****COLUMNS MAPPING *****
For i As Integer = 0 To dr.FieldCount - 1
s.ColumnMappings.Add(dr.GetName(i), dr.GetName(i))
Next i
s.DestinationTableName = Job.ApplicationDestinationTable
s.WriteToServer(dr)
s.Close()
End Using
End Using
cmd.Connection.Close()
End Using
I have tried casting in the Oracle Query file but nothing seems to work.
I have run out of ideas and welcome any suggestions.
Thank You !!!

Chanchal Wankhade wrote:
Hello,
Please suggest.
=================================
Patience, Grasshopper
You posted this follow-up a mere 85 minutes after your previous post. 
This forum is not a chat line, and it is not paid support. 
No one is responsible for monitoring it and giving a quick response. 
Furthermore, it is a global forum.  The person with the information you seek may very well live 20 time zones away from you and was going to bed just as you posted. He will not even see your post for several more hours. 
Your original post went up in the middle of the night for half the world.
No one with the information you seek is deliberately withholding it until you sound sufficiently desperate.

Similar Messages

  • Oracle Database 11g Administrator or Oracle PL/SQL and Forms Developer?

    Hi,
    I am thinking about doing an Oracle certification course- Oracle Database 11g Administrator or Oracle PL/SQL and Forms Developer.
    Oracle Database 11g OCP and OCM certification requires 3 mandatory training courses to be completed that costs between $1900 and $3250/each. Oracle PL/SQL certication doesn't require any mandatory training course.
    Which one of these would be a good choice? Please advise.
    Thank you,
    Tracy

    Regardless of which path you want to take, in order to get the OCP certification in either the DBA or PL/SQL developer track, you must first obtain the respective OCA certification for that track. I'm assuming that since you are still undecided in which path to take that you haven't started working on either yet. If you look at the pages for the OCA DBA and OCA PL/SQL Developer certs and what is required for each, you'll see that the first block of tests for either certification (the SQL based exams) has the same options (1Z0-007, 1Z0-047, 1Z0-051) and passing one of those SQL based exams gives credit towards obtaining both OCA certifications. That might be a good place to start.
    Doing one of these tests first might give you some extra time to decide which track you want to pursue. But as Justin said, it really depends on what you do (or plan on doing) in your career as to which path might be more beneficial for you.
    As for the OCM level stuff, I wouldn't even think about it until you get the OCP. One step at a time... Same with OCP before OCA. That being said, my suggestions are just that, suggestions. You're free to take any exams/courses in any order, but you won't be able to obtain the certs until you have completed the requirements for each.

  • Oracle 8i SQL and PL/SQL plus

    hi everybody, i am trying from two weeks to install oracle 8i SQL and PL/SQL plus on my PC on both Windows 2000 & XP and I installed every java runtime environment I found "the old and the new" but the SETUP insists on not working though it worked on the instructor's PC smoothly without problems.

    If you are getting any errors, you should tell us. Also, you should let us know what version you are trying to install.
    A very common problem at the moment is with Pentium 4 processors. If you have a Pentium 4, search the forums to find the answer.
    Alison

  • Coneection between Oracle to SQL and SQL to Oracle

    Dear All,
    I have oracle 11g R2 (32 bit) on windows 32 bit.
    I have sql express edition 2008 (32 bit) on windows 32 bit.
    More information about my system is :-
    I have install oracle database and sql database on same machine (there is no client).
    I want to fetch data from oracle to sql and sql to oracel. I have tried Using ODAC 32 bit but with no luck.
    steps i have performed:-
    1) Install odac for windows for oracle 11g R2 version (successful).
    2) Tried to create odbc connection using odbc driver (successful).
    3) Tried to create link server in sql (successful).
    4) Tried to connect to oracle using link server (failed).
    It seems i made some small mistake.
    I request you to please help me if you have perform this activity.
    Thanks,
    Chanchal Wankhade.

    Chanchal Wankhade wrote:
    Hello,
    Please suggest.
    =================================
    Patience, Grasshopper
    You posted this follow-up a mere 85 minutes after your previous post. 
    This forum is not a chat line, and it is not paid support. 
    No one is responsible for monitoring it and giving a quick response. 
    Furthermore, it is a global forum.  The person with the information you seek may very well live 20 time zones away from you and was going to bed just as you posted. He will not even see your post for several more hours. 
    Your original post went up in the middle of the night for half the world.
    No one with the information you seek is deliberately withholding it until you sound sufficiently desperate.

  • Oracle PL/SQL and Microsoft Access..

    Does anyone know of a good tutorial on how to write the correct syntax for Oracle PL/SQL in an Access pass-through query?

    Do you want to write PL/SQL via Access, or just pass a SQL string as a query? There are many books on PL/SQL if that is what you need, however, I suspect it is not.
    Oracle SQL is pretty standard, except that for versions up to and including 8.x, it only accepts joins listed in the "WHERE" clause. Access itself will accept this syntax for inner joins. Most general SQL books seem to include a section on Oracle and T-sql variations.
    SELECT a.field_1, b.field_2
    FROM table_1 a, table_2 b
    WHERE a.field_x = b.field_y ;
    BUT if field_x is a CHAR field containing trailing spaces (CHAR(6) value is 'ABC ') and field_y is a VARCHAR2 field (value is 'ABC'), then the join condition should be:
    WHERE TRIM(a.field_x) = b.field_y ;
    for outer joins you add "(+)" to the field that may be blank
    SELECT a.field_1, b.field_2
    FROM table_1 a, table_2 b
    WHERE a.field_x = b.field_y(+) ;
    (Access) MID([field_1],2,5] becomes (Oracle) SUBSTR(field_1,2,5)
    regards

  • Oracle Pl/Sql and Oracle Application Express for Beginners

    Good day,
    Have a prodigy that is strongly interested in oracle application express.Haven know that he will only do we in APEX if he is good in pl/sql and have some skills in html and javascripts.
    For such person,what are the books that i can recommend for him,that will guide and assist him?Will be highly grateful if anybody can assist.

    Sc0tt wrote:
    I think it also falsely gives the impression that one does not need to understand the database at all because Apex can do everything for you...This is why I echo Munky when he says that you need a solid understanding of data models and the database before attempting to build an application.
    I absolutely concur with this view. When I first started using ApEx, I was basically given a user guide and told to get on with it :-) Subsequently, for the first 6 months or so, I built probably fairly lousy (but functional) apps until I got a better grasp of Oracle architecture.
    That being said, SQL is an absolute must if you are going to work on a database. PL/SQL really should be learned as well because your application will be limited without it. CSS and Javascript and nice to have's, but they can be learned as you go. Since all of the api's are built in pl/sql, it would really hinder what you could do if you didn't know it.One resource I have found very useful is the good old 'Ant' book a.k.a. Oracle PL/SQL Programming by Feuerstein, et al. I have a well-thumbed 4th edition sitting on my desk at the moment - weirdly for a text book, rather a joy to read.
    I personally found Jay-Lew's "Cost-based Oracle Fundamentals" a somewhat bitterer pill to swallow - tough on the way down but good for one's constitution!

  • Help with Oracle PL/SQL and Objects...

    Hi,
    I wonder if you can help me, I am having some trouble dealing with Oracle objects in PL/SQL. I can declare them, populate them and read from them without any issues.
    But I am having some problems with trying to copy records in to other records of the same type, and also with updating existing records. I've made a mock up piece of code below to explain what I mean, it may have a few mistakes as I've written it in notepad but should be reasonably clear.
    First I have created a record type, which contains attributes relating to a person.....
    CREATE OR REPLACE
    TYPE PERSON_RECORD_TYPE AS object (
                        Person_ID          NUMBER(3),
                        Person_Name     VARCHAR(20),
                        Person_Age          NUMBER(2),
                        static function new return PERSON_RECORD_TYPE );
    CREATE OR REPLACE
    TYPE BODY PERSON_RECORD_TYPE as
    static function new return PERSON_RECORD_TYPE is
    BEGIN
    return PERSON_RECORD_TYPE (
         NULL,
                             NULL,
                             NULL,
                             NULL,
                             NULL
    END;
    END;
    Then I have created a table type, which is a table of the person record type......
    CREATE OR REPLACE
    type PERSON_TABLE_TYPE as table of PERSON_RECORD_TYPE;
    Finally I have created a procedure which recieves an instance of the person table type and reads through it using a cursor.....
    PROCEDURE ADMIN_PERSON (incoming_person     IN     PERSON_TABLE_TYPE)
    IS
    -- This is a local record declared as the same type as the incoming object
    local_person PERSON_TABLE_TYPE;
    -- Cursor to select all from the incoming object
    CURSOR select_person
    IS
    SELECT      *
    FROM      TABLE ( cast (incoming_person AS PERSON_TABLE_TYPE));
    BEGIN
    -- Loop to process cursor results
    FOR select_person_rec IN select_person
         LOOP
              /* Up to this point works fine...*/
              -- If I want to store the current cursor record in a local record of the same type, I can do this....
              local_person.person_id          := select_person_rec.person_id;
              local_person.person_name      := select_person_rec.person_name;
              local_person.person_age          := select_person_rec.person_age;
    -- QUESTION 1
              -- The above works fine, but in my real example there are a lot more fields          
              -- Why cant I set the local record to the value of the cursor record like this below..     
              local_person := select_person_rec;
    -- The above line gives a pl/sql error - expression is of wrong type, (as far as I can see the records are of the same type?)
    -- QUESTION 2
              --Also how do you update an existing record within the original object, I have tried the following but it does not work
              UPDATE incoming_person
              SET          age = (age + 1)
              WHERE     incoming_person.person_id = '123';
    -- The error here is that the table does not exist
         END LOOP;
    END;
    So I hope that you can see from this, I have two problems. The first is that I can store the current cursor record in a local record if I assign each attribute one at a time, but my real example has a large number of attributes. So why can't I just assign the entire cursor record to the local cursor record?
    I get a PL/SQL error "Expression is of wrong type" when I try to do this.
    The second question is with regards to the update statement, obviously this doesn't work, it expects a table name here instead. So can anyone show me how I should update existing person records in the incoming table type to the procedure?
    I hope this makes sense, but I don't think I have explained it very well!!
    Any help will be gratefully recieved!!
    Thanks

    I understand why you are having trouble - my own brain started to hurt looking at your questions :)
    First off, database types are not records. They can act like records but are "objects" with different characterstics.
    You can create a record in PL/SQL but the "type" is of RECORD. You created an OBJECT as BODY_PERSON_RECORD_TYPE.
    I don't use database types unless I really need them, such as for working with pipelined functions.
    -- QUESTION 1
    -- The above works fine, but in my real example there are a lot more fields
    -- Why cant I set the local record to the value of the cursor record like this below..
    local_person := select_person_rec; local_person is set to the (misnamed) BODY_PERSON_RECORD_TYPE, while SELECT_PERSON_REC is anchored to the cursor and is a RECORD of SELECT_PERSON%ROWTYPE with a field for each column selected in the query. Different types, not compatible.
    You should be able to manually assign the object items one by one as object.attribute := record.field one field at a time.
    -- QUESTION 2
    --Also how do you update an existing record within the original object, I have tried the following but it does not workCheck the on-line documentation for the syntax. You'll probably have to reference the actual value through the table; this is one reason why I don't work with nested tables - the syntax to do things like updates is much more complex.

  • Reading Text Files using Oracle PL/SQL and UTL_FILE

    Hi, experts. I tried to read a text file into oracle. Here is what i did:
    1. Create a text file in the directory: C:\temp\New Text Document.txt
    2. Run the following SQL in PL/SQL:
    CREATE or replace DIRECTORY sampledata AS 'C:\temp\';
    grant read, write on directory sampledata to public;
    3. When I run the following code, it caused an error: ora-29280: invalid directory path. I have alread checked the directory path, it is correct. Would someone know what wrong is my code?
    declare
    f utl_file.file_type;
    s varchar2(3000);
    begin
    f := utl_file.fopen('sampledata','New Text Document.txt','R');
    utl_file.get_line(f,s);
    utl_file.fclose(f);
    dbms_output.put_line(s);
    end;
    Thank you

    Try with a filename without spaces:No problem with spaces
    SQL> declare
      2  f utl_file.file_type;
      3  s varchar2(3000);
      4  begin
      5  f := utl_file.fopen('SAMPLEDATA','New Text Document.txt','R');
      6  utl_file.get_line(f,s);
      7  utl_file.fclose(f);
      8  dbms_output.put_line(s);
      9  end;
    10  /
    line1
    PL/SQL procedure successfully completed.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • I want to learn more about oracle seibel, hrms, and oracle's financials

    hello everyone;
    i have some experiance in oracle 10g, sql and programming;
    i would like to learn about:
    1) oracle seibel
    2) oracle human resource managment system
    3) oracle financials
    please advice me on a useful documentation that might help,
    and i wanna know if it is possible to download them on my laptop for free?
    thanks alot;

    Hi user;
    i would like to learn about:
    1) oracle seibelSiebel Installation Guide for Microsoft Windows
    http://download.oracle.com/docs/cd/B40099_02/books/PDF/SiebInstWIN.pdf
    Siebel CRM 8.0 Deployment Guide
    http://www.citrix.com/site/resources/dynamic/partnerDocs/CTX_Siebel_ANG_Guide.pdf
    Siebel Business Applications Documentation
    http://www.oracle.com/technology/documentation/siebel.html
    2) oracle human resource managment system
    3) oracle financials All note are avaliable below links, check and read what you need from below links please
    For r12.1.1:
    http://download.oracle.com/docs/cd/B53825_01/current/html/docset.html
    For r12:
    http://download.oracle.com/docs/cd/B40089_10/current/html/docset.html
    For r11:
    http://download.oracle.com/docs/cd/A60725_05/r11_doc.htm
    Regard
    Helios

  • Different Results from SQL-Query in Oracle 10.2 and  Oracle 11.2

    Look at the following example:
    CREATE TABLE GZP_PLAN (GZP_ID
    NUMBER(9) NOT NULL, PARENT_GZP_ID NUMBER(9),
    CONSTRAINT GZP_PLAN_PK1 PRIMARY KEY(GZP_ID)
    USING INDEX
    TABLESPACE USERS
    TABLESPACE USERS;
    insert into GZP_PLAN values(1,NULL);
    CREATE TABLE GZP_WB (OBJECTID NUMBER
    NOT NULL, GZP_ID NUMBER(10),
    CONSTRAINT GZP_WB_PK1_1 PRIMARY KEY(OBJECTID)
    USING INDEX
    TABLESPACE USERS
    TABLESPACE USERS;
    insert into GZP_WB values(1,1);
    CREATE OR REPLACE VIEW VW_GZP (GZP_ID1) AS
    SELECT xxx.gzp_id
    FROM gzp_plan xxx
    WHERE gzp_id IN (
    SELECT MAX (z.gzp_id) zzz
    FROM gzp_plan z
    START WITH z.gzp_id = xxx.gzp_id
    CONNECT BY PRIOR gzp_id = parent_gzp_id);
    -- query
    select a.* from GZP_WB a where gzp_id in (select gzp_id1 from vw_gzp);
    Result in Oracle 10.2. (Windows Server 2003 32-bit, Oracle 10.2.0.2 or Oracle 10.2.0.5, Enterprise Edition)
    OBJECTID     GZP_ID
    *1 1*
    Result in Oracle 11.2 (Windows Server 2008 64-bit, Oralcle 11.2.0.2, Enterprise Edition or Standard Edition One)
    no rows selected
    The result of the following queries are identical in Oracle 10.2 and 11.2
    SQL> select * from GZP_WB where to_char(gzp_id) in
    2 (select to_char(gzp_id1) from vw_gzp);
    OBJECTID GZP_ID
    1 1
    SQL>
    SQL> select a.* from GZP_WB a, vw_gzp b where a.gzp_id=b.gzp_id1;
    OBJECTID GZP_ID
    1 1

    The solution is Oracle 11.2.0.3 - patchset released 11th November.

  • Differences between ANSI SQL and Oracle 8/9

    Hallo,
    i'm looking for good online texts or books concerning the problem "Differences between ANSI SQL and different database implementations (ORACLE, Informix, MySQL...)" I want to check a program written in C (with ESQL) that works with an Informix-DB. In this code i want to find code that is specific to the Informix-DB. I want to change the database, so all the code should be independent from a DB. Does anybody know texts or books concerning this problem?
    thx
    Marco Seum

    Basically there is syntax difference between both of them.
    Lets say i want to join two table EMP and DEPT based on DEPTNO.
    With Oracle SQL format its like this.
    select e.*
      from emp e, dept d
    where e.deptno = d.deptnoHere the joining condition goes in the WHERE clause.
    With ANSI SQL format its like this.
    select e.*
      from emp e
      join dept d
        on e.deptno = d.deptnoHere the join condition is mentioned separately and not in WHERE clause.
    Oracle supports ANSI SQL starting from 9i version.
    You can read more about the syntax difference Here

  • Difference between Oracle 8i SQL Standard and the 9i Lite version

    Hi,
    I was wondering if anybody could inform me of the differences that occur between the full Oracle 8i version and the current Oracle 9i Lite version in respect of the SQL they both use.
    Would the the way temporary tables are created and managed on the lite version be the same as that on the full version?
    Would the SQL syntax also be the same between the two?
    Any feedback on this would be great.
    Thanks
    Stephen

    > 1)Can anyone tell me difference between oracle8i
    sql engine and 9i sql engine.
    They are different versions.
    If you have been expecting a list of differences and enhancements and new product features... forget it. It will take several pages to list. Rather refer to the 9i product feature sheet.
    > 2)Does oracle 9i uses the index defaultly if any
    primary key is there in table
    Huh? Oracle will use an index if it determines that it costs less to use that index to get to the data, than not using an index.

  • Can i run all the SQL And PL/SQL in Oracle SQL Developer?

    hi all
    I have heard that Oracle Sql Developer is a free editor for Oracle DB from Oracle.
    Is it possible to run all the the procedres and functions in that editor
    is there any limitation for that ,can i run all the things that we can run on the SQL Plus
    if anybody knows please let me know
    thanks & regards

    Interesting way of putting it.
    When it comes to SQL and PL/SQL, SQLPlus and SQL Developer do not really 'run' very much.
    Most of the time, these things are just shells that pass the SQL and PL/SQL requests to the appropriate engine (database) which will run the command.
    The challenges are:
    - will the shell interpret the request as something to pass to an engine?
    - will the shell display the response from the engine appropriately?
    For answers to those questions, TongucY provided approriate links.

  • Install Oracle XE, SQL Developer, and Toad on the same machine?

    I have been trying to install Oracle SQL Developer, Toad, and Oracle Express on my work computer. Installing SQL Developer and Toad was pretty straightforward, and I was able to browse the XE database with SQL Developer. But after installing Toad, problems started. Toad was using Oracle XE's registry settings to locate ORACLE_HOME and oci.dll. So I tried changing the settings for Oracle XE in the registry. Toad now works, but not Oracle XE. And while I was going through this all, I even had a time when I had Toad and oracle xe working, but not SQL Developer. It almost looks like you can choose two of the products, but not all three.
    So, my question to the community at large is "Can it be done?". In what directories do you have each product installed? What environment variables do you have set? Where is your tnsnames.ora? What Oracle registry settings do you have set (namely HKLM\SOFTWARE\Wow6432Node\ORACLE\KEY_XE)?
    I can post my current settings, but I've been through so many iterations that these current settings don't really matter that much.
    Here are the details I am looking for
    Path to sqldeveloper.exe
    Path to oracle.exe (for Oracle XE)
    Environment Variables
    ORACLE_HOME
    ORACLE_BASE
    TNS_ADMIN
    PATH (just the oracle stuff)
    Registry Settings
    HKLM\SOFTWARE\Wow6432Node\ORACLE\KEY_XE\ORACLE_HOME
    HKLM\SOFTWARE\Wow6432Node\ORACLE\KEY_XE\ORACLE_BASE
    HKLM\SOFTWARE\Wow6432Node\ORACLE\KEY_XE\TNS_ADMIN
    HKLM\SOFTWARE\Wow6432Node\ORACLE\KEY_XE\OLEDB
    HKLM\SOFTWARE\Wow6432Node\ORACLE\KEY_XE\ORAMTS_CP_TRACE_DIR

    I don't use toad, but there should be no reason why you can't install all 3. SQL Developer is a very clean install and affects nothing else. It doesn't add to the path, or create any registry entries except for file associations.
    A toad installation should pick up your oracle client (in this case the XE code). I am curious as to why you felt you had to change registry settings. What problem were you trying to fix?
    My recommendation would be to uninstall everything, clean the registry and reinstall in the order XE, Toad, SQL Developer. Test in between installations and seek help for problems as you find them. Bear in mind that this is the forum for SQL Developer. QUestions about Oracle XE would be better answered in the dedicated forum, or in the Installation forum, and questions about Toad in a toad forum.

  • Oracle sql and plsql

    Hi..friends...
    am new to this database side..am working on installtion devlopment side.
    i am planing to to change the domain into back end devloper.so i want to start with oracle sql and plsql .so plzz suggest me which book is good for begginers..
    Any IDE's are there to work on back end devloper in the company's...?

    Hi
    You need to search first in the forum before posting into the forum.
    For your Q, no.of answers having in the forum.

Maybe you are looking for