Dynamic SQL in RPGLE

10 pts.
Tags:
RPG
RPGLE
SQL
I am building a dynamic SQL in RPGLE with a wildcards. It does not work like a native SQL statement. A search for "FRANK" will search on 6 characters (retrieve all the FRANK and the FRANKL, but not the FRANKLIN). A search on "FRANKL" will retrieve the FRANKL and the FRANKLIN. Any help would be greatly appreciated.


Software/Hardware used:
IBM Power 7
1

Answer Wiki

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

It may be your code is off.. 

Here is a sample of code we use when looking up orders by PO#.
C/EXEC SQL                                                          
C+    DECLARE OHBPO CURSOR FOR                                      
C+       SELECT OHORD#, OHBTKY, OHSPO#, OHENTD, OHHOLD, OHFF3, OHSM 
C+       FROM  OH                                                   
C+       WHERE OHHOLD = 'E' AND OHFF3 <> ' '                        
C+       AND OHSPO# LIKE '%' concat Trim(:INPO) concat '%'          
C+          AND OHBTKY = :INCUST                                    
C/END-EXEC
:INPO is our screen parameter                                                          

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.
  • carlosdl
    When some code you have tried doesn't work, make sure to post the code you tried, so others can take a look and tell you what they think is wrong.
    84,580 pointsBadges:
    report
  • JDroke
    I think the trick is that the field with the wildcard needs to be defined as varying length.
    80 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.

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

Following

Share this item with your network: