in reply to Dynamic Query

Hi I don't understand your loop syntax but assuming you have your list in @array as shown this works fine:

my @array = (10,15,20); my $where_list = ''; foreach my $index (0..$#array) { $where_list .= ($index) ? "and\n" : "where\n"; $where_list .= " company_id='$array[$index]'\n"; } $sql = <<END_SQL; select comp_name from companies $where_list END_SQL print $sql;

We just loop over the array assigning the index to $index. We build up out $where_list. When $index == 0 we add 'where' otherwise we add 'and'. We then add the company_id bit. Finally we just interpolate the $where_list into your $sql herepage

Hope this helps.

BTW Do you really mean 'and' or should it be 'or'?

cheers

tachyon

s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print