Like in SQLRPGLE

255 pts.
Tags:
AS/400
RPG
SQLRPGLE

Hi, I am using the below query in SQLRPGLE

 Select count(data) into :cntrec from sample where data like '%' "+:tpnumber+" '%'. I am getting an error "Token "+:tpnmber+" was not valid" .

The tpnumber is a character field(10a). Sample file is a flat file

I even tried '%' +:tpnumber+" '%' and '%' '+:tpnumber+' '%'

 

What should be the correct format?

Answer Wiki

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

LIKE ‘%’ concat Trim(:INPO) concat ‘%’

Discuss This Question: 5  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
  • ToddN2000

    You may need to use the concat as well. We do something similar here to select po using the LIKE.

    OHSPO# LIKE '%' concat Trim(:INPO) concat '%'
    15,605 pointsBadges:
    report
  • TomLiotta
    What is the definition of ":tpnumber"? And what are some likely values that would be in that variable? Without knowing definitions of variables that are used, it's not possible to know for certain why this is a problem. I have a probable guess, but it'd be much easier to explain if I had details to demonstrate. -- Tom
    125,585 pointsBadges:
    report
  • Prashanth123

    D tpnumber    S 10a

    This variable will contain values like T000756701

    255 pointsBadges:
    report
  • TomLiotta
    Okay, we'll come back to that a little later. Now, please show the actual source statements from the program. A SQL statement cannot stand by itself; it must be within a EXEC-SQL statement. So, show a copy of the actual source. Your quote marks don't make sense the way that you have them, but I don't know what should be done until I can see what you're doing with the SELECT statement. -- Tom
    125,585 pointsBadges:
    report
  • Prashanth123

    Tom,

    Sorry for the delay.

    /Exec- Sql

    Select count(data) into :cntrec from sample where data like  '%' concat Trim(:tpnumber) concat '%'

    /End

    This is the only statement under Exec sql. Since it is a char field I gave the double quotes.

    The conditon given by Todd worked.:)

     

    255 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