in reply to Re: Re: A question of style.
in thread A question of style.
And now, rather than declaring and preparing the queries once per array element, you can lift them outside the loops:
That's why placeholders rock :-)my $sth = $db->prepare("SELECT curr_parent_id FROM demstock2 WHERE ds_ +id=?"); my $move_sth = $db->prepare("UPDATE demstock2 SET curr_parent_id=? WHE +RE ds_id=?"); my $action_sth = $db->prepare(" INSERT INTO action (action_id, action_type, ds_id, occurred, ref_no, staff_id) +VALUES (NULL, 'MOVE', ?, CURRENT_TIMESTAMP, ?, ?)"); for my $child (@built, @acc) { #Find out if it still is in free stock $sth->execute($child) or ... my $current_status = $sth->fetchrow_hashref; if($current_status->{"curr_parent_id"} != 0) { print ...; next; } $move_sth->execute($main, $child) or ... $action_sth->execute($child, "0,$main", $caluser) or ...; }
--
Tommy
Too stupid to live.
Too stubborn to die.
|
|---|