in reply to Array, SQL Question!
First, your @array_num variable is getting populated with a single value the way that your code is written. Try this:
my @array_num = qw/123 456 345 459 234/;
Second, you never set $n1 and $n2 to anything. I'll assume that you want them to be the first and second values in your array.
my $n1 = $array_num[0]; my $n2 = $array_num[1];
Third, you really should be using placeholders (or bind parameters) in your $sql statement to safeguard against SQL injection attacks. This is not much of a problem in the statements as you've presented them, but it's really a good practice to get into. Read more about SQL placeholders.
So, finally, we have this:
my @array_num = qw/123 456 345 459 234/; my $n1 = $array_num[0]; my $n2 = $array_num[1]; my $sql= " SELECT tb.num1, tb.num2 FROM MYTABLE tb WHERE tb.num1 = ? AND tb.num2 = ?"; $sql->execute($n1, $n2);
EDIT: Per trammell's reply below.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Array, SQL Question!
by trammell (Priest) on Nov 11, 2004 at 21:05 UTC | |
|
Re^2: Array, SQL Question!
by Anonymous Monk on Nov 11, 2004 at 20:37 UTC | |
by Yendor (Pilgrim) on Nov 11, 2004 at 21:04 UTC | |
by tachyon (Chancellor) on Nov 11, 2004 at 22:45 UTC |