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

Problem using DIGITS() and SUBSTR()


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

New User


Joined: 02 Jun 2008
Posts: 6
Location: Ottawa, Canada

PostPosted: Mon Jun 23, 2008 8:18 pm
Reply with quote

Folks, I got a rookie problem with SQL. I have an SQL query with the following statement: icon_confused.gif

SUBSTR(DIGITS(b.SIN),2,9) where the SIN is an INTEGER field that I need to extract the 9 digits - hence the 2,9.

Problem is that the output from this has leading characters ".&" (quotes added for clarity).

.&114172661

The leading characters are the problem. I have knowledge of functions like CHAR() from my days working with SQL SERVER and RDBMS, JCL on the HP and VAX.

I was thinking about replacing the SUBSTR(DIGITS( functions with a CHAR statement like this: CHAR(b.SIN,2,9)

Would this solve the problem? Your sage advice and wisdom would be gratefully appreciated. Jon icon_redface.gif
Back to top
View user's profile Send private message
ashimer

Active Member


Joined: 13 Feb 2004
Posts: 551
Location: Bangalore

PostPosted: Mon Jun 23, 2008 8:26 pm
Reply with quote

DIGITS function can take SMALLINT, INTEGER or DECIMAL as argument..

y dont you try SUBSTR(CHAR(b.SIN),3,9) to get the 9 digits after omitting ".&" ??
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 Want to mask Middle 8 Digits of Debit... COBOL Programming 3
No new posts Job scheduling problem. JCL & VSAM 9
No new posts Problem with IFTHEN=(WHEN=GROUP,BEGIN... DFSORT/ICETOOL 5
Search our Forums:

Back to Top