Hi All,
could you please help :
i have a script to search the for PRIMARY INDEX and if found display the whole definition of create table:
ISSUE NOW IS:
we have to store the table name in a variable and search the file if any update,show table exists for that particular table.
Example:
ct t15(
c1 varchar(32000),
c2 char(32000),
c3 int);
show table t15;
store t15 in var and search for show table $var.
can you help me
perl Script:
my $FILE = $ARGV[0];
if ($FILE eq "" )
{
print "File name $FILE not found \n";
print "Usage:Parse_bteq_new.pl <file.bteq/file.jcl> \n";
exit;
}
my $count=0;
open(IN_FILE, $FILE) or die "cannot open $FILE:" . "$!";
my $comment = true;
my $FND = false;
my $SRH=false;
my @LINE = ();
my $CNT = 0;
while ($line=<IN_FILE>)
{
$count++;
if ($line =~ /^$/)
{
next;
}
if ($line =~ /^grant/i)
{
next;
}
if ($line =~ /^\/\*/ ||$line =~ /^\/\/*/ || $line =~ /^\..*/ || $line =~ /^\*.*/)
{
my $comment = true;
next;
}
if ($comment eq "true")
{
if ( $line =~ /\*\/$/)
{
next;
}
else
{
$comment = false;
}
}
if ($FND eq "true" )
{
$LINE[$CNT] = $line;
if ($line =~ /\s*PRIMARY\s+INDEX/gi)
{
$PRMFLG=true;
}
if ($line =~ m/;$/ || $line =~ /;/)
{
$FND= false;
if ($PRMFLG =~ /true/)
{
@LINE=();
$PRMFLG=false;
}
else
{
print (@LINE);
}
@LINE=();
}
$CNT++;
next;
}
if ( $line =~ /^\s*CT|create[ ]*table[ ]*/gi)
{
if ( $line =~ m/.*;/)
{
if ($line =~ /\s*PRIMARY\s+INDEX/gi)
{
next;
}
print $count.":".$line;
$FND = false;
}
else
{
if ($line =~ /\s*PRIMARY\s+INDEX/gi)
{
next;
}
$LINE[$CNT] = $count.":".$line;
$CNT++;
$FND = true;
}
next;
}
}