Insert row using db_link

Hi All,
I am trying to insert data from one DB to another DB via db_link between them.
insert into table@xyz
select
col 1, col2 , ... coln from table wher id = 123;
the error is : ORA-02019: connection description for remote database not found
But i am sure the connection description is good and healthy working fine.
I checked it by
select count(*) from table@xyz;
And this resulted the # of rows.
Before this the error message was to set global name to true and then i changed the db_link name to global name..
I am using 10.2.0.5
Need help to fix this !!
Thanks,
AAG

Hi,
Just Check the TNSNAMES.ORA file that you have added the connection description for the remote database.
1.The TNSNAMES.ORA file will be in ORACLe_HOME\ora81\network\ADMIN.
2. Then try creating the link for the same..
Login as SYSDBA..
create database link "Link_name" connect to "REMOTE_USER_NAME"identified by "remote-db-pwd" using 'DBNAME';
Then, Just Check from you database the link is working by select statement to remote db..
select * from remote_user_name.table_name@link_name;
Once if you get, the link is fine and correct..
So,you can proceed with your Insert statement as
insert into your_table select * from remote_user_name.table_name@link_name;
Information:
There is a need to Perform a commit, if you perform even a select query from the remote database.
Edited by: Shankar Viji on May 10, 2012 2:52 AM

Similar Messages

  • How to see inserted rows using load csv data

    Hey all...
    I am using apex 3.1 and I want to know how can I see non failed rows when I insert data from an CSV file.
    the failed rows that I can see are the the ones that shows in the next case: Uploading data that already exists and having a primary key violation. But what I really want to see is the description of the rows that had been succesfully loaded, not just a number of succesfully loaded rows.
    Thanks in advance.
    Luis.

    Try some thing like this
    select  Field, Filed2, ORA_ROWSCN, SCN_TO_TIMESTAMP(ORA_ROWSCN)  from Table Name
    You will get the recent  date of  insert/update of record

  • Inserting rows using pl sql

    Hi all,
    I created one tabale to inserting some numbers
    create table loc_number (c1 number);
    now i want to insert 10 rows into this table using pl sql.
    How can i do that using pl sql?

    Hi,
    Yes it is possible.
    Why do you want to use loops here ?
    (I'm assuming, you need this for practice purpose)
    begin
    for i in 1..10
    loop
       insert into loc_number
           values (i);
    end loop;
    commit;
    end;

  • Insert row enhancement

    Idea
    A useful feature I would like to suggest would be to allow the creation of multiple blank rows from the 'insert row' button in a table tab.
    Possible Solution
    A good solution would be to add a prompt next to the button in order to specify the number of blank rows you wish to create. It should default to one to keep the current behavior intact but would allow the user to specify how many rows to insert.
    Issues with Current Behavior
    Currently you need to click 'insert new row' 50 times to paste 50 rows (from excel for example). If you click it 30 times and paste 50 rows, it will insert the first 30, then overwrite the first 20 existing values. Plus clicking the insert button for each row you want to insert isn't that productive.
    Other Comments
    I'm sure that many have experienced this delemma and has issues with the consistency of the current excel import tool. This solution would prove to be an easy alternative to importing with a tool and will prove to be a simple way to really improve the usability and much more importantly the ease of this product.
    Feedback
    If you have had a situation where this would have been nifty feel free to reply with thoughts.
    Oracle
    Do you believe this would be possible from a development standpoint and what sort of feedback can you provide on the probability of an enhancement like this.

    Just in case you haven't tried the following :
    When in last cell of the last row, you can hit Tab key and that would create a new row and the focus would be in the first cell of the newly created row.
    So you don't need to hit the insert row button. Btw, you can also set an accelerator for "Insert Row" using Preferences->Accelerators.
    So, probably your feature request could be to - automatically create appropriate # of rows and insert data into those when you paste the data copied from excel into the grid. That should save you a few clicks and eliminate the need of having a textfield to set the # of rows.
    -Raghu

  • How to retrieve the last inserted row

    This may be a question with a very known answer but I couldn't find any within this forum.
    What is the proper way to retrieve the just inserted record ?
    I'm accessing the DB from external Java and at this moment I use a timestamp column in order to retrieve the inserted row. So I generate an unique timestamp ('20020615184524356') which I inserted during the insert operation. I retrieve the just inserted row using "select * from fooTable where(timestamp='20020615184524356')".
    Is this the general idea or am I totally wrong ?

    hi Shaik Khaleel,
    Just wanted to clarify my doubts regarding rowid.
    Please refer the subject as "abt rowid" in previous posting and ur reply for that was
    "its an unique number throughout the database, its an hexadecimal number. it assigns the rowid of the deleted row in future , but not to the immediate insertation row."
    As u have mentioned the rowid of the deleted row can be assigned to a new row in future,
    wont the following query fail.
    select * from temp where rowid=(select max(rowid) from temp); -- in oracle. ~chandru

  • Rownum and last inserted row !!!!!!!!!!!!

    hi everybody,
    I am at present using oracle 8i Release 2. According to my knowledge and "Oracle 8 complete reference", when we use ROWNUM, the rownum is decided when the data is selected from the database. So when we use "order by" clause actually the rownum gets jumbled up.
    But to my surprise when i did something like this on my SQl prompt row num is acting very "innocent" :)
    <Code>
    1* select rownum, empno from emp
    SQL> /
    ROWNUM EMPNO
    1 7369
    2 7499
    3 7521
    4 7566
    5 7654
    6 7698
    7 7782
    8 7788
    9 7839
    10 7844
    11 7876
    12 7900
    13 7902
    14 7934
    15 1
    15 rows selected.
    SQL> select rownum, empno from emp order by empno;
    ROWNUM EMPNO
    1 1
    2 7369
    3 7499
    4 7521
    5 7566
    6 7654
    7 7698
    8 7782
    9 7788
    10 7839
    11 7844
    12 7876
    13 7900
    14 7902
    15 7934
    15 rows selected.
    </Code>
    As you can see rownum is ordered again .. m i missing something.
    B)
    Is it possible to get a row that was inserted last. Does oracle guarantee that data retrieval will be according to the time of inssertion !!
    Thanx in advance
    Chetan

    Rownum is decided afeter the complete execution of ur SQL statment (it includes ordey by, group by, where etc.).
    you can get the last inserted row using:
    select * from emp where rowid=
    (select max(rowid) from emp);
    Regards
    Riaz

  • Inserting multiple rows using a single Insert statement without using dual

    Hi all,
    i am trying to insert multiple rows using a single insert statement like the below one.
    The below one works fine..
    But is there any other change that can be done in the below one without using dual...
    insert all
    into ps_hd_samp (num1,num2) values (1,1)
    into ps_hd_samp (num1,num2) values (2,2)
    into ps_hd_samp (num1,num2) values (3,3)
    select 1 from dual;

    NiranjanSe wrote:
    Hi all,
    i am trying to insert multiple rows using a single insert statement like the below one.
    The below one works fine..
    But is there any other change that can be done in the below one without using dual...
    insert all
    into ps_hd_samp (num1,num2) values (1,1)
    into ps_hd_samp (num1,num2) values (2,2)
    into ps_hd_samp (num1,num2) values (3,3)
    select 1 from dual;
    SQL> create table ps_hd_samp (num1 number,num2 number);
    Table created.
    SQL> insert all
      2  into ps_hd_samp (num1,num2) values (1,1)
      3  into ps_hd_samp (num1,num2) values (2,2)
      4  into ps_hd_samp (num1,num2) values (3,3)
      5  select count(*)
      6  from ps_hd_samp;
    3 rows created.
    SQL> select * from ps_hd_samp;
          NUM1       NUM2
             1          1
             2          2
             3          3

  • SQL: inserting new rows using ResultSet

    Hi,
    I have the following question - how does one properly insert rows into a database table, using an updatable ResultSet? There doesn't seem to be much to it, but the following code/result has me puzzled:
    1. My MS SQL table:
    create table dogs
    age integer
    2. Java code
    public class TestSQL {
    public static void main (String args[]) {
    try{
    Connection con = null;
    Statement stmt = null;
    ResultSet rs = null;
    String url = "jdbc:odbc:bolit";
    String usr = "bolit";
    String pwd = "bolit";
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    con = DriverManager.getConnection(url, usr, pwd);
    stmt = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
    rs = stmt.executeQuery("Select * from dogs");
    rs.moveToInsertRow();
    rs.updateInt("age",10);
    rs.insertRow();
    } catch(Exception e) {
    System.out.println("TestSQL.main: "+e);
    3. Resulting exception:
    TestSQL.main: java.lang.NullPointerException
    I would have maybe expected some SQL exception, but this I don't understand...
    I'm in advance very grateful for any assistance.
    By the way, how can one format code in posts?

    to format posts, see:
    http://forum.java.sun.com/faq.jsp#messageformat
    I'd try putting in some printouts to see what's null:Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    con = DriverManager.getConnection(url, usr, pwd);
    //PRINT OUT "con" HERE
    stmt = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
    //PRINT OUT "stmt" HERE
    rs = stmt.executeQuery("Select * from dogs");
    //PRINT OUT "rs" HERE
    rs.moveToInsertRow(); My guess is that your url is incorrect, so con is null, but I'm not a betting man, so I won't put any money on it ;-).

  • Insert multiple rows using Cursors.

    I am trying to insert rows into a table based on information from another table.
    For example:
    When Table 1: Num_Rows = 100 my proc will insert 100 rows into Table 2 with relevent data.
    Do I need to use a Cursor and iterate through Num_Rows doing an INSERT each time? Is there a better way to do it other than using Cursors?
    Rob.

    It is not about using cursors or not using cursors. All SQLs wind up as cursors in the Oracle Shared Pool. So there is no such concept as not using cursors. Oracle needs to parse and compile and execute SQLs as cursors.
    The issue is WHERE* you do the work?
    Do you use the cursor (SQL) to do it for you? Or do you pull the data into another language, like PL or Java and process it there?
    And the performance mantra in this case is a very fundemantal Maximize SQL and minimize PL/Java/etc+.
    So do not do in PL/SQL what you can do in SQL only. It is a lot slower to pull data from the SQL engine into the PL engine. And then push that very same data from the PL engine back to the SQL engine. Like the following for example:
    -- poor design, poor performance
    for employee in (select e.* from emp e where e.deptid = 123 )
    loop
      insert into tab2 values( employee.empid, employee.name );
    end loop;You do not need to use PL (or Java) in this case. The SQL language is more than able to do this better and faster than any other language... as it is closer to the data.
    So the following is far more optimal code. Instead of the above PL/SQL code, we can simply do it as:
    -- optimal design: maximizing SQL and letting it to as much of the work as possible
    insert into tab2 select e.empid, e.name from emp e where e.deptid = 123;

  • How to get the inserted row primary key with out  using select statement

    how to return the primary key of inserted row ,with out using select statement
    Edited by: 849614 on Apr 4, 2011 6:13 AM

    yes thanks to all ,who helped me .its working fine
    getGeneratedKeys
    String hh = "INSERT INTO DIPOFFERTE (DIPOFFERTEID,AUDITUSERIDMODIFIED)VALUES(DIPOFFERTE_SEQ.nextval,?)";
              String generatedColumns[] = {"DIPOFFERTEID"};
              PreparedStatement preparedStatement = null;
              try {
                   //String gen[] = {"DIPOFFERTEID"};
                   PreparedStatement pstmt = conn.prepareStatement(hh, generatedColumns);
                   pstmt.setLong(1, 1);
                   pstmt.executeUpdate();
                   ResultSet rs = pstmt.getGeneratedKeys();
                   rs.next();
    //               The generated order id
                   long orderId = rs.getLong(1);

  • Using XSQL to insert rows in more then one table

    I tried to insert rows in one table and it works fine but does anyone know is it possiblle to insert row in two tables using one XML file.

    Alem,
    Could u please let me know how u achieved this ? I am using xsql servlet too and would be interested in the same. If u have been able to insert/update into more than one table using insert-request let me too know how u did it.
    Thanks in advance,
    Shanthi

  • Not able to insert row programticaly

    hi am trying to insert row to another viewObject from another viewobject programaticaly ,can somebody help me,i have recreate the problem i upload it in hostfile,am in jdeveloper 11.1.1.6.0
    am geting this log error
    Caused by: oracle.jbo.InvalidOwnerException: JBO-29114 ADFContext is not setup to process messages for this exception. Use the exception stack trace and error code to investigate the root cause of this exception. Root cause error code is JBO-25030. Error message parameters are {0=UamUserdetails, 1=oracle.jbo.Key[marksn ]}
         at oracle.jbo.server.EntityImpl.internalCreate(EntityImpl.java:1341)
         at oracle.jbo.server.EntityImpl.create(EntityImpl.java:1020)
         at oracle.jbo.server.EntityImpl.callCreate(EntityImpl.java:1197)
         at oracle.jbo.server.ViewRowStorage.create(ViewRowStorage.java:1152)
         at oracle.jbo.server.ViewRowImpl.create(ViewRowImpl.java:498)
         at oracle.jbo.server.ViewRowImpl.callCreate(ViewRowImpl.java:515)
         at oracle.jbo.server.ViewObjectImpl.createInstance(ViewObjectImpl.java:5714)
         at oracle.jbo.server.QueryCollection.createRowWithEntities(QueryCollection.java:1993)
         at oracle.jbo.server.ViewRowSetImpl.createRowWithEntities(ViewRowSetImpl.java:2492)
         at oracle.jbo.server.ViewRowSetImpl.doCreateAndInitRow(ViewRowSetImpl.java:2533)
         at oracle.jbo.server.ViewRowSetImpl.createAndInitRow(ViewRowSetImpl.java:2498)
         at oracle.jbo.server.ViewObjectImpl.createAndInitRow(ViewObjectImpl.java:11042)
         at worklis.view.beantest.addnew(beantest.java:138)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:597)
         at com.sun.el.parser.AstValue.invoke(Unknown Source)
         at com.sun.el.MethodExpressionImpl.invoke(Unknown Source)
         at org.apache.myfaces.trinidadinternal.taglib.util.MethodExpressionMethodBinding.invoke(MethodExpressionMethodBinding.java:53)
         at org.apache.myfaces.trinidad.component.UIXComponentBase.broadcastToMethodBinding(UIXComponentBase.java:1256)
         at org.apache.myfaces.trinidad.component.UIXCommand.broadcast(UIXCommand.java:183)
         at org.apache.myfaces.trinidad.component.UIXCollection.broadcast(UIXCollection.java:148)
         at org.apache.myfaces.trinidad.component.UIXTable.broadcast(UIXTable.java:279)
         at oracle.adf.view.rich.component.UIXTable.broadcast(UIXTable.java:145)
         at oracle.adf.view.rich.component.rich.data.RichTable.broadcast(RichTable.java:402)
         at oracle.adf.view.rich.component.fragment.UIXRegion.broadcast(UIXRegion.java:148)
         at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl.broadcastEvents(LifecycleImpl.java:1018)
         at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl._executePhase(LifecycleImpl.java:386)
         at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:194)
         at javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)Edited by: adf009 on 2013/02/15 4:43 PM
    Edited by: adf009 on 2013/02/15 4:57 PM
    Edited by: adf009 on 2013/02/15 7:22 PM

    the code am using is below
        public void addnew(ActionEvent actionEvent) {
            // Add event code here...
            // Add event code here...
            //Code to get the bindings for TargetVO :
            Map<Object,String> mp=new HashMap<Object, String>();
                    DCBindingContainer bindings2 =
                       (DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
                   JUCtrlHierBinding obj = (JUCtrlHierBinding)bindings2.findCtrlBinding("UamUserdetailsView2");
                   ViewObject targetVO = obj.getViewObject();
              DCBindingContainer bindings =
                       (DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
                   DCIteratorBinding empIter =
                       bindings.findIteratorBinding("DeltTable1Iterator");
            //SourceVO1Iterator is the iterator under Executables section for the SourceVO1 bindings.
            RowSetIterator roleRSIters = empIter.getRowSetIterator();
            RowSetIterator rs1 = roleRSIters.getRowSet().getViewObject().createRowSetIterator(null);
            rs1.first();
                   NameValuePairs nvp = null;
                   String username = null;
            while (rs1.hasNext()) {
                               Row r = rs1.next();  
                       nvp = new NameValuePairs();
                      // nvp.setAttribute("organisationid", r.getAttribute("organisationid"));
                       nvp.setAttribute("Organisationid", getorgid());
                       System.out.println("printedorgid" +getorgid());
                       nvp.setAttribute("Username",r.getAttribute("Username"));
                       nvp.setAttribute("Username1",r.getAttribute("Username"));
                       nvp.setAttribute("Firstname",r.getAttribute("Firstname"));
                       nvp.setAttribute("Surname",r.getAttribute("Surname"));
                       nvp.setAttribute("Emailaddress",r.getAttribute("Emailaddress")); 
                       // username = (String)r.getAttribute("Username");
                       System.out.println("prininstead " + nvp);
                     //  targetVO.createAndInitRow(nvp);
                        r = targetVO.createAndInitRow(nvp);
                        targetVO.insertRow(r);
                        //createAndInitRow(AttributeList nvp);
            //Row row = targetVO.createAndInitRow(nvp);
              //      targetVO.insertRow(row);
                   rs1.closeRowSetIterator();
                   targetVO.getApplicationModule().getTransaction().commit();
        }i have re-created the problem i upload in this hostfile,you can have the whole picture of what am trying to do
    http://www.4shared.com/zip/RaZ07PWS/createRow.html
    Edited by: adf009 on 2013/02/15 7:36 PM
    Edited by: adf009 on 2013/02/15 7:38 PM
    Edited by: adf009 on 2013/02/15 8:01 PM

  • I am trying to insert rows for alert_id 22 with diff abc_id and xyz_id

    I am trying to insert rows for alert_id 22 with diff abc_id and xyz_id
    these inserts will store in two tables that I have to join in the cursor.
    I have written cursor without passing cursor parameters. but here i need to pass acb_id and xyz_id along with alert_id.
    then if these are saticified with alert_id 22 then I want to stop the loop run, else i need to continue the loop. bcause the abc_id and xyz_id are diff for alert_id 22
    This is the issue I am facing!
    Please let me know if you have any idea. Let me know how to use cursor parameters here and in loop.
    Sample proc like this::
    Declare
    main_cursor
    another_cur
    alert_cur
    begin
    need to check first abc_id,xyz_id is already exist with alert_id 22
    if this set of records already exists then
    exit from the loop
    else
    continue with
    loop
    here coming the insert statements with different condition getting from first two cursors.(this part is ok for me)
    end loop
    end if
    Please write the logic if any idea on this.
    -LRK

    I want to stop if already alert_id is exist!

  • How to Display a message after inserting row in table............

    Hi
    I want to display a message after inserting rows in table like *'you have inserted a new row successfully*'.
    i am using the createinsert ADF Button to insert the rows in table.after that i am comitting it.
    after commiting i want to display message for the user.for this what i need to do.
    Please help me.
    Sailaja.

    user10860137
    Can you please explain me the each line in the code briefly.
    +public String saveButton_action(){+
    BindingContainer bindings = getBindings();
    OperationBinding operationBinding = bindings.getOperationBinding("Commit");
    Object result = operationBinding.execute();
    +// note "!" operator has been removed from the default code.+
    +if(operationBinding.getErrors().isEmpty()){+
    FacesContext ctx = FacesContext.getCurrentInstance();
    FacesMessage saveMsg = new FacesMessage("Record Saved Successfully");
    ctx.addMessage(null,saveMsg);
    +}+
    return null;
    +}+
    And i have requirement to show the message on favcet "status bar".not in a popup window.(from the above code the message is showing in popup window. )the Layout i am using is PanelCollection.
    can you tell me what i need to do.
    Thanks
    Sailaja.
    Edited by: sj0609 on Mar 19, 2009 8:03 AM

  • Error while inserting rows in a table

    Hi,
    We have recently migrated from 9i to 10g. We have a scheduled job out our DB which first deletes all the rows from a table and then inserts them back by selecting rows from 5 tables. This table has a composite primary key based on 6 columns in it. In 9i, when i try to insert rows into the table after deleting all the rows from it, I am able to insert the data successfully . However, in 10g, when i try doing the same operation, it fails with the ORA error:
    ORA-00001: unique constraint violated
    The same query which works perfectly in 9i fails in 10g
    If anybody has some ideas on how to resolve the same, kindly let me know.
    Thanks in advance.

    Hi,
    I was finally able to resolve the reason behind that error message and found it even more weird. The error was because I was using the substr function for extracting the characters 1-4 from a column which is 5 characters long. When i specify the query as:
    select substr(column1, 1, 4)) from table1;
    only the characters 1-3 are retrieved. Now if i change the query to select substr(column1, 1, 5)) from table1, in that case also only 3 characters are retrieved although i have specified the substr to start from 1 and read till 5 characters. Also, when i run the query:
    select length(substr(column1, 1, 4)) from table1 or select length(substr(column1, 1, 5)) from table1
    I get the answer as 3.
    However, the most amazing part is that the query is working perfectly in 9i and is retrieving the data correctly i.e. from substr 1-4.
    Can anyone suggest what the problem could be?
    Thanks
    Edited by: CrazyAnie on May 13, 2009 1:34 AM

Maybe you are looking for

  • VGA, DVI, 18-pin, 30-pin???

    I'm sorry. I apologize from the bottom of my heart. I'm sure this issue has been dealt with somewhere in past forums but I have just wasted an hour trying to locate this info from other sources and failed. Please bear with me: I just received deliver

  • Back to my mac failing after upgrade to 10.10

    Hey guys, I upgraded my home iMac and home MBP at the same time to 10.10.  All went smoothly.  When out of town, my MBP can still see my iMac for Back to my Mac use.  I upgraded my work iMac, which has always been able to see my home iMac, to 10.10 a

  • Video levels how to

    i am frustrated here because i opened the audio panel and it appears for can make instant on-the-fly adjustments of your audio.  so now i'm trying to just tweak the whole video portion of my clip.  i keep trying to drag the video effect to the clip o

  • Bank keys and house bank creation

    Hi My company have 9 branches all over India. HO of my organization is in Bombay. Now every branch have bank account in respective city. 5 are Current account and 5 are Cash Credit account. But all these bank accounts are in one bank only say Bank AB

  • OSB Managed Servers Overloaded

    Hi All, We have a clustered environment in production. We have one Admin and four managed server. We have mostly DB calls. The initial and final capacity of the data source connecting to the DB are 0 and 15. The legacy DB are controlled by another co