AS400- RPG-SQL Select  statement Issue

Andy400
Andy400 used Ask the Experts™
on
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
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
VP 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


Author

Commented:
Thanks a lot!
Gary PattersonVP Technology / Senior Consultant

Commented:
Happy to help.

- Gary

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial