× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



GUY_HENZA@xxxxxxxxxxxxxx wrote:
It was the $ that needed to be proceeded by a \.

Glad you figured this out, Guy.

Just in case it's interesting to someone... the $ symbol in Qshell represents a variable. So you could potentially do this:

db2 "select custno,custnm,addr from $lib.custmas where custno=$custno"

It would insert the value of the "lib" environment variable, and the value of the "custno" environment variable in the appropriate places in the SQL statement.

In CL programming terms that's not as useful as it would be in an actual Unix script, since you're building the command on-the-fly from variables in your code anyway. However, if you want to try it from CL, you could do something like this:

PGM

DCL VAR(&CUSTNO) TYPE(*CHAR) LEN(4) VALUE('1234')
DCL VAR(&LIB) TYPE(*CHAR) LEN(10) VALUE('FILELIB')

ADDENVVAR ENVVAR(custno) VALUE(&CUSTNO) REPLACE(*YES)
ADDENVVAR ENVVAR(lib) VALUE(&LIB) REPLACE(*YES)

STRQSH CMD('db2 "select custno,custnm,addr from $lib.custmas +
where custno=$custno"')

ENDPGM

QShell will insert the values set with ADDENVVAR into your SQL statement. Environment variables ARE case-sensitive, so if you try to use my code, above, be sure to use "lib" and "custno" instead of "LIB" or "CUSTNO".


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.