Hi,
I am a newbie in perl. I will really appreciate any help and advice.
I have a Oracle table that contains quite a few Filenames. I am trying to write a perl script thats generates all the possible dates between two dates that is passed as a parameter to Perl script and concatenate these dates with FileNames.
For E.G.:
I grab one filename from Oracle table called "SMITH.sfs". I pass in two dates to a perl script 2006-06-01 and 2006-06-30. I have to generate the 30 dates one for each day between the above two dates that was passed in.
I am trying to get the output something like below and write it to a flat file:
SMITH.sfs.20060601
SMITH.sfs.20060602
SMITH.sfs.20060603
........and so on till
SMITH.sfs.20060630
Below is my script that works fine with the Oracle SYSDATE.....(This script is not passing the date right now). I have to modify this script to generate dates as mentioned above.
#!/usr/bin/perl
use DBI;
$dbh = DBI->connect("dbi:Oracle:sid...",user,passwd) ;
print "Connected Sucessfully to Oracle database \n"; \
$sql = q{
Select
ID,
File_Name||to_char(SYSDATE,'YYYYMMDD') As FILE_NAME
From TABLE A
Where D_Reg Like '%d{8}%'
UNION
Select
ID,
File_Name||to_char(SYSDATE,'YYYYMMDD') As FILE_NAME
From TABLE A
Where D_Reg Like '%d{6}%'
};
$stmt = $dbh->prepare($sql) or die "Cannot prepare the SQL";
$stmt->execute() or die "Cannot Excecute";
$rec = $stmt->fetchall_hashref('DATA_FL_ID');
for $DATA_FL_ID ( keys %$rec )
{
my $record = $rec->{ $DATA_FL_ID };
print $record->{'FILE_NAME'}, "\n"; -->THIS PRINTS THE FILENAMES....
}
I will really appreciate any help in this regards.
Thanks
RK
I am a newbie in perl. I will really appreciate any help and advice.
I have a Oracle table that contains quite a few Filenames. I am trying to write a perl script thats generates all the possible dates between two dates that is passed as a parameter to Perl script and concatenate these dates with FileNames.
For E.G.:
I grab one filename from Oracle table called "SMITH.sfs". I pass in two dates to a perl script 2006-06-01 and 2006-06-30. I have to generate the 30 dates one for each day between the above two dates that was passed in.
I am trying to get the output something like below and write it to a flat file:
SMITH.sfs.20060601
SMITH.sfs.20060602
SMITH.sfs.20060603
........and so on till
SMITH.sfs.20060630
Below is my script that works fine with the Oracle SYSDATE.....(This script is not passing the date right now). I have to modify this script to generate dates as mentioned above.
#!/usr/bin/perl
use DBI;
$dbh = DBI->connect("dbi:Oracle:sid...",user,passwd) ;
print "Connected Sucessfully to Oracle database \n"; \
$sql = q{
Select
ID,
File_Name||to_char(SYSDATE,'YYYYMMDD') As FILE_NAME
From TABLE A
Where D_Reg Like '%d{8}%'
UNION
Select
ID,
File_Name||to_char(SYSDATE,'YYYYMMDD') As FILE_NAME
From TABLE A
Where D_Reg Like '%d{6}%'
};
$stmt = $dbh->prepare($sql) or die "Cannot prepare the SQL";
$stmt->execute() or die "Cannot Excecute";
$rec = $stmt->fetchall_hashref('DATA_FL_ID');
for $DATA_FL_ID ( keys %$rec )
{
my $record = $rec->{ $DATA_FL_ID };
print $record->{'FILE_NAME'}, "\n"; -->THIS PRINTS THE FILENAMES....
}
I will really appreciate any help in this regards.
Thanks
RK