Compare strings in bteq statement, not in sql

Database
Enthusiast

Compare strings in bteq statement, not in sql

Hi,

i have a bteq statement and depending on the unix environment variable ${JOB_ENV} i want to skip to a lable

bteq < EOF

${LOGON};

.label A

----------

...

.if errorlevel <> 0 then .quit 1

.if '${JOB_ENV}' = 'tst' then .goto C

.label B

----------

...

.label C

----------

.....

I get this error on running (unix variable JOB_ENV is set to 'tst')

   .if 'tst' = 'tst' then .goto C

 *** Error: Did not recognize the variable ''.

How can i do string comparison at .if statement without having to do in a sql statement?

Thanks,

-srinivas yelamanchili

Tags (2)
5 REPLIES
Senior Supporter

Re: Compare strings in bteq statement, not in sql

Will not work this way. According to the BTEQ manual (see attached jpg)

.if is limited to conditions on ERRORCODE, ERRORLEVL and ACTIVITYCOUNT.

So you can't compare strings as you like.

Senior Supporter

Re: Compare strings in bteq statement, not in sql

You might use the following

select 'OK' from sys_calendar.calendar where calendar_date = current_date and 'tst' = '${JOB_ENV}';

.if Activitycount = 1 then .goto C

Enthusiast

Re: Compare strings in bteq statement, not in sql

i need to check in BTEQ like

Select length(Employee_Name) from Employee where Employee_id=155;

but length is not working, is there any way to calculate the string length.

Length is ODBC commend.

Please guide me

Enthusiast

Re: Compare strings in bteq statement, not in sql

try with char(Employee_Name)...

Enthusiast

Re: Compare strings in bteq statement, not in sql

ok I found solution like

Select char_Length(Employee_name) from where Employee_id=155;

this way its working