Monks, I have code which generates a large XML packet (containing hundreds of packet_refs, see below) based on the result of a SQL query. I want to break this down so that 1 XML packet, each containing 10 packet_ref's is sent, then looped for the rest of the results. I've tried to adapt my code to do this, but I don't know what the condition should be for the if statement. As requested, this is a cut down example of my code. Please advise
foreach my $item (@SQLvars){ my $sth = $self->dbh()->prepare($DocumentQuery) or die "Can't prepair statement: $self->DBI::errstr"; my ( $foo, $bar ); $sth->execute( $item->{PACKID}, $item->{PACKINFO} ); $sth->bind_columns(\( $foo, $bar )); while ($sth->fetch) { $XMLContent .= "<packet_ref> <packID>$foo</packID> <packInfo>$bar</packINFO> </packet_ref>\n"; if (){ # if there are 10 packet_ref's send the XML and loop round + for the remainder my $XMLPacket; $XMLPacket = $XMLHead . $XMLContent . $XMLFoot; my $mech = WWW::Mechanize->new(); $mech->get( $TargetURL ); $mech->field( "xml_doc", $XMLPacket ); my $mechres = $mech->submit(); if ($mechres->is_success) { warn $mechres->decoded_content; return "Success"; }else{ warn $mechres->status_line, "\n"; return "Error"; } undef $XMLContent; } } }
In reply to Dynamically breaking up a data set by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |