INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Help Debugging an Update Statement with an Inner Join

Help Debugging an Update Statement with an Inner Join

Help Debugging an Update Statement with an Inner Join

(OP)
Hi everyone ...

I'm hoping you guys can offer some guidance.

My update query doesn't seem to work.  I'm using QMF to interact with DB2 v9 on z/OS.  I typically stick to select statements so I'm a bit out of my element.  Here is what I've got:

CODE

    UPDATE TABLE1   A           
INNER JOIN TABLE2   B           
        ON A.1_PROC_NUM  = B.2_PROC_NUM
       AND A.BUS_ID      = B.BUS_ID      
       SET A.1_PROC_NUM  = B.2_PROC_NUM,
           A.1_CTRY_CD   = B.1_CTRY_CD,
           A.1_CTRY_NM   = B.1_CTRY_NM,
           A.1_REGN_CD   = B.1_REGN_CD,
           A.1_REGN_NM   = B.1_REGN_NM;

The error message I get is DSQ17199, which seems to be generic and rather unhelpful.  I think it has to do with the inner join.

Anyone have any ideas?

Many thanks in advance ...

ks01

RE: Help Debugging an Update Statement with an Inner Join

db2 is a pain on its updates.

try

CODE

    UPDATE TABLE1   A           
       SET (
            A.1_PROC_NUM  
           ,A.1_CTRY_CD   
           ,A.1_CTRY_NM   
           ,A.1_REGN_CD   
           ,A.1_REGN_NM
           ) = (
                select B.2_PROC_NUM
                      ,B.1_CTRY_CD
                      ,B.1_CTRY_NM
                      ,B.1_REGN_CD
                      ,B.1_REGN_NM
                FROM TABLE2 B
               WHERE A.1_PROC_NUM  = B.2_PROC_NUM
                 AND A.BUS_ID      = B.BUS_ID
               )
WHERE EXISTS (
              SELECT 1
                FROM TABLE2 B
               WHERE A.1_PROC_NUM  = B.2_PROC_NUM
                 AND A.BUS_ID      = B.BUS_ID
             )

 

Regards

Frederico Fonseca
SysSoft Integrated Ltd
www.syssoft-int.com

FAQ219-2884: How Do I Get Great Answers To my Tek-Tips Questions?
FAQ181-2886: How can I maximize my chances of getting an answer?

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close