how can i use like in cl program?

5 pts.
Tags:
AS/400
CL Program
how can i write this statment in cl program? Q -   select name from empname where name like %@name% thanks

Software/Hardware used:
rpg as/400

Answer Wiki

Thanks. We'll let you know when a new response is added.

You can use QCLSCAN
Here is some code:
<pre>
/* used by QCLSCAN */

DCL VAR(&STRLEN) TYPE(*DEC) LEN(3)
DCL VAR(&STRPOS) TYPE(*DEC) LEN(3)
DCL VAR(&PATTERN) TYPE(*CHAR) LEN(1)
DCL VAR(&STAR) TYPE(*CHAR) LEN(1) VALUE(‘*’)
DCL VAR(&PATLEN) TYPE(*DEC) LEN(3) VALUE(1)
DCL VAR(&TRANSLATE) TYPE(*CHAR) LEN(1) VALUE(’1′)
DCL VAR(&TRIM) TYPE(*CHAR) LEN(1) VALUE(’1′)
DCL VAR(&WILD) TYPE(*CHAR) LEN(1) VALUE(’0′)
DCL VAR(&RESULT) TYPE(*DEC) LEN(3)
/*——————————————————————-*/
/* Find out to which group(s) message is to be sent. To do this, */
/* scan first ten positions of &LDA. Characters to left of ‘*’ are */
/* the group indicators. */
/*——————————————————————-*/
RTVDTAARA DTAARA(*LDA *ALL) RTNVAR(&LDA)
CHGVAR VAR(&STRLEN) VALUE(11)
CHGVAR VAR(&STRPOS) VALUE(1)

CALL PGM(QCLSCAN) PARM(&LDA &STRLEN &STRPOS &STAR +
&PATLEN &TRANSLATE &TRIM &WILD &RESULT)

/*——————————————————————-*/
/* If ‘*’ was in position 1, then there are no groups in *LDA */
/*——————————————————————-*/
IF COND(&RESULT *LE 1) THEN(GOTO CMDLBL(END))
/*——————————————————————-*/
/* QCLSCAN is an IBM provided utility that scans a string for a */
/* pattern. In this case, &MSGLIST is scanned for &PATTERN starting */
/* at position &STRPOS. If found, the position will be placed in */
/* &RESULT. If not found, &RESULT will be 0. */
/* For more info on QCLSCAN, refer to AS/400 CL Programmers Guide */
/* page 6-6 */
/*——————————————————————-*/</pre>

Discuss This Question: 2  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • TomLiotta
    ...select name from empname where name like %@name% Since CL is not enabled for SQL in the first place, you can't use SELECT except through some external function such as a QM query. And if you use a QM query, then that's where you would use LIKE. In that case, LIKE has no place in CL. Other than that, you use something like CharlieBrowne's suggestion. Tom
    125,585 pointsBadges:
    report
  • dinuas400
    In OPNQRYF there a field called QRYSLT there you can give the selection conditions..
    510 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following