Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Turn variable into a string 1

Status
Not open for further replies.

kaeserea

Programmer
Feb 26, 2003
164
0
0
DE
Hello!

I set a variable by adding values. Thus it is an integer. But later on I need it as a string. How can I convert it into a string?

Here's the code:
[tt]
-SET &MONAT1 = IF &MONAT GE '02'
- THEN &MONAT -1
- ELSE &MONAT + 11;
[/tt]

(where &MONAT is given by the user in a prompt)

Later I use it in a WHERE statement:
[tt]
WHERE MONAT EQ '&MONAT' OR MONAT EQ '&MONAT1'
[/tt]

The part OR MONAT EQ '&MONAT1' is not considered (the data is present in the database). I used also OR MONAT EQ &MONAT1 but then I get the error message
"(FOC280) VERGLEICH ZWISCHEN ZIFFERN UND BUCHSTABEN NICHT MÖGLICH"
which translates into comparison between numbers and characters is not possible. That's why I'd like to have the variable &MONAT1 as a string.

Eva
 
Eva,

Firat question is, what format is the field MONAT? If alpha, then you need quotes around the literals; if numeric, then the quotes should be removed.

If that doesn't resolve the issue, try putting parentheses around each comparison, like this:

WHERE (MONAT EQ '&MONAT') OR (MONAT EQ '&MONAT1')
 
Try this. I'm not sure it works but it should.

WHERE (MONAT EQ EDIT(&MONAT)) OR (MONAT EQ EDIT(&MONAT1))


The simple EDIT() (with no mask) turns numeric to character and vice-versa. Not sure if it works with &parameters.
 
Eva,

if you're still having difficulty, try

WHERE MONAT EQ '&MONAT.EVAL' OR MONAT EQ '&MONAT1.EVAL';

I don't know the exact rules for using .EVAL but it's always the first thing I try when errors like this occur.
 
Eva,

What the FOCWIZARD is telling you is that &MONAT and &MONAT1 are already strings. Thus, if the field MONAT is a number, you statement should read;

WHERE (MONAT EQ &MONAT) OR (MONAT EQ &MONAT1);

If the field MONAT is alphanumeric, your statement should be:

WHERE (MONAT EQ '&MONAT') OR (MONAT EQ '&MONAT1');

The parentheses are not necessary, but I think they clarify the logic. Neither 'EDIT' nor 'EVAL' add anything to your situation.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top