Does PostgreSQL subbot temp tables?  If so, use a temp table and join to it.  If not, 
you will need to place these values into a comma-delimited string.

-----------------
Ron Reidy
Lead DBA
Array BioPharma, Inc.


-----Original Message-----
From: Kamran [mailto:[EMAIL PROTECTED]
Sent: Monday, September 27, 2004 12:20 PM
To: [EMAIL PROTECTED]
Subject: passing array as subquery to a SQL query


Hello all,
I am new to the list. 

I am trying to achieve a goal in PERL. That is:
I have a table say students with fields (id int, name char(10) ) .
I have data like:-

ID      NAME
==      ==========
1       Kamran
2       Imran
3       Amir
4       Abid


I have an array in perl as :-

my @ids = (1,2,3) ;


I want to select those records from the table students , which do not
have ID in the array @ids. (This should give me 4 and 'Abid' ) .

I am trying to do it as the follwoing code:-

########################## code snip start #########################
my @ids = (1,2,3) ;

my $SQL = "select * from students where id in (@ids)";

# I am using the syntax of subquery in the above line .

my $sth = $slavedbh->prepare($SQL) || die "Cannot prepare SQL
statement\n";

my $howmany = $sth->execute || die "Cannot select from table\n";

######################### code snip end ############################


I am using Postgresql 7.3 on Redhat Linux 9. I have perl 5. Rather
everything is what comes bundled with Redhat 9. nothing extra.

I don't know if this problem has been addressed in past. If so please
point me in the right direction.


Thanks in advance for your time and help.

Kamran


This electronic message transmission is a PRIVATE communication which contains
information which may be confidential or privileged. The information is intended 
to be for the use of the individual or entity named above. If you are not the 
intended recipient, please be aware that any disclosure, copying, distribution 
or use of the contents of this information is prohibited. Please notify the
sender  of the delivery error by replying to this message, or notify us by
telephone (877-633-2436, ext. 0), and then delete it from your system.

Reply via email to