Gay, Jerry on 20 Sep 2004 20:08:32 -0000


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

sql, dbi, placeholders and 'in'


i have a bunch of sql queries that have the form:

	select fields
	from table
	where
	 product in ('a', 'b', 'c', ...)
	 and
	 document in ('1', '2', '3', ...)
	;

i don't know up front how many values will be in the in() clause, and i
can't seem to find a way to easily build these queries and run them through
dbi with placeholders.

is there a module that will help me create these queries on the fly, or am i
stuck with concatenating the bits together like

my $sql= 'select fields from table where '
	. 'product in (' . join( ', ' => ( ('?')x@products) ) . ')'
	. 'document in (' . join( ', ' => ( ('?')x@documents) ) . ')'
;

~jerry



************************************************************************** 
This e-mail and any files transmitted with it may contain privileged or 
confidential information. It is solely for use by the individual for whom 
it is intended, even if addressed incorrectly. If you received this e-mail 
in error, please notify the sender; do not disclose, copy, distribute, or 
take any action in reliance on the contents of this information; and delete 
it from your system. Any other use of this e-mail is prohibited. Thank you 
for your compliance.



-
**Majordomo list services provided by PANIX <URL:http://www.panix.com>**
**To Unsubscribe, send "unsubscribe phl" to majordomo@lists.pm.org**