(IBM i fans only) Extracting Data from DB2 to Excel with ODBC




Configuring ODBC is the first crucial step to enable data transmission between your PC and the IBMi server (AS400).


In my example, I am using the Windows 10 operating system and want to extract data from the public IBMi server PUB400.COM. However, make sure to configure ODBC to point to your specific IBMi environment.


ODBC Configuration on Windows:


1. Open "ODBC Data Sources" in either 32-bit or 64-bit (in my case, 64-bit).

2. Select "iSeries Access ODBC Driver" and click "Add".




**Data Source:** Specify the data source name.



3. Fill in the nine configuration tabs:


- **Server:** Indicate the address of your IBMi server.


   


- **Libraries:** List the libraries containing the files you want to access.

























4. Once the tabs are filled, click "Apply" and "OK".


Extracting Data to Excel:

1. Open Excel.
2. Go to "Data" and then "Get Data".




3. Select "From Other Sources" and choose "From Microsoft Query".





3b. In other Excel version: Select "Legacy Wizard" and choose "From Microsoft Query (legacy)".







4. Select the ODBC data source and click "OK".





5. Choose the file to read (in my case, C00X00F) and click ">".






6. Proceed by clicking "Next" until the process is complete.








7. Click "Finish" and then "OK".


333

The C00X00F file is now imported into Excel.



C00X00F Record Layout:

Here is the structure of the C00X00F record:



C00X00F Record Format (Phisical File Description):

Content of C00X00F on IBMi:

You can view the content of C00X00F using "Display Physical File Member" on IBMi.






Let me know if you encountered any difficulties while implementing ODBC and reading files from DB2.

Every feedback is highly appreciated
!


Comments

  1. Thank you Aldo for this "treasure"!
    But to thanks Holger Scherer is better to say is his "baby" more than public server, don't you think? 😉

    ReplyDelete
    Replies
    1. You're absolutely right! PUB400 is more like Holger Scherer's 'brainchild' than just a public server. Let’s say it’s a public service with a personal touch! 😉 Big thanks to Holger for keeping it running for all of us!

      Delete
  2. Thank you for this very useful information!
    But don't you think that is better to say the server is from Holger Scherer more than public? 😉
    I wonder if is possible to adapt to an IBM Z DB2?

    ReplyDelete
    Replies
    1. Good question! While IBM i and IBM Z are like distant cousins in the IBM family, both speaking DB2, aren't they?

      Delete

Post a Comment

Popular posts from this blog

(IBM i fans only) How to Sniff User Access

(IBM i fans only) Detecting and Handling Non-Printable Characters in DB2 SQL Using LOCATE() and REPLACE() Functions