IBM i (AS400) fans only ' How to read a TXT file in the IFS with SQL
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
and copy it to IFS.
Here we can see the file divina.txt into IFS. I use ACS to show it.
Here we can see the file divina.txt into IFS. I use WRKLNK to show it.
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
To display the QTEMP/OUTFILE file, type from the command line:
DSPPFM FILE(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
To display the QTEMP/OUTFILE file, type from the command line:
DSPPFM FILE(QTEMP/OUTFILE)
That's it.
I appreciate all the comments made on this blog.
I appreciate all the comments made on this blog.
DSPF command can display file in IFS. What makes this different?
ReplyDelete