IBM i (AS400) fans only ' How to read a TXT file in the IFS with SQL

WRKLNK IFS - Work with Object Links




In this post, I'm going to show how you can easily read a TXT file in IFS using SQL.


I create a file named divina.txt 

reading TXT file in IFS using SQL


and copy it to IFS.

IBM i Access Client Solutions

Here we can see the file divina.txt into IFS. I use ACS to show it.



WRKLNK IFS - Work with Object Links
Here we can see the file divina.txt into IFS. I use WRKLNK to show it.


WRKLNK (Work with Object Links) - Display file

Here we can see the file divina.txt into IFS. I use option 5=Display into WRKLNK (Work with Object Links).


I read it through SQL and write it to QTEMP/OUTFILE:

Execute this SQL command:
CREATE TABLE QTEMP.OUTFILE (RECORD) AS                           
              (SELECT CAST(LINE AS CHAR(50)) FROM TABLE          
                (QSYS2.IFS_READ('/home/VDOTEST/WSF/DIVINA.txt')))
              WITH DATA
QSYS2.IFS_READ


To display the QTEMP/OUTFILE file, type from the command line:
DSPPFM FILE(QTEMP/OUTFILE)
DSPPFM FILE(QTEMP/OUTFILE)




That's it.


I appreciate all the comments made on this blog.

Comments

  1. DSPF command can display file in IFS. What makes this different?

    ReplyDelete

Post a Comment

Popular posts from this blog

IBMi (AS400) fans only ' Efficient WRKSPLF with WSF - How to Search string into spooled files, Sort, and Generate PDFs on IBMi

IBMi (AS400) fans only - How to Sniff User Access

IBMi (AS400) fans only ' Detecting and Handling Non-Printable Characters in DB2 SQL Using LOCATE() and REPLACE() Functions