AS400- RPG-SQL Select statement Issue

Hi
I have query regarding SQL statement which i need to use where from file is flat file and i need to extract records from that Flat file based on values in position 15th = 'X'
As below
Select * from Flatfile where Flatfile (position 15th = 'X') Is it possible?

or

Is it possible from below Code?
CPYF       FROMFILE(&flib/Flat file)
           TOFILE(&flib/File2) MBROPT(*ADD)
           INCREL((*IF Flatfilefield *EQ 'C'))  

Please guide .
Andy
Andy400Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Gary PattersonVP Technology / Senior Consultant Commented:
Sure.

SQL method

Use DSPFFD to determine the name of single the flatfile data field (If it was created without DDS via CRTPF, for example, the field name is the same as the file name):

select * from flatfile where substring(dataFieldNameGoesHere,15,1) = "X"
CPYF method

CPYF FROMFILE(FLATFILE)      
     TOFILE(NEWFILE)  
     INCCHAR(*RCD 15 *EQ 'X')
- Gary Patterson


0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Andy400Author Commented:
Thanks a lot!
0
Gary PattersonVP Technology / Senior Consultant Commented:
Happy to help.

- Gary
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Mainframe Languages

From novice to tech pro — start learning today.