my $i = 0;
# Connect to Oracle database.
#When you fetch the data for the below sql statment it is loaded into
+array index '0'. There is no way to index it. array = ['0','1','2',.
+..'nth'].
# Set up Query for ID
my $stmt_1 = "select alignment from rd_list";
# Prepare Query
my $query = $connection->prepare($stmt_1);
# Execute Query
$query->execute() or die $connection->errstr;
# Create Array_ref for array.
my $rows = $query->fetchall_arrayref;
# Load data in array.
foreach $i(0..$#{$rows})
{
foreach $j (0..$#{$rows->[$i]} )
{
$rows->[$i][$j];
}
}
my $num = $query->rows;
print "\nThis process returns $num of ID's.\n\n";
while ($i<=2)
{
my $rd = "$rows->[$i][0]";
print "$rd\n";
$i++;
}
In terms of a premade dataset. I know the exact count of $row. I just print the count. I have not created array via hard coding a premade list of $row. I can try that. I know that $row has the correct values because I checked them against the list in my database.
Each time I run the process, it sends an email to my inbox with three reports. I have it set to process while $i < = 2. So, the first email with id = '01' is the only worksheet with data from the sql statement. The other two have all the headers, etc.. but no data from the sql. It is as if the sql prepare holds on to the first value. I know the value changes, because it prints each time and email it each time.
I also know that the first report from array index '0' is correct because I validate the selected data from my data in Oracle.