MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Need to convert numeric field to char in Rexx exec

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> TSO and ISPF
View previous topic :: View next topic  
Author Message
mcclr
Beginner


Joined: 10 Jan 2006
Posts: 11
Topics: 4

PostPosted: Tue Jul 24, 2007 1:20 pm    Post subject: Need to convert numeric field to char in Rexx exec Reply with quote

We are reading in a file that contains 10 bytes of data that is all numeric in column 1. We are using DSNREXX to issue a DB2 select statement with this variable in the WHERE clause.
SELECT NAME FROM TABLE1 WHERE KEY = "inputfield"
KEY is defined in the table as a 10 byte character field. The datatype of the variable that Rexx creates is numeric. This causes the select to receive a -301 SQL error. Is there a way to cause the 'inputfield' in Rexx to be character instead of numeric?
Thanks, Larry
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Tue Jul 24, 2007 2:08 pm    Post subject: Reply with quote

mcclr,

when you say NUMERIC is the data left justified ? ie.

Code:

1         
0000000001


Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
mcclr
Beginner


Joined: 10 Jan 2006
Posts: 11
Topics: 4

PostPosted: Tue Jul 24, 2007 2:36 pm    Post subject: Reply with quote

Kolusu,
Not necessarily. It seems to create a numeric variable whether it is left justified or not.
Example:
Code:

/*  REXX   */                   
a = '       123' 
b = 123                         
c = '123'                       
say 'a = ' datatype(a)           
say 'b = ' datatype(b)           
say 'c = ' datatype(c)           

Response:
Code:

a =  NUM
b =  NUM
c =  NUM
Back to top
View user's profile Send private message
dbzTHEdinosauer
Supermod


Joined: 20 Oct 2006
Posts: 1411
Topics: 26
Location: germany

PostPosted: Tue Jul 24, 2007 3:30 pm    Post subject: Reply with quote

you can use BBcode to preserve your spacing - creates CODE blocks

could try

characters_for_sql = FORMAT(char_pos_1_to_10,10)
_________________
Dick Brenholtz
American living in Varel, Germany
Back to top
View user's profile Send private message
s_shivaraj
Beginner


Joined: 21 Sep 2004
Posts: 140
Topics: 14
Location: Chennai, India

PostPosted: Tue Jul 24, 2007 3:41 pm    Post subject: Reply with quote

mcclr,
Quote:
KEY is defined in the table as a 10 byte character field.

Dont you concatenate with Quotes since the key field is char.
For Example

Code:
VAR = 10;
STR = "'"VAR"'";


Use this STR IN YOUR query , i think this should Help you.
_________________
Cheers
Sivaraj S

'Technical Skill is the Master of complexity, while Creativity is the Master of Simplicity'
Back to top
View user's profile Send private message AIM Address
expat
Intermediate


Joined: 01 Mar 2007
Posts: 475
Topics: 9
Location: Welsh Wales

PostPosted: Wed Jul 25, 2007 2:40 am    Post subject: Reply with quote

Deleted, erroneous reply posted
Back to top
View user's profile Send private message
dbzTHEdinosauer
Supermod


Joined: 20 Oct 2006
Posts: 1411
Topics: 26
Location: germany

PostPosted: Wed Jul 25, 2007 3:28 am    Post subject: Reply with quote

s_shivaraj,

good thinking, great post!
_________________
Dick Brenholtz
American living in Varel, Germany
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> TSO and ISPF All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group