SQL table in RPG

170 pts.
Tags:
RPG
SQL
SQL tables
I need to read an SQL table (file) in RPG and select certain records. I'm pretty green in SQL. Anyone have a sample they could share? I'm better at RPG than ILE but I'll take what I can get. Thanks!

Answer Wiki

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

You might also find this site useful.
Good Luck!
-Flame

Discuss This Question: 5  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
  • ToddN2000
    It depends on where you table is stored. Is it on a server or on the i-Series? If on the i-series, type STRSQL at a command line. then SELECT FLD1,FLD2 from LIBRARY/FILENAME  then optionally you can add a sort by typing ORDER BY FLD1 in the same command prompt.
    15,605 pointsBadges:
    report
  • deepu9321
    If you would like to read the file (created through SQL) in RPG, You can define it on F - Spec like how you use to define External Files (PF/LF) on F - Spec.

    And, Read through the file using READ Opcode.

    Pradeep.
    4,290 pointsBadges:
    report
  • hunshabbir7
    I think his table resides on SQL Server and he wants to fetch data in RPG code. If this is the case then ToddN2000 can help you better.

    Thanks
    2,630 pointsBadges:
    report
  • deepu9321
    If this is the case, First you should establish the SQL Connection from RPG program using embedded SQL Connect Statement.

    Then, You would be able to perform SELECT Query on your SQL Table.

    Pradeep.
    4,290 pointsBadges:
    report
  • ToddN2000
    Can you can provide a little more on the specifics, like where the file is your are trying to read from, are you trying to read it in RPG or from an embedded SQL query.  This way we can give a more accurate response.
    15,605 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