in reply to Re^3: Explanation of Code Problem
in thread Explanation of Code Problem

I treid something like that;
while (@array) { $element = shift @array #other processing }


But, are you using the "?" as a place holder? How would I use the values of the @array in my $sql?

Replies are listed 'Best First'.
Re^5: Explanation of Code Problem
by Grygonos (Chaplain) on Jan 04, 2005 at 20:38 UTC

    Ok, I've tried to hand wave this enough.. give me a CLEAR explanation of where your data is coming from and where you want to put it.. then I can give you a 100% usable answer otherwise I'm just guessing

      Sure no problem simple,
      The code is too big and just his instance of it that is driving me crazy, but I can explain what the situation is.
      I have some code that runs a query and returns a bunch of found account numbers and I use the following code
      push @array_accnumber,$TOSUBACCOUNT
      And inside of this "sub - &ACCOUNT" I have to run another query on each element of the array @array_accnumber, and at the end use RETURN to return the values found for each account number

      $user = "myuser"; $pass = "mypass"; $dbh = DBI->connect("DBI:ODBC:MYDB",$user, $pass) || print "Connect to + MYDB fail: $!"; #Here the SQL will not contain the values. The values (@array_accnumbe +r) are passed in during each execution. #Instead of actually putting values in the sql,placeholders (?) are us +ed instead. #Then the statement can be reused a bunch of times with different data + sets. #It has a number of advantages with regards to security, performance, +and reusability. my $p_str = join ',', ('?') x @array_accnumber; print "<br><font color=navy><b>L 1437 - \$p_str - @array_claim</b></fo +nt><br>"; $sql= "SELECT C58MASTER.CCLM, C58MASTER.CLIN FROM C58MASTER WHERE C58 +MASTER.CCLM IN ( $p_str ) AND C58MASTER.CLIN=$X_LINE "; my $sth = $dbh->prepare( $sql ); $sth->execute( @array_claim )|| die $sth->errstr; while (my $pointer = $sth->fetchrow_hashref){ #more code here...till I can use RETURN of the result data found... } $sth->finish; #done

      But instead this code is working very slow and I am trying to optimize it by doing something to improve speed when processing this sub routine.
      Thank you, and I hope I explained better what I am looking for.