Executing DB2 command without using the DBI module


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Executing DB2 command without using the DBI module
# 1  
Old 05-28-2010
Executing DB2 command without using the DBI module

Hi Guys,

I wonder if possible to execute a Db2 commands within a perl scripts without installing or invoking the DBI modules. I have a script that is written in kron shell and it looks like :


DB=`db2 list db directory | egrep "Database alias|Directory entry type"|awk '{printf $0 ; getline; print $0}'| grep "Indirect" | awk '{print $4 }'`
for DATABASE in $DB ;
do
db2 connect to $DATABASE
export CONN=$?
db2 "select count(*) from sysibm.sysdummy1"
export SEL=$?
db2 terminate
export TER=$?
if [[ $CONN -ne 0 || $SEL -ne 0 || $TER -ne 0 ]]; then
print " Error has occured connecting to $DATABASE on hostname : `hostname`"
print " Error has occured connecting to $DATABASE on hostname : `hostname`"
fi
done


and I would like to rewrite it in perl if I don't have to install the DBI modules. Has anyone done it before or it is possible. thanks.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Issue on executing db2 queries through shell script

hi i am trying to execute db2 queries through shell script. it's working fine but for few queries is not working ( those queries are taking time so the script is not waiting to get the complete the execution of that query ) could you please any one help me on this is there any wait... (1 Reply)
Discussion started by: bhaskar v
1 Replies

2. UNIX for Dummies Questions & Answers

Db2 command issues with cron

Hi, I have a very simple script that queries from a DB2 table. The script has 3 parts - (i) Sets the db2profile (ii) connects to db2 using credentials (iii) executes the query.This script works fine if i run it manually from the command prompt. However when scheduled in crontab, it proceeds... (2 Replies)
Discussion started by: VeePee
2 Replies

3. Shell Programming and Scripting

DB2: load command in unix

I am currently trying to load data from e.txt into tablea. I am getting error. db2 connect to qw01p user wcs using abc db2 "LOAD CLIENT FROM /dswork/ECONT/output/interface/e.txt OF DEL MODIFIED BY coldel| SAVECOUNT 0 ROWCOUNT 0 WARNINGCOUNT 0 MESSAGES XTMPRTI1.txt REPLACE into WCSADM.TABLEA... (1 Reply)
Discussion started by: skatpally
1 Replies

4. Shell Programming and Scripting

Help in executing the following db2 sql querry in unix

Hi All, Please help me out in executing the following db2 querry in unix db2 "select AP_RQ_ACQ_INST_ID || ',' || txn_classifier || ',' || AP_RS_RESP_CD || ',' || (count(*) AS COUNT1) || ',' || (SUM(AP_RQ_TXN_AMT) AS TOTAL_AMT) from TXN_RECORD where CREATE_TS > '2010-11-22 11:00:00.008645' ... (1 Reply)
Discussion started by: dudd9
1 Replies

5. UNIX for Advanced & Expert Users

Perl's DBI Module on OS X - uninstallable?

i've been struggling with installing the Perl DBI & DBD modules all weekend, and I'm getting close, but no cigar as of yet. When I run the perl script db.pl I get the following mismatch error: Mon Apr 19 09:43:29 EDT 2010 /Library/Perl/DBD-mysql-4.011 -> peterv@MBP17.local<515>$: db.pl | tee... (0 Replies)
Discussion started by: peterv6
0 Replies

6. AIX

db2 command on the AIX mechine

Hello, can any one help me to debug the following command. db2 -stec +pc ; Regards, SM (2 Replies)
Discussion started by: smolgara
2 Replies

7. Programming

perl dbi to oracle getting disconnect_all for oracle dbi help

hi i am trying to connect to an oracle database using dbi and i get this :: Driver has not implemented the disconnect_all method. at /opt/perl/lib/site_perl/5.8.0/sun4-solaris/DBI.pm line 575 END failed--call queue aborted. for all i know, the script was working earlier, but has... (1 Reply)
Discussion started by: poggendroff
1 Replies

8. Shell Programming and Scripting

perl DBI/DBD Module -in cygwin

Hi all, I am trying to install the DBI module in perl using perl -MCPAN -e shell install 'DBI' --It is installing into the nuild directory properly but when it try to make it is saying NOT OK -I tried to copy the module manually to the /lib/perl5/vendor_perl ... (3 Replies)
Discussion started by: jambesh
3 Replies

9. Shell Programming and Scripting

for loop with db2 command

Having some trouble with usage of for loop and displaying words. Basically I had 3 words( some times more ) in the variable. I want to get one at a time to process. I am new to unix scripting so please bear with my question and appreciate your reply. I think this can also me done my awk... (1 Reply)
Discussion started by: Vaddadi
1 Replies

10. Shell Programming and Scripting

PERL DBI module install

We ran into an issue trying to install DBI and DB2 modules for perl for AIX from the link http://www-306.ibm.com/software/data/db2/perl/ We tried to install the DBI module using bash# perl -MCPAN -e 'install DBI' command. However we ended up with the following error. Stop. ... (3 Replies)
Discussion started by: jerardfjay
3 Replies
Login or Register to Ask a Question
DateTime::Format::DBI(3pm)				User Contributed Perl Documentation				DateTime::Format::DBI(3pm)

NAME
DateTime::Format::DBI - Find a parser class for a database connection. SYNOPSIS
use DBI; use DateTime; use DateTime::Format::DBI; my $db = DBI->connect('dbi:...'); my $db_parser = DateTime::Format::DBI->new($dbh); my $dt = DateTime->now(); $db->do("UPDATE table SET dt=? WHERE foo='bar'",undef, $db_parser->format_datetime($dt); DESCRIPTION
This module finds a "DateTime::Format::*" class that is suitable for the use with a given DBI connection (and "DBD::*" driver). It currently supports the following format modules: IBM DB2 (DB2), Microsoft SQL (MSSQL), MySQL, Oracle, PostgreSQL (Pg), SQLite, and Sybase. NOTE: This module provides a quick method to find the correct parser and formatter class. However, this is usually not sufficient for full database abstraction. You will also have to cater for differences in the syntax and semantics of SQL datetime functions (and other SQL commands). CLASS METHODS
This module provides a single factory method: o new( $dbh ) Creates a new "DateTime::Format::*" instance, the exact class of which depends on the database driver used for the database connection referenced by $dbh. PARSER
/FORMATTER INTERFACE "DateTime::Format::DBI" is just a front-end class factory that will return one of the format classes based on the nature of your $dbh. For information on the interface of the returned parser object, please see the documentation for the class pertaining to your particular $dbh. In general, parser classes for databases will implement the following methods. For more information on the exact behaviour of these methods, see the documentation of the parser class. o parse_datetime( $string ) Given a string containing a date and/or time representation from the database used, this method will return a new "DateTime" object. If given an improperly formatted string, this method may die. o format_datetime( $dt ) Given a "DateTime" object, this method returns a string appropriate as input for all or the most common date and date/time types of the database used. o parse_duration( $string ) Given a string containing a duration representation from the database used, this method will return a new "DateTime::Duration" object. If given an improperly formatted string, this method may die. Not all databases and format/formatter classes support durations; please use UNIVERSAL::has to check for the availability of this method. o format_duration( $du ) Given a "DateTime::Duration" object, this method returns a string appropriate as input for the duration or interval type of the database used. Not all databases and parser/formatter classes support durations; please use UNIVERSAL::has to check for the availability of this method. Parser/formatter classes may additionally define methods like parse_type or format_type (where type is derived from the SQL type); please see the documentation of the individual format class for more information. SUPPORT
Please report bugs and other requests to the rt tracker: <https://rt.cpan.org/Public/Dist/Display.html?Name=DateTime-Format-DBI>. AUTHOR
Claus Faerber <CFAERBER@cpan.org> LICENSE
Copyright 2003-2010 Claus Faerber. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The full text of the license can be found in the LICENSE file included with this module. SEE ALSO
DateTime, DBI datetime@perl.org mailing list http://datetime.perl.org/ perl v5.10.1 2011-02-10 DateTime::Format::DBI(3pm)