Results 1 to 5 of 5
  1. #1
    Join Date
    Jun 2003
    Posts
    127

    Unanswered: Using cursor to move data

    Hello, I have source and target databases. I need to replace the data from a table in source db to a table in target db. The tables in both databases have the same name,schema,structure.
    The source db is cataloged on the target DB server. I plan to run this on the target server. Is this going to work?

    db2 "connect to target_db"

    db2 "DECLARE tb1.cursor CURSOR DATABASE source_db USER inst1 using inst1 for select * from schema1.tab1"


    db2 "LOAD FROM tb1.cursor OF cursor messages msg.cursor INSERT INTO schema1.tab1 NONRECOVERABLE"

    db2 connect reset


    Thanks
    Last edited by Kota; 08-04-15 at 00:19.

  2. #2
    Join Date
    Apr 2012
    Posts
    1,034
    Provided Answers: 18
    Hang on let me just look into my crystal ball

  3. #3
    Join Date
    Jun 2003
    Posts
    127
    That's very funny.

    My question was to confirm if it works when table names are identical.

  4. #4
    Join Date
    May 2012
    Location
    Canberra, Australia
    Posts
    176
    Provided Answers: 6
    Would have been faster if you had simply tried it. Yes it will work. I think the point is .... why wouldn't it work? You have two databases and are declaring the cursor for one and loading in to the other.
    Andy

    "All parts should go together without forcing. You must remember that the parts you are reassembling were disassembled by you. Therefore, if you can’t get them together again, there must be a reason. By all means, do not use hammer.” — IBM maintenance manual, 1975 "

  5. #5
    Join Date
    Jun 2003
    Posts
    127
    I understand what you are saying. I was playing safe since its a warehouse. My question was about identical tables. I was thinking about federated too. Anyway ended up completing it yesterday morning.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •