Preparing and executing a query with IN (?)
- From: "Vijoy Varghese" <thedifferenz@xxxxxxxxx>
- Date: 23 Feb 2006 02:06:49 -0800
Couldn't find a better Subject, sorry for that.
This is my querry
$GLOBALS{sql}{select_bill_items} = $dbh->prepare(qq{
SELECT
item_id,bill_id,item_type,description,quantity,amount
FROM
bill_items
WHERE
bill_id IN ( ? )
ORDER BY
item_id ASC
});
I have the query prepared.
Now I want to execute it.
foreach my $invoice(@invoices){
my @bill_ids = &getBillIds($invoice);
my $bill_ids = join(",",@bill_ids);
$GLOBALS{sql}{select_bill_items}->execute($bill_ids);
while(my @result =
$GLOBALS{sql}{select_bill_items}->fetchrow_array()){
# use fetched items...
}
}
here, say @bill_ids = (1,2,3,4,5);
then $bill_ids = "1,2,3,4,5";
The query was supposed to execute like this
SELECT
item_id,bill_id,item_type,description,quantity,amount
FROM
bill_items
WHERE
bill_id IN ( 1,2,3,4,5 )
ORDER BY
item_id ASC
But, its ignoring 2,3,4,5
that is, its getting executed like this
SELECT
item_id,bill_id,item_type,description,quantity,amount
FROM
bill_items
WHERE
bill_id IN ( 1 )
ORDER BY
item_id ASC
Can some one tell me what is wrong with my query/logic/program?
thanks
Vijoy~
.
- Prev by Date: DBD::Pg 1.44 released
- Next by Date: Re: Calling a PostgreSQL function via DBI
- Previous by thread: DBD::Pg 1.44 released
- Next by thread: Installation Issues
- Index(es):
Relevant Pages
|