AS/400: Fetch data from file

700 pts.
Tags:
AS400 - Embedded SQL
I need to fetch the data from a file and write into another file. What is the best way to do that? I have an SQL query which has a number of conditions. I need to put this SQL query into a program.

Software/Hardware used:
software

Answer Wiki

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

Discuss This Question: 8  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
  • ravula
    i tried to do with the Open query file with rcdslt and CPYFRMQRYF but this sql querie has "like" and not able to use it
    700 pointsBadges:
    report
  • ravula
    i need to create this program schedule a job which runs at particular time.please help me in this thanks in advance
    700 pointsBadges:
    report
  • philpl1jb
    I would put my SQL into a member of a source file -- usually QSQLSRC -- member type TXT And create a CL with the RUNSQLSTM command -- set the commitment control to *NONE
    50,860 pointsBadges:
    report
  • ravula
    SQL9010 received by procedure CL2700,Below is the sql txt i used for RUNSQLSTM SELECT M$NACI, M$NADT, M$DARI FROM d502087810/J$SCMS@ WHERE ( M$NACI like ('_8%') or M$NACI like ('_1%') or M$NACI like ('_2%') or M$NACI like ('_4%') or M$NACI like ('_3%') or M$NACI like ('_5%') or M$NACI like ('_9%')) and M$NACI not like ('% ') and M$DARI not in ('INACTIVE') and M$DUARI not in ('INACTIVE') ORDER BY M$NACI please advice me
    700 pointsBadges:
    report
  • philpl1jb
    You might have gotten a spool file with details .. SQL9010 30 RUNSQLSTM command failed. Doesn't tell us much .. I think that you may have wanted an INSERT INTO TofileName followed by your select clause..
    50,860 pointsBadges:
    report
  • TomLiotta
    Yes, RUNSQLSTM cannot process a simple SELECT statement. It needs to be a sub-select that tells a different statement what rows to process. Most likely that would be an INSERT rather than a simple SELECT. . A SELECT statement doesn't actually do anything with rows from a table. It simply 'selects' the rows. . Tom
    125,585 pointsBadges:
    report
  • ravula
    Thank you all i am able to achive this with ought RUNSQLSTM,but able to achive this through 2 processes . 1STRQMQRY 2embedded sql
    700 pointsBadges:
    report
  • TomLiotta
    SQL can run a statement like this:
       INSERT INTO MyFile2 SELECT * FROM MyFile1
    The INSERT inserts all rows SELECTed from MyFile1. The SELECT statement is a "subselect". It's not a statement by itself.
    .
    In that form, it can be placed into a RUNSQLSTM source member.
    .
    The SELECT can have a WHERE clause if you want to only copy some of the rows. It could use a GROUP BY clause if you wanted to put summary rows into MyFile2. If you need to have variables to change parts of the statement, then you would use STRQMQRY instead of RUNSQLSTM.
    .
    In short, it seems that you don't need both RUNSQLSTM and STRQMQRY. You should be able to use just one or the other and get it done in a single INSERT statement that uses a sub-select.
    .
    Tom
    125,585 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