Open query file selecting records(qryslt)

470 pts.
Tags:
AS400/OPNQRYF
Open Query
Open Query File
Physical File
QRYSLT
V5R3
This is my Physical file 'EMPS' existing in library "TAMIL1" and its record format is 'EMPRCD"
a)its source is
R EMPRCD              
     ENO            4  0 
     ENAME         10    
     EADD          10  
b)The records present in EMPS are as follows
ENO   ENAME       EADD       
0001  tamil       coimbatore 
0002  kumar       bangalore  
0003  sunder      bangalore  
0004  arunkumar   chennai    
0005  pandi       hyderabad  
0006  santhosh    hyderabad  
0007  sasi        salem      
0008  kalai       chennai    
0009  suresh      hyderabad  
0010  vijay       bangalore  
0011  Arul        chennai    
0012  velu        chennai    
0013  khan        bangalore  
0014  praba       chennai    
0015  praba.p     coimbatore 
0016  anand       ooty       
0017  raja        erode      
0018  sankar      erode      
0019  vadivel     namakkal   
0020  anbu        chennai
0021  Ajith       mumabi  
c)now i want to select the 'ENAME' field  records starting with 'S'
for that i have created a RPG program
its source code is 
        PGM                                                                       
            DCLF       FILE(TAMIL1/EMPS)                                          
            DCL        VAR(&MYENO) TYPE(*CHAR) LEN(4)                             
            OVRDBF     FILE(EMPS) SHARE(*YES)                                     
            OPNQRYF    FILE((TAMIL1/EMPS)) QRYSLT('ENAME *EQ %WLDCRD("S *")')     
READ:    RCVF       RCDFMT(EMPRCD)                                             
            MONMSG     MSGID(CPF0864) EXEC(GOTO CMDLBL(END))                      
            CHGVAR     VAR(&MYENO) VALUE(&ENO)                                    
            SNDUSRMSG  MSG(&MYENO)                                                
            SNDUSRMSG  MSG(&ENAME)                                                
            SNDUSRMSG  MSG(&EADD)                                                 
            GOTO READ                                                             
END:      CLOF       OPNID(EMPS)                                                
            DLTOVR     FILE(EMPS)                                                 
            ENDPGM                                                                
Is this coding correct sir,the program gets compiled,and if i call it it says query running but records are not displayed.please help me out


Software/Hardware used:
V5R3
ASKED: December 8, 2010  8:17 AM
UPDATED: December 9, 2010  1:18 PM

Answer Wiki

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

Got it now — 2 things in the value S *
Your values are lower case s not upper case S
The values aren’t followed by a blank
To find that data change the compare value to s*
Phil
==
Great catch Phil
So you do not have to worry about case, you can use %XLATE
OPNQRYF FILE((TAMIL1/EMPS)) QRYSLT(‘%XLATE(ENAME QSYSTRNTBL) *EQ %WLDCRD(“S *”)’)
———————————–
Charlie
You missed the part about the space. Your code would find S or s followed by a space and any other characters. Take the space out and you’ve got it.

OPNQRYF FILE((TAMIL1/EMPS)) QRYSLT(‘%XLATE(ENAME QSYSTRNTBL) *EQ %WLDCRD(“S*”)’)

Phil

Discuss This Question: 3  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
  • Kaly
    ENAME,EADD and ENO are Fields in my Physical file 'EMPS"
    470 pointsBadges:
    report
  • philpl1jb
    Here is a discussion on this topic. http://itknowledgeexchange.techtarget.com/itanswers/getting-wildcard-results-from-opnqryf/ Your query looks good but I'm not sure if it will be in effect for the program that declairs it, but if it wasn't you should see all names. Should you specify where to send the user messages? Phil
    48,595 pointsBadges:
    report
  • Kaly
    thats great it works now,thank u phil and others for responding
    470 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