IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

SQL MERGE statement with INCLUDE clause


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Pedro

Global Moderator


Joined: 01 Sep 2006
Posts: 2547
Location: Silicon Valley

PostPosted: Sat Jun 16, 2012 4:20 am
Reply with quote

Right now, I am not using the INCLUDE clause and it more or less works. But on some instances of the name, I get a -433:

Code:
 DSNT408I SQLCODE = -433, ERROR:  VALUE TBOC7001_BASE IS TOO LONG


For that reason, I think I need to have an INCLUDE clause which will let me specify a data type of VARCHAR(128).

But I am not having luck with the correct syntax. Does anyone have an example of a SQL MERGE statement with the INCLUDE clause?
Back to top
View user's profile Send private message
Pedro

Global Moderator


Joined: 01 Sep 2006
Posts: 2547
Location: Silicon Valley

PostPosted: Sat Jun 16, 2012 4:30 am
Reply with quote

I finally read the manual.
Quote:
INCLUDE can only be specified when the
MERGE statement is nested in the FROM clause of a SELECT statement.


But how do I resolve my -433 problem? The NAME column is VARCHAR(128)


Code:
MERGE INTO PEDRO.TABLE1 AS A                                   
                                                                     
USING (                                                             
VALUES ( 168   ,'TB','QUOC7001','TBOC7001_BASE',''      ,'' )) AS B
       (SCOPEID,TYPE,QUALIFIER ,NAME           , COLNAME,AUTHLEVEL)                     
ON    A.SCOPEID  = B.SCOPEID                                         
AND  A.TYPE      = B.TYPE                                           
AND  A.QUALIFIER = B.QUALIFIER                                       
AND  A.NAME      = B.NAME                                           
WHEN NOT MATCHED                                                     
THEN                                                                 
INSERT( SCOPEID,   TYPE,   QUALIFIER,   NAME,   COLNAME,   AUTHLEVEL)
VALUES                                                               
     (B.SCOPEID, B.TYPE, B.QUALIFIER, B.NAME, B.COLNAME, B.AUTHLEVEL)
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Sat Jun 16, 2012 5:35 am
Reply with quote

Pedro,

can you INSERT a row into PEDRO.TABLE1 with
VALUES ( 168 ,'TB','QUOC7001','TBOC7001_BASE','' ,'' )
Back to top
View user's profile Send private message
Pedro

Global Moderator


Joined: 01 Sep 2006
Posts: 2547
Location: Silicon Valley

PostPosted: Tue Jun 19, 2012 4:12 am
Reply with quote

Found my problem... apparently the SQL parser wants a blank after a comma.

When all of the values are strung together, it causes some unpredictable results.
Code:
VALUES ( 168   ,'TB','QUOC7001','TBOC7001_BASE',''      ,'' )) AS B


Well, I could not predict it before. Maybe in the future.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts INCLUDE OMIT COND for Multiple values... DFSORT/ICETOOL 5
No new posts Merge two VSAM KSDS files into third ... JCL & VSAM 6
No new posts To search DB2 table based on Conditio... DB2 1
This topic is locked: you cannot edit posts or make replies. Merge 2 input files based on the reco... JCL & VSAM 2
No new posts Merge 2 input files after sort SYNCSORT 14
Search our Forums:

Back to Top