PEPPLER.ORG
Michael Peppler
Sybase Consulting
Menu
Home
Sybase on Linux
Install Guide for Sybase on Linux
General Sybase Resources
General Perl Resources
Freeware
Sybperl
Sybase::Simple
DBD::Sybase
BCP Tool
Bug Tracker
Mailing List Archive
Downloads Directory
FAQs
Sybase on Linux FAQ
Sybperl FAQ
Personal
Michael Peppler's resume

sybperl-l Archive

Up    Prev    Next    

From: Michael Peppler <mpeppler at mbay dot net>
Subject: Re: Using an array in SQL
Date: Aug 5 1998 1:14PM

> 
> Hi all:
> 
> I have an array that contains a list of keys I want to query
> on.
> eg
> @array = ("name1","name2","name3")
> 
> How can I pass the list in to my select statement ?
> I would like to do something like:
> $db->sql(qq#select * from tablea where name in (@array)#)

There are two things taht nbeed to be taken into account: one is the
list separator (,) abd the other is quoting. In your case you
need to quote all the names, which makes it a lot more complicated,
and I would probably suggest using a simple foreach() loop to handle
this case. When quoting is not needed you can set $" = ',' and simply
specify the array in the SQL string (like you did above).

Michael

PS. sorry for the typos, I'm typing this from telnetting from Switzerland
to my ISP in Monterey, CA...


> 
> Thanks
> 
> 
> 
> 
> 
> ***********************************************************************************
> Bear Stearns is not responsible for any recommendation, solicitation, offer or
> agreement or any information about any transaction, customer account or account
> activity contained in this communication.
> ***********************************************************************************
> 
>