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;
}
}

Help you with what? You should not expect anyone here to debug your code, explain where you are having problems.

Please note there is no urgent help here. Your question is no more important or less important then any other question posted on the forum. If you need urgent help hire a programmer.

I would try to help you but your code is unreadable. You need to use the "code" tags and include your indentations as described in the posting rules.

also, you need to explain what you have already done as far as debugging.

like Kevin said, this is not a service for you to demand urgent or immediate help. help us help you and you might get somewhere

This article has been dead for over six months. Start a new discussion instead.