Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

CONVERT a field table in a SELECT statement

Former Member
0 Likes
9,126

Hi all,

I have the follow SELECT statement:

SELECT SINGLE * FROM table1 INTO wa1

WHERE

field1 = var1;

The problem is that field1 DataType is CHAR10 and var1 DataType is I. So if field1 contains '0123' and var1 = '123' the SELECT fails.

Is there any way to consider field1 as an Integer?

Best Regards,

Raffaele

Hi all,

I have the follow SELECT statement:

SELECT SINGLE * FROM table1 INTO wa1

WHERE

field1 = var1;

The problem is that field1 DataType is CHAR10 and var1 DataType is I. So if field1 contains '0123' and var1 = '123' the SELECT fails.

Is there any way to consider field1 as an Integer?

Best Regards,

Raffaele

4 REPLIES 4
Read only

Former Member
0 Likes
3,971

No, but you could move var1 to a type n variable to get the leading zeros and then compare with that variable

Read only

0 Likes
3,971

No, but you could move var1 to a type n variable to get the leading zeros and then compare with that variable

It doesn't work because I don't know how many zeros are in the field1.

Best Regards,

Raffaele

Read only

Former Member
0 Likes
3,971

hi,

do this way ..Convert it to char data type


data : var1 like table1-field1 value '0123'.

SELECT SINGLE * FROM table1 INTO wa1
WHERE
field1 = var1. 

Read only

Former Member
0 Likes
3,971

use the FM : CONVERSION_EXIT_ALPHA_OUTPUT to quit the zeros of any variable.

example

if u have 000945

after call FM u obtain only 945