Update a table column with data from other table

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • vinayagama
    New Member
    • May 2013
    • 2

    Update a table column with data from other table

    1. I have three table
    a. Relationship table(table A and Table b relationship)
    b. Table A
    c. Table B
    2. Read each record in relationship table and search for combination of table A and table B data
    3. Upon find the combination, update the attributes of table A with table B attribute.
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    What have you done so far?

    Comment

    • vinayagama
      New Member
      • May 2013
      • 2

      #3
      I tried to use the following to update the matched records,

      Code:
      merge into table_A d
       using (select a.toobjectnumber,a.fromobjectnumber,b.trobjectnumber,c.objectnumber,b.eexport_control from relationship_table a, table_A c , table_B b)alg
          on (alg.toobjectnumber = alg.objectnumber AND alg.fromobjectnumber=alg.trobjectnumber)
        when matched then
      update set d.export_control = alg.eexport_control;
      Error report:
      SQL Error: ORA-30926: unable to get a stable set of rows in the source tables
      30926. 00000 - "unable to get a stable set of rows in the source tables"
      *Cause: A stable set of rows could not be got because of large dml
      activity or a non-deterministic where clause.
      *Action: Remove any non-deterministic where clauses and reissue the dml.
      Last edited by Rabbit; May 28 '13, 04:38 PM. Reason: Please use code tags when posting code.

      Comment

      • Rabbit
        Recognized Expert MVP
        • Jan 2007
        • 12517

        #4
        That phrase means that the the query inside the USING clause returns a non-unique set of rows. The returned rows can’t be matched uniquely against the target table in the ON clause. The ON clause is where the MERGE statment matches the source query’s rows against the target table’s rows.

        On a possibly related note, it makes no sense that your ON clause is matching to fields solely within the source.

        Comment

        Working...