ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

ODBC Service Program

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • ODBC Service Program

    Well, people have asked for this so I decided to make a new thread. I had hoped to complete this project but like so many things in life, I can't find the time. Maybe someone here will pick up where I left off, finish the project and make it one of the downloadeable items here on Code400.com.

    Attached are three source members: odbc.rpgle.txt, odbc_h.rpgle.txt and odbc_test.rpgle.txt. Upload all three to a source file on your iSeries. Preferrably qrpglesrc as these members reference copy members found in qrpglesrc. You can change that, obviously.

    Once uploaded, compile as follows:
    * Create an RPGLE module from odbc.rpgle (I just used option 15 from PDM without changing any command defaults)
    * Create a service program named ODBC from the module you just created. On my V5R3 machine I didn't have to specify any other service programs to get the ODBC service program to create. If you can't create on a pre-V5R3 machine you might need to specify service program QSQCLI on the CRTSRVPGM command. I used the following command:
    CRTSRVPGM SRVPGM(JONAS/ODBC) MODULE(JONAS/ODBC) EXPORT(*ALL)
    * Create an RPGLE module from odbc_test.rpgle (I just used option 15 from PDM without changing any command defaults)
    * Create program ODBC_TEST from the module you just created specifying BNDSRVPGM(ODBC). Command I used:
    CRTPGM PGM(JONAS/ODBC_TEST) MODULE(JONAS/ODBC_TEST) BNDSRVPGM(JONAS/ODBC)

    Now you're ready to run the test program. Before you do, ensure that you have a *LOCAL relational database directory entry. From a command line issue WRKRDBDIRE. You should see at least one entry and it should have *LOCAL as the remote location. If you don't see the *LOCAL entry you can add with option 1. The ODBC_TEST program uses the first entry on this screen as a test so it assumes the *LOCAL is first. If *LOCAL is not first you will have to change ODBC_TEST to connect to the appropriate DSN number.

    Now issue command: CALL ODBC_TEST
    This program will list the entries from WRKRDBDIRE and then attempt a connection to the first entry. Once it connects, it will run a "select" statement against table syscolumns and display the contents of colno and name from the first three records. It will then disconnect from the data source.

    I apologize that there is no documentation but if you look at odbc_test you should be able to figure out what's going on. My long range goal was to complete the service program (make all the SQLCLI functions available) and finish the documentation.

    The beauty about CLI is you can code SQL statements in your program and you DON'T need the SQL product installed on your machine.

    Have fun!

    Jonas
    Attached Files
    Jonas Temple
    Got FROG?
    Got Tadpole? No, because it's not done yet! Stay tuned....

    01010111 01100001 01110011 01110011 01110101 01110000 00100000 01100100 01101111 01100111 00111111
Working...
X