Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

fetchrow_array() issue

by Freezer (Sexton)
on Sep 26, 2012 at 12:23 UTC ( #995758=perlquestion: print w/replies, xml ) Need Help??
Freezer has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks

I have a problem with the following:
my $sql_A = "SELECT DISTINCT parameter_id FROM e.measurement WHERE +((parameter_id LIKE 'M%') OR (parameter_id LIKE 'G%') OR (parameter_i +d LIKE 'E%')) AND parameter_id NOT LIKE '%_________8__' ORDER BY para +meter_id;"; my $Output_A = "List_parameters_common_to_centers.txt"; open (OUTFILE_A, ">>$Output_A") || die "Error opening outfile.$!,s +topped"; my $sth_A = $dbh->prepare($sql_A) or die "Cannot prepare: " . $dbh +->errstr(); $sth_A->execute() or die "$sth_A->errstr\n"; my @row_A; my @parameters_A; my @record_A; while(@row_A = $sth_A->fetchrow_array()) { @record_A = @row_A; push(@parameters_A, @record_A); print OUTFILE_A "@record_A\n"; } $sth_A->finish();
The Perl code seems to drop a whole lot of what the select statement takes. UPDATE: This is comparing what i get from the SELECT statement directly, to what I get with it is buried in perl code.

UPDATE: I think that there is a memory problem because there should be 911 rows and instead I am getting 459, with the last row only being a partial string.

Replies are listed 'Best First'.
Re: fetchrow_array() issue
by Corion (Pope) on Sep 26, 2012 at 12:30 UTC

    How do you know?

Re: fetchrow_array() issue
by tobyink (Abbot) on Sep 26, 2012 at 14:17 UTC

    This line needs work, though it's not what's causing your problem...

    $sth_A->execute() or die "$sth_A->errstr\n";

    And memory is very unlikely to be an issue either (unless your parameter IDs are very long strings - say, hundreds of thousands of characters each - but I'm guessing they're integers or short strings).

    Is the filesystem full, or perhaps you have a quota on it?

    perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'
      I'm working in Linux and I don't know how to check if my file system is full.
      m@m-workstation:~/Documents/Perl/29_8_2012$ df -k Filesystem 1K-blocks Used Available Use% Mounted on /dev/sda5 315043940 27888296 271385432 10% / udev 8186712 4 8186708 1% /dev tmpfs 3278200 836 3277364 1% /run none 5120 0 5120 0% /run/lock none 8195492 156 8195336 1% /run/shm /dev/sda1 280936 9456 271480 4% /media/07DB-0207

        So why have you not looked up how to do this using your search engine of choice? You seem to want to make things difficult for yourself.

Re: fetchrow_array() issue
by Neighbour (Friar) on Sep 27, 2012 at 08:01 UTC
    It would help if you close OUTFILE; at some point. If you don't, you could miss data that's still in the file buffer.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://995758]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (3)
As of 2017-06-28 23:47 GMT
Find Nodes?
    Voting Booth?
    How many monitors do you use while coding?

    Results (653 votes). Check out past polls.