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

SQL Merge Statement


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

New User


Joined: 18 Aug 2008
Posts: 98
Location: India

PostPosted: Thu Oct 01, 2009 8:51 pm
Reply with quote

Hi
I am trying to use the MERGE to update a table.

Code:
MERGE INTO D1.TJAEREFERENCE B                             
USING D1.TJAECATALOGUE A                                 
ON                                                       
substr(A.TABLENAME,5,46) = substr(B.REFTBNAME,5,46)       
and A.REFINTGRTFLAG = 'Y'                                 
WHEN MATCHED THEN UPDATE SET                             
B.TLOTYPE = A.TLOTYPE                                     


But I am getting the error as below
Code:
DSNT408I SQLCODE = -104, ERROR:  ILLEGAL SYMBOL "D1". SOME SYMBOLS THAT MIGHT   
         BE LEGAL ARE: IS                                                       


Can some one please shed some light whats missing...
Back to top
View user's profile Send private message
Pandora-Box

Global Moderator


Joined: 07 Sep 2006
Posts: 1592
Location: Andromeda Galaxy

PostPosted: Fri Oct 02, 2009 12:19 pm
Reply with quote

Can you try removing all occurance of D1.
Back to top
View user's profile Send private message
tomehta

New User


Joined: 18 Aug 2008
Posts: 98
Location: India

PostPosted: Fri Oct 02, 2009 5:09 pm
Reply with quote

then system is looking for instance of table in my login id

same kinda result.
Back to top
View user's profile Send private message
Pandora-Box

Global Moderator


Joined: 07 Sep 2006
Posts: 1592
Location: Andromeda Galaxy

PostPosted: Fri Oct 02, 2009 5:24 pm
Reply with quote

Can you post the changed code?
Back to top
View user's profile Send private message
tomehta

New User


Joined: 18 Aug 2008
Posts: 98
Location: India

PostPosted: Fri Oct 02, 2009 6:39 pm
Reply with quote

MERGE INTO TJAEREFERENCE B 00000003
USING TJAECATALOGUE A 00000004
ON 00000005
A.TABLENAME = B.REFTBNAME 00000006
and A.REFINTGRTFLAG = 'Y' 00000007
WHEN MATCHED THEN UPDATE SET 00000008
B.TLOTYPE = A.TLOTYPE;;;;;; 00000009
Code:
---------+---------+---------+---------+---------+---------+---------+---------+
DSNT408I SQLCODE = -104, ERROR:  ILLEGAL SYMBOL "TJAEREFERENCE". SOME SYMBOLS   
         THAT MIGHT BE LEGAL ARE: IS                                           
DSNT418I SQLSTATE   = 42601 SQLSTATE RETURN CODE                               
DSNT415I SQLERRP    = DSNHPARS SQL PROCEDURE DETECTING ERROR                   
DSNT416I SQLERRD    = 502 0  0  -1  84  0 SQL DIAGNOSTIC INFORMATION           
DSNT416I SQLERRD    = X'000001F6'  X'00000000'  X'00000000'  X'FFFFFFFF'       
         X'00000054'  X'00000000' SQL DIAGNOSTIC INFORMATION                   
Back to top
View user's profile Send private message
dejunzhu

Active User


Joined: 08 May 2008
Posts: 390
Location: China

PostPosted: Sat Oct 03, 2009 1:53 pm
Reply with quote

Please consult the grammar of MERGE statement from <<SQL reference>>.

You can notice that obviously there is a grammar error on the 2nd line in your statement.

Keyword "VALUE" must be followed by "USING"!

Code:
USING D1.TJAECATALOGUE A 
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 Merge two VSAM KSDS files into third ... JCL & VSAM 6
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
No new posts JOIN STATEMENT PERFORMANCE. DFSORT/ICETOOL 12
No new posts Merge files with a key and insert a b... DFSORT/ICETOOL 6
Search our Forums:

Back to Top