04-03-2009
# Program to get the Query, Parse count, Execute count, Fetch count, Total cpu time and Total elapsed time.
# Begin Prompt for User Input .. Input Trace File
$inputFile = &promptUser("\n\t\t Enter the TraceFile Name");
#Open input and output files and create File Handles
open(INFILE,"<$inputFile") or die " Input File opening ERROR :: $!";
$opFile = $inputFile.".xls";
open(OUTFILE,">$opFile") or die " Output File opening ERROR :: $!";
# Write the Headings to the file
print OUTFILE "SQL Query and the Indexes used in the Query is printed in the output_log file \n\n";
#print OUTFILE "===================================================================\n";
#print OUTFILE "SQL QUERY ~PARSE Count ~EXECUTE Count ~FETCH Count ~TOTAL CPU TIME ~TOTAL ELAPSED TIME ~FullTableScan\n";
# initializations
$SQLLINE="";
$CUTLINE="";
$CUTLINE1="";
$FLAG=0;
$SUFLAG=0;
$Indexflag=0;
$MyFlag=0;
$Rows=0;
$Blocks=0;
$Result=0;
$Zero=0;
$Level=10;
#
# Working on the input file One Line at a Time !!! Read from given I/P file Line by Line.
foreach $actual_line (<INFILE>)
{
# To get the PLAN !!!
# if line is a sql statement change the flag status
# and copy the line to a variable
if( $actual_line =~ m/^SELECT/ || $actual_line =~ m/^select/ || $actual_line =~ m/^update/ || $actual_line =~ m/^UPDATE/) {
$FLAG=1;
$SUFLAG=1;
#print OUTFILE "------------------------------------------------------------------------------- \n\n";
chomp($actual_line);
$SQLLINE=$actual_line;
}
#change the flag status when complete sql statement is read
elsif($actual_line =~ m/^call/){
#print "call";
$FLAG=0;
print OUTFILE "***************************************************************************** \n";
print OUTFILE "$SQLLINE" ;
$CUTLINE=$SQLLINE;
@charArray = split(/FROM/,$CUTLINE);
$CUTLINE1=@charArray[1];
print OUTFILE "$CUTLINE1" ;
$SQLLINE="";
next;
}
# read the complete sql statement line by line and join them together
elsif($FLAG==1) {
chomp($actual_line);
$line=$actual_line;
$temp=$SQLLINE;
$SQLLINE=$temp.$line;
next;
}
# Above code Completes the program for copying the SQL Query.
else{
next;
}
}
##
# Close all file handles !!!
##
close(INFILE) or die " INFILE CLOSING ERROR : $!";
close(OUTFILE) or die " OUTFILE CLOSING ERROR : $!";
#
# Display Console message to user ..
print "\t\tOUTPUT printed to File : $opFile \n";
# Prompting the usr to enter an Input file or accept a default I/P File ...
#
#
sub promptUser
{
local($promptString,$defaultValue) = @_;
if ($defaultValue)
{
print $promptString, "[", $defaultValue, "]: ";
}
else
{
print $promptString, ": ";
}
$| = 1; # force a flush after our print
$_ = <STDIN>; # get the input from STDIN (presumably the keyboard)
chomp;
if ("$defaultValue")
{
return $_ ? $_ : $defaultValue; # return $_ if it has a value
}
else
{
return $_;
}
}
This is the code that I have created. The problem comes as it is splitting for FROM but it is not splitting for from.
Also need to continue with the logic
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I am trying to split input that looks like
,2005-09-12 01:45:00.000000,2005-09-12 01:48:18.000000,
I want to split on the dot .
What I am using is ($ev_time,$rol)=split(/\./),$inputfile;
This does not recognize the dot as what I want to split on. (2 Replies)
Discussion started by: reggiej
2 Replies
2. UNIX for Dummies Questions & Answers
Hi friends,
What are the possible ways to connect to DB2 database from Perl (on unix).
I need to connect to DB2 and get records for further processing. Can you please suggest the best possible way. I heard about DBI/DBD, if you have some sample scripts please post them too.
Thanks in advance. (3 Replies)
Discussion started by: satguyz
3 Replies
3. Shell Programming and Scripting
Let's say I have a very long string with no spaces but just words stored in $very_long_string.
$very_long_string = "aaaaaaaaaaabbbbbbbbbbbccccccccccccdddddddddddd";
I can do this to split the string into 1 character each and store them in an array:
@myArray = split(//, $very_long_string); ... (3 Replies)
Discussion started by: teiji
3 Replies
4. Shell Programming and Scripting
If i have a script name.pl
I run it like name.pl -v file.txt -t ext2 -u user -j
how can I edit the array @ARGV so when my script calls
$ARGV = -v file.txt
$ARGV = -j (2 Replies)
Discussion started by: 3junior
2 Replies
5. Shell Programming and Scripting
Hi there,
I have an output from a command like this
# ypcat -k netgroup.byuser| grep steven
steven.* users_main,users_sysadmin,users_global,users_backup_team
and wanted to pull the 'users' netgroups returned into a perl array, that will look like this
users_main... (2 Replies)
Discussion started by: rethink
2 Replies
6. Shell Programming and Scripting
how to link the linux files in perl on the local webpage ????
suppose we have some results and want to get them published on the local webpage of our internal site. how this can be done using HTML and perl together , so that the results are published directly on the webpage.
thanks
kullu (0 Replies)
Discussion started by: kullu
0 Replies
7. Shell Programming and Scripting
Hi,
I'm trying to split a large file into several smaller files
the script will have two input arguments argument1=filename and argument2=no of files to be split.
In my large input file I have a header followed by 100009 records
The first line is a header; I want this header in all my... (9 Replies)
Discussion started by: ramky79
9 Replies
8. Shell Programming and Scripting
I am trying to make a simple perl program that reads 20 characters upstream from the codon ATG in a given sequence. The following is what I have. I just dont know how to make the program read 20 characters upstream from the ATG codon.
print "\nThis program will read 20 characters upstream... (1 Reply)
Discussion started by: patiencenpray
1 Replies
9. Shell Programming and Scripting
I have a perl variable which contains the below value.
$var1 = "2% / 51%"
Now I would like to split the data into 2 different variables.
For example
$part1 = 2
$part2 = 51
Could anyone please help me in this regard ?
Regards,
GS (4 Replies)
Discussion started by: giridhar276
4 Replies
10. Shell Programming and Scripting
Hi All,
I am new to Scripting language.
I want to split a file and create several subfiles using Perl script.
Example :
File format :
Sourcename ID Date Nbr
SU IMYFDJ 9/17/2012 5552159976555
SU BWZMIG 9/14/2012 1952257857887
AR PEHQDF 11/26/2012 ... (13 Replies)
Discussion started by: Deepak9870
13 Replies
LEARN ABOUT DEBIAN
fastq_quality_trimmer
FASTQ_QUALITY_TRIMMER(1) User Commands FASTQ_QUALITY_TRIMMER(1)
NAME
fastq_quality_trimmer - Filters sequences based on quality
DESCRIPTION
usage: fastq_quality_trimmer [-h] [-v] [-t N] [-l N] [-z] [-i INFILE] [-o OUTFILE] Part of FASTX Toolkit 0.0.13.1 by A. Gordon (gor-
don@cshl.edu)
[-h] = This helpful help screen.
[-t N] = Quality threshold - nucleotides with lower
quality will be trimmed (from the end of the sequence).
[-l N] = Minimum length - sequences shorter than this (after trimming)
will be discarded. Default = 0 = no minimum length.
[-z] = Compress output with GZIP.
[-i INFILE]
= FASTQ input file. default is STDIN.
[-o OUTFILE] = FASTQ output file. default is STDOUT. [-v] = Verbose - report number of sequences.
If [-o] is specified,
report will be printed to STDOUT.
If [-o] is not specified (and output goes to STDOUT), report will be printed to STDERR.
SEE ALSO
The quality of this automatically generated manpage might be insufficient. It is suggested to visit
http://hannonlab.cshl.edu/fastx_toolkit/commandline.html
to get a better layout as well as an overview about connected FASTX tools.
fastq_quality_trimmer 0.0.13.1 April 2012 FASTQ_QUALITY_TRIMMER(1)