Cal I load a record SET into a work file using SQL within RPGLE?

940 pts.
Tags:
RPGLE
SQL
ALL -

I have to process a set of Inventory Transactions based on W/H, Product, From Date, and To Date. Normally, I would jump into a Do Loop; read the SQL cursor; write the record to a work file; process until EOF.

Can an SQL statement do all of that for me in one statement? I have not been able to do it in Interactive SQL.

Phil

Answer Wiki

Thanks. We'll let you know when a new response is added.

Hay Other Phil
INSERT INTO MYLIBRARY/TEMPF0101 SELECT * FROM DATALIB/F0101 WHERE ABAC02=’ABC’
This format request that you fill all fields of TEMPF0101 in order with fields from the select statement

Paul Conte pg 122 adds a field list — only field1,2,3 will be populated — others default or null.

Insert into file1 (field1, field2, field3)
Select xfield1, xfield2, xfield3 from xfile where ….

Hope this helps
Phil

EXCELLENT!
I just check the SQLCOD for problems.
0000 = no problems.
0100 = no rows satisfy the statement.

Now, some where in the SQL Communications area is the number of records processed.
Any Ideas?

The Other Phil

=======================
Phil
Great question — how would I solve it
Add H debug(*YES) and right after the sql command put Dump
You should see the anwer somewhere in the SQL stuff in the Dump
Let me know the answer.

The other Phil — go Cards

=======================
Good idea.
I have most of the above code in a sub-procedure I use to check the SQLCOD status after I exec a statement.

And the winner is:
SQLERRD(3)
The number of rows updated, inserted, or deleted by SQL.

<a href=”http://publib.boulder.ibm.com/infocenter/iseries/v5r4/topic/rzajp/rzajperrtncd.htm”>
Handling SQL error return codes using the SQLCA /A]

The Other Phil
Cards? WHO?

Discuss This Question:  

 
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

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