View previous topic :: View next topic |
Author |
Message |
mcclr Beginner
Joined: 10 Jan 2006 Posts: 11 Topics: 4
|
Posted: Tue Jul 24, 2007 1:20 pm Post subject: Need to convert numeric field to char in Rexx exec |
|
|
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 |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
|
Posted: Tue Jul 24, 2007 2:08 pm Post subject: |
|
|
mcclr,
when you say NUMERIC is the data left justified ? ie.
Kolusu _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
 |
mcclr Beginner
Joined: 10 Jan 2006 Posts: 11 Topics: 4
|
Posted: Tue Jul 24, 2007 2:36 pm Post subject: |
|
|
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 |
|
 |
dbzTHEdinosauer Supermod
Joined: 20 Oct 2006 Posts: 1411 Topics: 26 Location: germany
|
Posted: Tue Jul 24, 2007 3:30 pm Post subject: |
|
|
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 |
|
 |
s_shivaraj Beginner

Joined: 21 Sep 2004 Posts: 140 Topics: 14 Location: Chennai, India
|
Posted: Tue Jul 24, 2007 3:41 pm Post subject: |
|
|
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 |
|
 |
expat Intermediate

Joined: 01 Mar 2007 Posts: 475 Topics: 9 Location: Welsh Wales
|
Posted: Wed Jul 25, 2007 2:40 am Post subject: |
|
|
Deleted, erroneous reply posted |
|
Back to top |
|
 |
dbzTHEdinosauer Supermod
Joined: 20 Oct 2006 Posts: 1411 Topics: 26 Location: germany
|
Posted: Wed Jul 25, 2007 3:28 am Post subject: |
|
|
s_shivaraj,
good thinking, great post! _________________ Dick Brenholtz
American living in Varel, Germany |
|
Back to top |
|
 |
|
|