Hi Friends..
I am facing problem while running a query (with oracle placeholder) in my Perl script.
Following is the code :
#!/usr/bin/perl -w
use warnings;
use strict;
use CGI;
use DBI;
use CGI::Carp qw(fatalsToBrowser);
my $query=new CGI;
my $cgiobj = CGI -> new();
#my $xlsdata;
my $querydata;
my $querycreated;
#print "Content-type:text/html\n\n";
my $querytitle = $cgiobj -> param('querytitle');
$ENV{ORACLE_HOME}="/home/oracle/product/10.2.0/db_1";
our $conn = DBI->connect("dbi:Oracle:host=10.0.0.1;sid=dev;","queryedi
+tor","editor");
die($DBI::errstr) unless $conn;
print $querytitle;
print "Content-type: application/HTML\n";
print "Content-disposition: inline; filename=\"Report.html\"\n";
print "Pragma: no-cache\n";
print "Expires: 0\n\n";
my $query_detail1 = "select querydata from querydetail where querytitl
+e='$querytitle'";
my $query_records1 = $conn->prepare($query_detail1) or die("Error on p
+reparing the sql statement1 \n");
$query_records1->execute() or die("Error on getting the data from QUER
+YDETAIL \n");
while(my @query_resultset1= $query_records1->fetchrow_array)
{
my $mainquery= $query_resultset1[0];
#print $mainquery;
my $query_records2 = $conn->prepare($mainquery) or die("Error on prepa
+ring the sql statement2 \n");
$query_records2->execute() or die("Error on getting the data from QUER
+YDETAIL \n");
print "<h1><center>Report</center></h1><br><br>";
my $dat = $query_records2 -> fetchall_arrayref;
foreach my $i ( 0..$#{ $dat } ) {
foreach my $j ( 0..$#{ $dat->[$i] } ) {
print $dat->[$i][$j]."<br>";
}
}
}
I am making the final result in HTML report format. For example I am using the "select * from EMP where EMPNO = &eno " query here. So, $mainquery will carry this query and will process the rest.
What could be the problem ? If you need more detail..then i can supply iy to you..
Thanks in Advance..
Warm Regards,
Saravanan
Code tags added by Arunbear