× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Hi Buck,

Sounds great !

Looking forward to when our systems are upgraded to the point I can use
function PARSE_STATEMENT. I've got some great uses lined up for it as well.

Mike

On Tue, Mar 7, 2017 at 2:26 PM, Buck Calabro <kc2hiz@xxxxxxxxx> wrote:

I wrote an internal CL command that takes an SQL SELECT statement and
populates an XLSX spreadsheet file.
CMD -> CLP -> PASE -> Python -> Python script

It was quite easy; I had the general notion stubbed out and working with
print statements within minutes. pip install xlsxwriter worked a treat.
Working through the details took most of a day and that includes testing.

The Python script uses ibm_db to access DB2 for i. I used the new DB2
service UDTF qsys2.parse_statement() to extract the column names to be
used as the heading row. For 'select *' statements, this returns zero
columns, but the ibm_db2.columns() function will get the column names
from the table itself.

Error handling is very minimal; it's a tool that probably only I will use.

I was going to say that finding the documentation was kind of a pain,
but it's such a new domain to me that I can't judge until I've got used
to the new idiom.

Mixing CLP, Python, DB2, Excel, and the new DB2 services was very easy.
The only thing I wanted to do but didn't was to feed the exit code back
from Python to the CLP.

Altogether, quite a pleasant experience. I really like the short
feedback loop of an interpreted language.

--
--buck

Try wiki.midrange.com!

--
This is the IBMi Open Source Roundtable (OpenSource) mailing list
To post a message email: OpenSource@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/opensource
or email: OpenSource-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/opensource.


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.