Embedded SQL in an RPG FREE program

30 pts.
Tags:
Embedded SQL
RPGILE
SQL
I am developing an on-line screen program, where the user can select a view of the data from a list of "views". This is my first crack at embedded SQL, Basically i issue the Prepare, declar the c1 scroll cursor, and then open c1, and then do the fetch. At this point I am loading the subfile. First view displays fine.. Then they go to the selection window and select a different view. At this point I - clear the subfile -close the cursor (c1) and go thru the same previoys steps, but the prepare is based on a select statement with a different LF view. I get data displayed, but it is not in the correct order as the LF, and I have found some records missing. Not sure if I am missing something. If there is a good web-site that I could go to for further info, that would be helpful. thanks. "
ASKED: March 25, 2009  5:17 PM
UPDATED: March 26, 2009  3:25 PM

Answer Wiki

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

Yes – you’ve missed something.
Your Select statement needs an Order By clause.
You may not need seperate Views — views aren’t, by the way, Logical files.
You shouldn’t need to use LF’s at all. The SQL-Query engine will find the best index.
You may find your performance needs you to create indexes.
Records missing – does the LF have and omit or select clause.

Phil

Discuss This Question: 1  Reply

 
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
  • Koohiisan
    All of the criteria should usually be in the select statement for sure. When I first started with embedded SQL, I had a few times where my results were not what I had expected as far as records not being omitted as the logical specified. Basically, the query engine takes what you request as a 'suggestion', notes it, and then picks whatever it thinks best satisfies your SQL statement. I put logicals in my select statements to appease those in my realm that are not up to snuff on SQL and would be otherwise frightened. Typically I go to an interactive SQL session while in debug and run my statements there just to check the job log to see what the query engine is actually picking.
    5,020 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