Sponsored Content
Full Discussion: for loop with db2 command
Top Forums Shell Programming and Scripting for loop with db2 command Post 302139332 by Vaddadi on Friday 5th of October 2007 11:15:00 AM
Old 10-05-2007
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 command but I don't know how.. So appreciate your help.

Shell script is
=================
table_name='TAB_NAME'
schema_name='SCH_NAME'
db2 "connect to DB2D"

tempfile1=`db2 -x "select concat(pkgschema,concat('.',pkgname)) from
syscat.packagedep where bname='"$table_name"' and
bschema='"$schema_name"' with ur "`
echo ' ---tempfile after the db2 command ------- ' $tempfile1
for variable in $tempfile1; do
echo $tempfile1[0]
done

db2 "connect reset"


After the db2 command tempfile1 looks like ( 3 words seperated by blank)
sch1.package1 sch2.package2 sch3.package3

In the for loop also it shows like
sch1.package1 sch2.package2 sch3.package3 [0]
sch1.package1 sch2.package2 sch3.package3 [0]
sch1.package1 sch2.package2 sch3.package3 [0]


Expected output is
====================
sch1.package1
sch2.package2
sch3.package3
 

10 More Discussions You Might Find Interesting

1. 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

2. UNIX for Dummies Questions & Answers

Exception while loading DB2 driver Class.forName("com.ibm.db2.jcc.DB2Driver")

Hi... I m working on UNIX z/OS. Actually i have to pass the parameters from the JCL to java-db2 program thru PARM. I am able to pass the arguments but the problem occured is, it is throwing an exception while loading the db2 driver as 'Javaclassnotfound:com.ibm.db2.jcc.DB2Driver'... (0 Replies)
Discussion started by: Sujatha Gowda
0 Replies

3. UNIX for Dummies Questions & Answers

Unable to get the db2 command prompt in unix

Hi, When i try to connect to the db2 database from unix solaris 5.8 version by typing "db2" from the .../sqllib/bin/ folder, i am not getting the db2 command prompt. Could anyone help me resolve this? Here the db2 is executable only. But still iam not getting the db2 prompt. The error i get is... (4 Replies)
Discussion started by: ragavhere
4 Replies

4. Shell Programming and Scripting

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 ;... (0 Replies)
Discussion started by: arizah
0 Replies

5. Shell Programming and Scripting

Run DB2 export command in loop

Hi All, I have list of 100 table names in a file, how to read table name from and pass to DB2 export command and run for all tables in loop. Please help me with script. db2 EXPORT TO ~/data_export/<table name from file>.ixf OF IXF MESSAGES messages.txt "SELECT * FROM ITG.<Table Name... (4 Replies)
Discussion started by: srimitta
4 Replies

6. Shell Programming and Scripting

how do i access db2 instance via telnet command prompt

Hi I have a perl script code in which connecting with db2 database and doing some process. My perl script code and db2 database server present in the same unix server. I am connecting and executing perl script code via windows telnet. Now my question is i could not able to connect db2 server... (4 Replies)
Discussion started by: solo123
4 Replies

7. 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

8. Shell Programming and Scripting

How to create DB2 Connections in While loop using shell script

Hi , I have to create a db2 connection for the while loop in shell scripting. Below is the connection for DB2 I have to establish connect to TABLESCHENMA user $USERID using $PASSWORD Below is the while loop. while read TABLE; do db2 LOAD CLIENT FROM $DIRECTORY/$TABLE.ixf OF ixf INSERT... (1 Reply)
Discussion started by: vikyalex4
1 Replies

9. 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

10. UNIX for Beginners Questions & Answers

Troubles running DB2 command in shell script via cron

Hi there, Now I'm facing error regarding running shell script via cron. The shell script which is required to get value from database. Below is the main part of shell script. #/bin/bash #connect to database(1) db2 connect to $database user xxxx using yyyy #set values from... (3 Replies)
Discussion started by: Rohan Kishibe
3 Replies
DPROFPP(1)						 Perl Programmers Reference Guide						DPROFPP(1)

NAME
dprofpp - display perl profile data SYNOPSIS
dprofpp [-a|-z|-l|-v|-U] [-d] [-s|-r|-u] [-q] [-F] [-I|-E] [-O cnt] [-A] [-R] [-S] [-g subroutine] [-G <regexp> [-P]] [-f <regexp>] [pro- file] dprofpp -T [-F] [-g subroutine] [profile] dprofpp -t [-F] [-g subroutine] [profile] dprofpp -G <regexp> [-P] [profile] dprofpp -p script [-Q] [other opts] dprofpp -V [profile] DESCRIPTION
The dprofpp command interprets profile data produced by a profiler, such as the Devel::DProf profiler. Dprofpp will read the file tmon.out and will display the 15 subroutines which are using the most time. By default the times for each subroutine are given exclusive of the times of their child subroutines. To profile a Perl script run the perl interpreter with the -d switch. So to profile script test.pl with Devel::DProf the following command should be used. $ perl5 -d:DProf test.pl Then run dprofpp to analyze the profile. The output of dprofpp depends on the flags to the program and the version of Perl you're using. $ dprofpp -u Total Elapsed Time = 1.67 Seconds User Time = 0.61 Seconds Exclusive Times %Time Seconds #Calls sec/call Name 52.4 0.320 2 0.1600 main::foo 45.9 0.280 200 0.0014 main::bar 0.00 0.000 1 0.0000 DynaLoader::import 0.00 0.000 1 0.0000 main::baz The dprofpp tool can also run the profiler before analyzing the profile data. The above two commands can be executed with one dprofpp com- mand. $ dprofpp -u -p test.pl Consult "PROFILE FORMAT" in Devel::DProf for a description of the raw profile. OUTPUT
Columns are: %Time Percentage of time spent in this routine. #Calls Number of calls to this routine. sec/call Average number of seconds per call to this routine. Name Name of routine. CumulS Time (in seconds) spent in this routine and routines called from it. ExclSec Time (in seconds) spent in this routine (not including those called from it). Csec/c Average time (in seconds) spent in each call of this routine (including those called from it). OPTIONS
-a Sort alphabetically by subroutine names. -d Reverse whatever sort is used -A Count timing for autoloaded subroutine as timing for *::AUTOLOAD. Otherwise the time to autoload it is counted as time of the subrou- tine itself (there is no way to separate autoload time from run time). This is going to be irrelevant with newer Perls. They will inform "Devel::DProf" when the "AUTOLOAD" switches to actual subroutine, so a separate statistics for "AUTOLOAD" will be collected no matter whether this option is set. -R Count anonymous subroutines defined in the same package separately. -E (default) Display all subroutine times exclusive of child subroutine times. -F Force the generation of fake exit timestamps if dprofpp reports that the profile is garbled. This is only useful if dprofpp deter- mines that the profile is garbled due to missing exit timestamps. You're on your own if you do this. Consult the BUGS section. -I Display all subroutine times inclusive of child subroutine times. -l Sort by number of calls to the subroutines. This may help identify candidates for inlining. -O cnt Show only cnt subroutines. The default is 15. -p script Tells dprofpp that it should profile the given script and then interpret its profile data. See -Q. -Q Used with -p to tell dprofpp to quit after profiling the script, without interpreting the data. -q Do not display column headers. -r Display elapsed real times rather than user+system times. -s Display system times rather than user+system times. -T Display subroutine call tree to stdout. Subroutine statistics are not displayed. -t Display subroutine call tree to stdout. Subroutine statistics are not displayed. When a function is called multiple consecutive times at the same calling level then it is displayed once with a repeat count. -S Display merged subroutine call tree to stdout. Statistics are displayed for each branch of the tree. When a function is called multiple (not necessarily consecutive) times in the same branch then all these calls go into one branch of the next level. A repeat count is output together with combined inclusive, exclusive and kids time. Branches are sorted w.r.t. inclusive time. -U Do not sort. Display in the order found in the raw profile. -u Display user times rather than user+system times. -V Print dprofpp's version number and exit. If a raw profile is found then its XS_VERSION variable will be displayed, too. -v Sort by average time spent in subroutines during each call. This may help identify candidates for inlining. -z (default) Sort by amount of user+system time used. The first few lines should show you which subroutines are using the most time. -g "subroutine" Ignore subroutines except "subroutine" and whatever is called from it. -G <regexp> Aggregate "Group" all calls matching the pattern together. For example this can be used to group all calls of a set of packages -G "(package1::)|(package2::)|(package3::)" or to group subroutines by name: -G "getNum" -P Used with -G to aggregate "Pull" together all calls that did not match -G. -f <regexp> Filter all calls matching the pattern. ENVIRONMENT
The environment variable DPROFPP_OPTS can be set to a string containing options for dprofpp. You might use this if you prefer -I over -E or if you want -F on all the time. This was added fairly lazily, so there are some undesirable side effects. Options on the commandline should override options in DPROFPP_OPTS--but don't count on that in this version. BUGS
Applications which call _exit() or exec() from within a subroutine will leave an incomplete profile. See the -F option. Any bugs in Devel::DProf, or any profiler generating the profile data, could be visible here. See "BUGS" in Devel::DProf. Mail bug reports and feature requests to the perl5-porters mailing list at <perl5-porters@perl.org>. Bug reports should include the output of the -V option. FILES
dprofpp - profile processor tmon.out - raw profile SEE ALSO
perl, Devel::DProf, times(2) perl v5.8.0 2003-02-18 DPROFPP(1)
All times are GMT -4. The time now is 05:12 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy