DBlink Data

Hello,
I am having problem in selecting data from dblink.
here is the query
SELECT PRODUCT_CNT FROM SPF_L4_PRODUCT@LinkedDB s WHERE s.REVISION = (SELECT TO_CHAR(SYSDATE-2,'DD-MON-YYYY') FROM DUAL);
this query is returning no records, but if i execute the same query in the linkeddb it gives me output.
even when i run * SELECT PRODUCT_CNT FROM SPF_L4_PRODUCT@LinkedDB * it gives me all records without problem.
but when i use the where clause i get no records.
I am not able to understand what is the problem.
Any help will be highly appreciated.
Thanks
Deepak

OK. Then your query is wrong.
If you have a DATE column, you should always compare it to a DATE value. If you compare a DATE to a VARCHAR2, Oracle has to implicitly cast the date to a string which will use the current session's NLS_DATE_FORMAT as the format mask. Different systems have different NLS_DATE_FORMAT values, different sessions within the same system can have different date formats, and different client machines can have different date formats. Relying on implicit conversion will invariably cause problems where things work on one machine but not another or for one user and not another.
You should get the results you're looking for with the query
SELECT PRODUCT_CNT FROM SPF_L4_PRODUCT@LinkedDB s WHERE trunc(s.REVISION) = trunc(SYSDATE-2)If REVISION is always stored with a time component of midnight, you can eliminate the TRUC on REVISION. If you need the TRUNC, you may want to create a function-based index on TRUNC(s.REVISION) for performance (assuming there are many different values for REVISION).
Justin

Similar Messages

  • Dblink data copy

    Hi,
    I have 3 instances (instance1, instance2, instance3). DB links exists between instance1 and instance2, instance1 and instance3.
    instance1 <-> instance2
    instance1 <-> instance3
    I want to copy data (some records from a table) from instance2 to instance 3.
    What is the best and optimal way to do this data copy. Can I use some stored procedure in instance1?
    Please suggest.

    I am assuming when you say instance1, instance2 & instance3 they are different database instances. I would like to call it db1 db2 & db3
    If you are referring to multiple instances of same DB (RAC) then all the data is accessible across all instances.
    A simplest way
    - if the number of records are not very high
    - provided table structures are the same across db2 & db3 and
    - you have privileges to write into db3 from db1.
    insert into table@instance3 as select from table@instance2
    Edited by: Sudheendra on Jan 17, 2012 5:16 PM

  • DBLINK confusion

    Hi,
    I am getting an error on Insert flow into I$ table step while execution.
    I am connecting two database from two different hosts, both are in oracle.
    I have two logical schema prepared for both database.
    should i have to mentioned these schema in one physical topology? what should be placed in schema and work schema option.
    I have used LKM Oracle to Oracle(DBLINK) as KM.
    Please help
    Best regards,
    manish

    Hi Manish,
    Are you accessing target DB machine remotely, if yes you need to create DBLink at target DB machine and you need to specify same at Topology Manager>Oracle technology>Physical Architecture> In Definition tab Instance / dblink (Data Server)
    I hope you are not provided DBLink details at Instance / dblink (Data Server) while configuring target DB in topology manager
    I think you got error " *Caused By: java.sql.SQLSyntaxErrorException: ORA-01729: database link name expected* " when you using LKM Oracle to Oracle(DBLINK) as KM
    Regards,
    Phanikanth

  • Insert via DB-LINK

    Hi, i'm trying to insert via dblink data selected from local table. Here is the code:
    create or replace type T_DATA_IDS as table of number(19);
    export_process_ids t_data_ids;And here is the query:
        insert into process@archive
          (select * from process where process_id in
            (select * from table(export_process_ids)));And it throws
    ORA-22804: remote operations not permitted on object tables or user-defined type columns
    When i change '(select * from table(export_process_ids))' to some id's from that table data is inserted without errors.
    How can i work around that error?
    Edited by: 843706 on 2011-03-11 05:58

    843706 wrote:
    I tried
    create table temp2 as (select * from table(export_process_ids));But now i have error:
    Error(90,3): PLS-00103: Encountered the symbol "CREATE" when expecting one of the following:    
    begin case declare end exception exit for goto if loop mod    null pragma raise return select update while
    with    <an identifier> <a double-quoted delimited-identifier>    <a bind variable> << close current
    delete fetch lock insert    open rollback savepoint set sql execute commit forall merge    pipe So is it possible to use DDL in PL/SQL?You'r doing this within a plsql block, right?
    You need the following:
    begin
      execute immediate 'create table temp2 as (select * from table(export_process_ids))';
    end>
    [...] but with every iteration it executes one select query ((select * from process where process_id in my_rows.NOT_SURE_WHAT_THIS_NAME_IS) )) which i'd like to avoid.No. For inserts FORALL creates a bulk statement. Only for updates FORALL creates individual statements:
    CREATE OR REPLACE TYPE my_collection IS VARRAY (256) OF NUMBER;
    CREATE TABLE test_bulk (   test_id    NUMBER , id_test_1  NUMBER , id_test_2  NUMBER );
    CREATE OR REPLACE TRIGGER test_asi AFTER INSERT ON TEST_BULK  REFERENCING NEW AS NEW OLD AS Old DECLARE BEGIN  DBMS_OUTPUT.PUT_LINE('expensive action'); END;
    DECLARE
      my_collection_test  my_collection;
    BEGIN
          SELECT LEVEL
            BULK COLLECT INTO my_collection_test
            FROM DUAL
      CONNECT BY LEVEL < 15;
      DBMS_OUTPUT.PUT_LINE('forall');
    FORALL i IN 1..my_collection_test.COUNT
               INSERT INTO test_bulk(id_test_1,id_test_2) VALUES (1,my_collection_test(i));
      DBMS_OUTPUT.PUT_LINE('simple loop');
       FOR i IN 1..my_collection_test.COUNT LOOP
               INSERT INTO test_bulk(id_test_1,id_test_2) VALUES (1,my_collection_test(i));
       END LOOP;
    END;
    DROP TABLE test_bulk;
    DROP TYPE my_collection;returns:forall
    expensive action
    simple loop
    expensive action
    expensive action
    expensive action
    expensive action
    expensive action
    expensive action
    expensive action
    expensive action
    expensive action
    expensive action
    expensive action
    expensive action
    expensive action
    expensive action

  • ODI11g Integration Step:  Insert flow into I$ Table failure: TNS: error

    The project/interfaces have been working successfully for quite sometime. After a server reboot, they are all failing on the Integration step
    Insert flow into I$ Table failure with:
    ODI-1228: Task xxxxx(Integration) fails on the target ORACLE connection xxxxxx.
    Caused By: java.sql.SQLException: ORA-12154: TNS:could not resolve the connect identifier specified
    I have verified the topology and the dblink/Data Server is what resides in the tnsnames.ora file (which also has not changed).
    Any ideas what else to look at, all topology connection tests are successful.
    Thank you.

    All connections were testing successfull. The problem ended up being with one of the database links, after the server reboot there were multiple tnsnames and the environment was not pointing to the correct one. After removing all tnsnames except for the correct, the problem was fixed.
    Thank you for your response.

  • Performence Imporve

    1.I am inserting bulk load 9 GB file into oracle database but performence is not upto the mark.Its taking arround 99 minutes which is very high.There is index on one field of target table.I am using LKM file to oracle(external table) and ikm sql control append.My target+staging area are on same location.
    Oracle 11g ,ODI and file is located on same machine.
    2.Then i simultaneous launched two parallel odi integration interface.Means i inserted 2 9 GB file into oracle database(accord. to Simultaneous Launching Of Multiple Parallel ODI Integration Interfaces
    My target+staging area are on same location
    Oracle 11g ,ODI and file is located on same machine..and it took 4 hrs.
    How to improve these performences?

    I am not able to insert using sqlloader bcz getting error at File.err
    Invalid argument for username/password.
    In physical architecture of topology when i inserted data server by right clicking oracle then there is option instance/dblink(data server) which i left blank.

  • Work Repository creation - Error

    hi,
    I have cretaed Master Repository successfully but while creating Work Repository, getting following error
    Name : Work_Repository
    Technology: Oracle
    instance/dblink (Data Server): (empty)
    username: snpw (I have created this user)
    password: snpw
    JDBC Driver: oracle.jdbc.driver.OracleDriver
    JDBC URL: jdbc:oracle:thin:@localhost:1521:XE
    ERROR
    java.lang.NullPointerException
         at com.sunopsis.dwg.DwgObject.computeNextId(DwgObject.java)
         at com.sunopsis.dwg.DwgObject.getNextEntId(DwgObject.java)
         at com.sunopsis.dwg.DwgObject.getNextEntId(DwgObject.java)
         at com.sunopsis.graphical.frame.a.ji.cz(ji.java)
         at com.sunopsis.graphical.frame.bo.cC(bo.java)
         at com.sunopsis.graphical.frame.a.ji.cC(ji.java)
         at com.sunopsis.graphical.frame.bo.bH(bo.java)
         at com.sunopsis.graphical.frame.bn.q(bn.java)
         at com.sunopsis.graphical.frame.bn.t(bn.java)
         at com.sunopsis.graphical.frame.bn.f(bn.java)
         at com.sunopsis.graphical.frame.bn.z(bn.java)
         at com.sunopsis.graphical.frame.bn.c(bn.java)
         at com.sunopsis.graphical.frame.w.actionPerformed(w.java)
         at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
         at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(Unknown Source)
         at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
         at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
         at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
         at java.awt.Component.processMouseEvent(Unknown Source)
         at java.awt.Component.processEvent(Unknown Source)
         at java.awt.Container.processEvent(Unknown Source)
         at java.awt.Component.dispatchEventImpl(Unknown Source)
         at java.awt.Container.dispatchEventImpl(Unknown Source)
         at java.awt.Component.dispatchEvent(Unknown Source)
         at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
         at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
         at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
         at java.awt.Container.dispatchEventImpl(Unknown Source)
         at java.awt.Window.dispatchEventImpl(Unknown Source)
         at java.awt.Component.dispatchEvent(Unknown Source)
         at java.awt.EventQueue.dispatchEvent(Unknown Source)
         at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
         at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
         at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
         at java.awt.EventDispatchThread.run(Unknown Source)
    Please help to resolve this issue
    Thanks in advance

    both user name & password for master repository & working repoistory should be same ---
    username: snpw (I have created this user)
    password: snpw
    while looging to topology manager create a new connection with master repository details & then create the data server & working repository

  • How to transfer DATA from one machine to another using  DBlink

    I want to transfer data from one machine to another both having oracle 8.0.5 with AIX operating system using DB link. CAn any one help me in this task

    Step one - Create and test SQLNet connections between the databases.
    Step two - Create at least on database like from one database to the other:
    CREATE DATABASE LINK linkname
    CONNECT TO user identified by password
    USING 'tnsnamesentry';
    Step three - use the dblink linkname in dml statements eg:
    insert into emp@linkname
    (select * from emp);

  • I am getting ORA-02063 error while copying bulk data from DBLINK

    Hi all ,
    I am trying to copy data from DBlink ,whenever i am trying to pull more data ,The db link break down ,
    I have try to put /*+ APPEND */  (Hint) in insert statement.Below is the insert code from my procedure
    from where i am getting below error
    "Error in copy_data_pkg-3113 ORA-03113: end-of-file on communication channel
    ORA-02063: preceding line from TESTDBLINK"
    Insert code:
    INSERT /*+ APPEND */ INTO target_tab
    select
    col1,
    col2,
    col3,
    col4,
    col5,
    o_time
    FROM padmin.V_tab1@testdblink
        where
    trunc (sysmodtime) = trunc(sysdate)-1
    and O_time >= al_time
    and (CLEAR_TIME is null or  CLEAR_TIME >= occur_time)
        and (res_code is null or (UPPER(res_code) not LIKE '%TEST TT%' and UPPER(res_code) not LIKE '%TEST SITE%'))
        and ((UPPER(BRIEF_DESC) not like '%TEST TT%' and UPPER(BRIEF_DESC) not LIKE '%TEST SITE%'))
        and (o_time+(330/(24*60))) <= trunc(SYSDATE)-1/24/60/60
        and  catvar IN('POS')
      and UPPER(action_var) not like '%SC_NET%' and UPPER(action) not like '%ROAM_NET%' and UPPER(action) not like '%PUP_NET%';
      COMMIT ;
    Please suggest me ,why i am getting this error.

    Can you elaborate the thing... I don't think  /*+ APPEND */ this is working for me ,still I am getting same error.
    If you have any other suggestion,I would like to hear.
    Should i not put commit after some 500 records inserted ? As i am putting commit once after whole data gets inserted.

  • Copying table data accross a dblink using dbms_datapump

    Hi Friends,
    I need to copy a table data accross a dblink into another table of same structure.
    There is a requirement to use 10g dbms_datapump package to copy the data.
    The problem is that I can export into a dump file and then import it into the other database, But we do not need the dump file. We need directly exportimg and simultaneously importing into the table through dblink without generating the intermediate dump file.
    If any one have a sample code or document link, Please do help.
    cheers

    But the application we have that uses the database cannot be changed to read from a CLOBWhy can't you change the application?
    Well, anyway you should point out to your superiors that Oracle documented years ago to not use LONGS anymore...
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14220/datatype.htm#sthref3806
    It clearly states:
    LONG Datatype
    Note:
    Do not create tables with LONG columns. Use LOB columns (CLOB, NCLOB) instead. LONG columns are supported only for backward compatibility.
    Oracle also recommends that you convert existing LONG columns to LOB columns. LOB columns are subject to far fewer restrictions than LONG columns. Further, LOB functionality is enhanced in every release, whereas LONG functionality has been static for several releases.
    How do I go from CLOB to LONG?I'm sorry, cannot help you on that one, I don't think you can do that at all (Oracle wants us to stop using LONGS, so, it's a one-way conversion...):
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:1037232794454#15512131314505
    So: NO built_in, you'll need to write a program if the clob is ALWAYS LESS THAN 32k in size, you can use plsql..but is that the case in your case? Only you know that.
    I believe that question is still unanswered on this forum, but you might try searchin for answers on this forum, and
    the 'Database-General' forum: General Database Discussions
    Perhaps you can google a Q&D workaround...
    ( And consider convincing your collegues to just convert your LONGS to LOBS)
    Edited by: hoek on Apr 8, 2009 5:43 PM

  • PowerPlant passive Oracle dblink to read data from SAP ECC?

    Hello
    We have a third party vendor named PowerPlant that is proposing to integrate with SAP ECC using a passive dblink to pull data into PowerPlant.  This is proposed when SAP ECC is running on an Oracle database.  Presumably this is a read-only connection to the SAP ECC Oracle database (at database level).  Has anyone used this and/or have recommnedations for or against?
    Thank you,
    Harold

    Hi Harold,
    Technically it is possible but, check your Oracle license with the local SAP office. As far as I know that SAP is not permitted 3rd party connections to the database.
    Best regards,
    Orkun Gedik

  • Using DBLINK in ABAP to retreive data from externam system

    Hi All,
    Please help me, if anyone knows the answer.
    The basis team has created a dblink 'DBL_TEST.YY.XXX.COM'.
    Now I have to fetch data from another non-sap external system using this dblink only. Cannot have any entry in DBCON.
    I know the procedure of retreiving data using DBCON entry. But since DBCON will not be used here, so I have to use the DBLINK to get data from an external oracle table (say, ZTEST).
    I need the procedure to implement the logic in abap program.
    Thanks in advance,
    Ipsita

    My problem is now solved. We created views @the database level, and fetched data using the database view in Native SQL.
    In case anybody needs to do, I am giving a short code dump;
        TRY.
            EXEC SQL PERFORMING f_loop_output.
              select alias_type_id,
                     name,
                     molecule_id
              into   :w_tab
              from   ext.V_XXXX
              where molecule_id in
               (Select mh.MOLECULE_ID
                from  ext.V_YYYY mh, ext.V_XXXX al
                where  mh.molecule_id   = al.molecule_id
                and    mh.IS_CURRENT    = 'Y'
                and    al.ALIAS_TYPE_ID = :c_type_id
                and    al.NAME                  = :l_number
              and ALIAS_TYPE_ID in ('AAA','B','CCCC')
            ENDEXEC.
          CATCH cx_sy_native_sql_error INTO l_check_rs.
            l_text  = l_check_rs->get_text( ).
            MESSAGE i005 WITH l_text.
            LEAVE LIST-PROCESSING.
        ENDTRY.

  • Accessing DB2 data through DBLINK in Java program recieves ORA-02063 error

    Hello,
    Is it posible to access a mainframe DB2 table through a Java JDBC connection utilizing a DBLink / Synonym. Using Toad or SQLDeveloper, I can select the DB2 data just fine. Also, PL/SQL programs can access the data without issues. When I try to select data from the DB2 Table in a Java program, I get ORA-01002: fetch out of sequence -- ORA-02063 preceding line from DB2D errors.
    The code I am using to test is:
    (Note: TBL_LOC_ADR is the Synonym that points to the Mainfram DB2 table)
    public static void main(String[] args) {
              Connection con = null;
              Statement stmt = null;
              String query = "SELECT * FROM tbl_loc_adr";
              ResultSet rs;
              try {
                   System.out.println("Getting connection");
                   con = BatchDBConnection.getDBConnection();
                   TestConnection tc = new TestConnection();
                   System.out.println("Creating ps");
                   stmt = con.createStatement();
                   System.out.println("Calling qds");
                   rs = stmt.executeQuery(query);
                   System.out.println(" Returned data " );
              } catch (Exception e) {
                   System.out.println("Error " + e.getMessage());
                   e.printStackTrace();
    The error occurs on the rs = stmt.executeQuery(query); line.
    Thanks for any input into this error. It's been driving me nuts all day.
    Chris

    Chris,
    What's your oracle version? You might be hitting a bug as identified in this metalkink doc id, see if this helps out. Resolution posted in the metalink by applying patches or confirm that you have applied all the required patches.
    Doc ID: 456815.1 ORA-01002 ORA-2063 When Profiling DB2/400 Table Accessed by View via Transparent Gateway for DRDA
    Regards

  • SQL*Net more data to dblink event for hours or days

    Hello Everyone,
    in our production database when we commit a transaction we call a remote procedure over dblink.
    usually the call succeeds ,but every now and then a couple of sessions hang up,
    when I use the session browser of Toad I notice that these sessions are waiting with the event SQL*Net more data to dblink
    below are some queries and their results:
    select sid,event,wait_class,wait_time,seconds_in_wait,state from gv$session_wait where sid=225
    rslt:
    225 SQL*Net more data to dblink Network -1 18279 WAITED SHORT TIME
    select * from gv$session_wait_history where sid=225
    rslt:
    INST_ID     SID     SEQ#     EVENT#     EVENT     P1TEXT     P1     P2TEXT     P2     P3TEXT     P3     WAIT_TIME     WAIT_TIME_MICRO     TIME_SINCE_LAST_WAIT_MICRO
    2     225     1     344     SQL*Net more data to dblink     driver id     1413697536     #bytes     8144          0     0     8     41
    2     225     2     344     SQL*Net more data to dblink     driver id     1413697536     #bytes     8143          0     0     13     39
    2     225     3     344     SQL*Net more data to dblink     driver id     1413697536     #bytes     8149          0     0     7     37
    2     225     4     344     SQL*Net more data to dblink     driver id     1413697536     #bytes     8145          0     0     8     40
    2     225     5     344     SQL*Net more data to dblink     driver id     1413697536     #bytes     8145          0     1     11394     37
    2     225     6     344     SQL*Net more data to dblink     driver id     1413697536     #bytes     8143          0     0     7     37
    2     225     7     344     SQL*Net more data to dblink     driver id     1413697536     #bytes     8145          0     0     7     36
    2     225     8     344     SQL*Net more data to dblink     driver id     1413697536     #bytes     8138          0     0     8     37
    2     225     9     344     SQL*Net more data to dblink     driver id     1413697536     #bytes     8149          0     0     8     38
    2     225     10     344     SQL*Net more data to dblink     driver id     1413697536     #bytes     8149          0     1     11476     37I'm not sure but from the above results ,is it safe to conclude that I get stuck because I am caught in infinite loop trying to write to dblink?
    additional notes:
    <li>some times when I look at the current statement I find that the statement is a query or insert into a local table.
    <li>there were some network outages.
    <li>when viewing the database log files I found:Error 3135 trapped in 2PC on transaction 7.6.306086. Cleaning up.
    Error stack returned to user:
    ORA-03135: connection lost contact
    ORA-02063: preceding line from MPF//where MPF is the name of dblinkeven though we use the DBLink to execute the procedure only without any changes on the remote DB, and we don't use 2PC.
    <li> the local DB is a RAC
    select * from dba_blockers
    rslt:
    no rows
    select * from dba_waiters
    rslt:
    no rows
    select * from gv$lock where sid=225
    rslt:
    INST_ID     ADDR     KADDR     SID     TYPE     ID1     ID2     LMODE     REQUEST     CTIME     BLOCK
    2     0000000199D54F60     0000000199D54FB8     225     AE     100     0     4     0     20152     2
    2     000000018EA18108     000000018EA18180     225     TX     1114138     251539     6     0     19654     2
    select * from gv$session where sid=225
    rslt:
    INST_ID     SADDR     SID     SERIAL#     AUDSID     PADDR     USER#     USERNAME     COMMAND     OWNERID     TADDR     LOCKWAIT     STATUS     SERVER     SCHEMA#     SCHEMANAME     OSUSER     PROCESS     MACHINE     PORT     TERMINAL     PROGRAM     TYPE     SQL_ADDRESS     SQL_HASH_VALUE     SQL_ID     SQL_CHILD_NUMBER     SQL_EXEC_START     SQL_EXEC_ID     PREV_SQL_ADDR     PREV_HASH_VALUE     PREV_SQL_ID     PREV_CHILD_NUMBER     PREV_EXEC_START     PREV_EXEC_ID     PLSQL_ENTRY_OBJECT_ID     PLSQL_ENTRY_SUBPROGRAM_ID     PLSQL_OBJECT_ID     PLSQL_SUBPROGRAM_ID     MODULE     MODULE_HASH     ACTION     ACTION_HASH     CLIENT_INFO     FIXED_TABLE_SEQUENCE     ROW_WAIT_OBJ#     ROW_WAIT_FILE#     ROW_WAIT_BLOCK#     ROW_WAIT_ROW#     TOP_LEVEL_CALL#     LOGON_TIME     LAST_CALL_ET     PDML_ENABLED     FAILOVER_TYPE     FAILOVER_METHOD     FAILED_OVER     RESOURCE_CONSUMER_GROUP     PDML_STATUS     PDDL_STATUS     PQ_STATUS     CURRENT_QUEUE_DURATION     CLIENT_IDENTIFIER     BLOCKING_SESSION_STATUS     BLOCKING_INSTANCE     BLOCKING_SESSION     FINAL_BLOCKING_SESSION_STATUS     FINAL_BLOCKING_INSTANCE     FINAL_BLOCKING_SESSION     SEQ#     EVENT#     EVENT     P1TEXT     P1     P1RAW     P2TEXT     P2     P2RAW     P3TEXT     P3     P3RAW     WAIT_CLASS_ID     WAIT_CLASS#     WAIT_CLASS     WAIT_TIME     SECONDS_IN_WAIT     STATE     WAIT_TIME_MICRO     TIME_REMAINING_MICRO     TIME_SINCE_LAST_WAIT_MICRO     SERVICE_NAME     SQL_TRACE     SQL_TRACE_WAITS     SQL_TRACE_BINDS     SQL_TRACE_PLAN_STATS     SESSION_EDITION_ID     CREATOR_ADDR     CREATOR_SERIAL#     ECID
    2     00000001993E4F58     225     445     1353611     0000000198E2FA10     198     <schema>     47     2147483644     000000018EA18108          ACTIVE     DEDICATED     198     <schema>     oracle     1234     <cluster name>     49993     unknown     JDBC Thin Client     USER     00000001968A1250     3198676106     72y8ztfzagv4a     2     02/04/2013 11:18:22 ص     33554852     00000001968A18E0     3992616824     03mm4u3qznzvs     0     02/04/2013 11:18:22 ص     33554730     158207     1     158207     1     JDBC Thin Client     2546894660          0          12206     122409     8     49354     0     94     02/04/2013 10:53:20 ص     19559     NO     NONE     NONE     NO          DISABLED     ENABLED     ENABLED     0          NOT IN WAIT               NOT IN WAIT               42844     344     SQL*Net more data to dblink     driver id     1413697536     0000000054435000     #bytes     8144     0000000000001FD0          0     00     2000153315     7     Network     -1     19553     WAITED SHORT TIME     8          19553325216     SYS$USERS     DISABLED     FALSE     FALSE     FIRST EXEC     100     0000000198E2FA10     2     004qLk^iPyp0bqw5wFDCiW0002fR000B^f

    Hi ,
    we managed to reproduce the case in test environment, below are the steps:
    1)have 2 databases on different machines, will call the first one local, the other one remote.
    2)in the local database create:
    a - DBLink to remote database.
    b - read data from remote database(we simply used select count(*) from dummy_table )
    c - insert data into a table on the local database
    d - terminate the connection between the 2 databases (disconnect either machine from the network)
    e - commit on local database.
    what we noticed was the following:
    1)when the local database is disconnected from the network(the machine is not connected to any network at the moment): almost immediately throws an error, and issuing the following:
    select * from dba_2pc_pending;we found some data .
    2) when the remote database was disconnected(the local database is still connected to the network):
    after 7-8 seconds an error is thrown, and issuing the following:
    select * from dba_2pc_pending;did not return any data.
    since this is pretty similar to our case ,we concluded that it's a network issue.
    is this the correct behavior ?
    as a temporary solution till the network issue is fixed ,we did the following:
    1) changed the call of the remote procedure to calling a local procedure that calls the remote procedure.
    2) added pragma autonomous_transaction to the local procedure.
    3) at the end of the local procedure rollback the autonomous transaction.
    it seems that since the global transaction does not use the DBLink database does not issue a 2PC commit.
    this works in my cases since the DBLink is only issed to read data.

  • Data transfer using dblink

    I am transfering the data from Mysql database to Oracle 11gR2. I using a control table( here temp_tab ) to maintain the details of the source and target table and dblink info.
    Also p1 is the procedure used for data transfer. My problem is
    1) I am not able to move data for some of the MSQL tables as they have text columns. The text columns cannot be queried and inserted in oracle database. tables The whole insert
    fails. The work around can be to use column names in select through which i am inserting data ( i can give null as <columnname> ) so that i can get text field as null for now.
    But the problem is if i hard code the values in select dynamic character of code is destroyed.
    2) I wanna use bulk collect in my code so that if one records fails the whole data of table doesnot fail. So that save exception can be used for record failure.
    Can anyone suggest a work aroung in this code.
    temp_tab
    ================================
    source_tab     target_tab          dblink
    aaa@dblink     aaa1               dblink name
    bbb@dblink     bbb1               dblink name
    ccc@dblink     ccc1               dblink name
    procedure p1 is
         cursor cursor_tab is select * from temp_tab;
    begin
         for cur in cursor_tab
         loop
              begin
                   EXECUTE IMMEDIATE 'insert into ' || cur.target_tab || ' select * from ' || cur.source_tab;
              exception
                   when other then
                        dbms_output.put_line(' the error is :: ' || sqlerrm(sqlcode));
              end;
         end loop;
    end p1;

    What in your code is dynamic and requires native dynamic SQL?
    Cursor FOR Loops have been obsolete in the Oracle database for more than 12 years ... why are you using one and why are you using a loop at all?
    It appears that all you have, and require, is INSERT INTO ... SELECT * FROM.
    You source table definition does not reference or use a database link. Why?

Maybe you are looking for