Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: How to collect output of DB2 query run interactive mode using perl script

by Corion (Patriarch)
on Aug 01, 2022 at 18:42 UTC ( [id://11145879]=note: print w/replies, xml ) Need Help??


in reply to How to collect output of DB2 query run interactive mode using perl script

If you want the information about the column , like its type etc., don't do it by running an external program, but do it by using the catalog methods. What you want is basically:

use DBI; my $dbh = DBI->connect('dbi:DB2', 'db2tf0' ); my $sth_columns = $dbh->column_info(undef, undef, 'indic.name', undef) +; # print out the results

If you really cannot use DBI and your system administrator won't install it, maybe you can simply pipe text into the db2 shell instead of trying to run things interactively:

my @results = qx(echo 'connect to ctinld01 user db2tf0 using db2tf0\nd +escribe select * from indic.name' | db2 ); print "<$_>" for @results;

According to the db2 manual, you can simply pass the SQL statement(s) to the db2 tool:

db2 "connect ..." "select ..."

Replies are listed 'Best First'.
Re^2: How to collect output of DB2 query run interactive mode using perl script
by Rishi2Monk (Novice) on Aug 01, 2022 at 18:49 UTC

    Thanks for your quick reply. I will check both the ways and update here.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11145879]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (4)
As of 2024-04-19 20:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found