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.


In reply to Re^6: SQL query using dynamic array by cocl04
in thread SQL query using dynamic array by cocl04

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.