update or insert data from one table to another

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Sally1053
    New Member
    • Sep 2007
    • 11

    #1

    update or insert data from one table to another

    i have been given a task, where i have to write a query that will take data from a certain database1 table and update the records in the database2 tables or insert new record

    how do i do that?

    and can one explain for me how the fetch statement works If i have to use to resolve my problem?
  • ck9663
    Recognized Expert Specialist
    • Jun 2007
    • 2878

    #2
    Originally posted by Sally1053
    i have been given a task, where i have to write a query that will take data from a certain database1 table and update the records in the database2 tables or insert new record

    how do i do that?

    and can one explain for me how the fetch statement works If i have to use to resolve my problem?

    how do you do that? just reference the tables using their fullname: dbname.owner.ta blename, both in select and insert.

    fetch is a command to read/get the value of each row of the table. each time you issue a FETCH, the entire row is stored in the memory, ready to be processed. you have to declare CURSOR first before you can use FETCH.

    use the CURSOR-FETCH as the last option...althou gh RDBMS can handle FETCH-ish type of processing, it's not always recommended to use it

    Comment

    • Sally1053
      New Member
      • Sep 2007
      • 11

      #3
      can you please give me and example of using the FETCH and cursor statement

      And make to be able to fetch more that one row at a time,

      lets say the two database are TEST and TLC (fetch from) and both have Table called Mine with same fields

      Comment

      • ck9663
        Recognized Expert Specialist
        • Jun 2007
        • 2878

        #4
        Originally posted by Sally1053
        can you please give me and example of using the FETCH and cursor statement

        And make to be able to fetch more that one row at a time,

        lets say the two database are TEST and TLC (fetch from) and both have Table called Mine with same fields
        check the online help on the example...what you could do is to create two cursors for the two fetch. the fetch assigned to that cursor will retrieve rows respectively, when called...

        Comment

        • REVENTH

          #5
          SELECT *
          INTO DestinationDB.. MyDestinationTa ble
          FROM SourceDB..MySou rceTable

          Comment

          Working...