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

Sql problem with LIKE in WHERE: sqlcode +100


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

New User


Joined: 03 May 2005
Posts: 4
Location: Pune

PostPosted: Fri Mar 23, 2007 5:36 pm
Reply with quote

Hi there,
I have one problem in COBOL-DB2 -CICS program with LIKE in WHERE clause.This sql runs in SPUFI with hardcoded value but in program it is giving sqlcode +100.
The column in where clause is char(26) and has values like
'SCMTA 20070226093602001' .I want to ignore last 3 digit( i.e. 001) in sql. So value of WS-APLCN should be 'SCMTA 20070226093602%'. OR 'SCMTA 20070226093602&&&'
Please suggest .....

EXEC SQL
UPDATE mytable name
SET column-name = '99'
WHERE column name LIKE :WS-APLCN
END-EXEC.


Pankaj
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Fri Mar 23, 2007 5:42 pm
Reply with quote

Isn't there a substring function you could use?
Back to top
View user's profile Send private message
vini_srcna

Active User


Joined: 26 May 2005
Posts: 178
Location: Copenhagen, Denmark

PostPosted: Mon Mar 26, 2007 10:07 am
Reply with quote

I believe the host variable value is not populated correctly in the run time.
Make sure % wild char is in place before the execution.

This would not be an efficient method, Instead you can use the bulit in function SUBSTR as suggested by William.

Try this:
EXEC SQL
UPDATE mytable name
SET column-name = '99'
WHERE SUBSTR(colname,1,23) = :WS-APLCN
END-EXEC.

In this case WS-APLCN can have the value 'SCMTA 20070226093602' .
I mean no need for wild char's. Hope this helps. Thanks
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 Map Vols and Problem Dataset All Other Mainframe Topics 2
No new posts z/vm installation problem All Other Mainframe Topics 0
No new posts Job scheduling problem. JCL & VSAM 9
No new posts Problem with IFTHEN=(WHEN=GROUP,BEGIN... DFSORT/ICETOOL 5
No new posts Need to add field to copybook, proble... COBOL Programming 14
Search our Forums:

Back to Top