Don't believe you can do this then, you can either write a stored procedure
and then execute with DBI or programmatically check within you Perl code
while fetching.

Ilya Sterin

-----Original Message-----
From: [EMAIL PROTECTED]
To: [EMAIL PROTECTED]; Sterin, Ilya
Cc: [EMAIL PROTECTED]
Sent: 05/01/2001 9:12 AM
Subject: RE: sql table joins

Hello IIya,
I forgot one important thing the tables are in two different databases
(that
is why I have two connect statements). This is why I can't figure out
how to
write the prepare statement. If they were on the same database your
suggestions would work fine.

Willie McSweeney
Memory Component Engineer
EMC,
Ovens, 
Co.Cork, Ireland.
Tel +00353-21-4281412
Fax +00353-21-4281898
Email <[EMAIL PROTECTED] >


> -----Original Message-----
> From: McSweeney, William 
> Sent: Tuesday, May 01, 2001 3:47 PM
> To:   'Sterin, Ilya'
> Cc:   '[EMAIL PROTECTED] '
> Subject:      RE: sql table joins
> 
> Hi IIya,
> Thanks for the reply. I know that your suggestion will work but how do
I
> construct the prepare statement in DBI
> If I do something like
> $dbh = DBI->connect ('dbi:ODBC:TotalBoards', 'user', 'password') or
die
> "could not CONNECT $!";
> $dbh_aml = DBI->connect ('dbi:ODBC:AML', 'user', 'password') or die
"could
> not CONNECT $!";
> 
> $sth = $dbh->prepare(qq{SELECT TotalBoards.EMC_PN FROM TotalBoards,
> AMLMaster WHERE TotalBoards.SYMPTOM_CODE LIKE ? AND TotalBoards.EMC_PN
=
> AMLMaster.AMLPN AND TotalBoards.REC_DATE BETWEEN ? AND ?}) or die
> "Couldn't prepare statement: " . $dbh->errstr;
> 
> I get an error "invalid object name AMLMaster". This is I guess
because
> $dbh is the connection to TotalBoards and knows nothing about the AML
> database . I have another $dhh_aml connecting to AMLMaster. My
question is
> how do you write a prepare statement as above that works. Can you get
$dbh
> to connect to both tables at the same time??? 
> Willie 
> 
> 
> Willie McSweeney
> Memory Component Engineer
> EMC,
> Ovens, 
> Co.Cork, Ireland.
> Tel +00353-21-4281412
> Fax +00353-21-4281898
> Email <[EMAIL PROTECTED] >
> 
> 
>       -----Original Message-----
>       From:   Sterin, Ilya [SMTP:[EMAIL PROTECTED]]
>       Sent:   Tuesday, May 01, 2001 3:19 PM
>       To:     '[EMAIL PROTECTED] '; '[EMAIL PROTECTED] '
>       Subject:        RE: sql table joins
> 
>       You sure can, that's just a simple join, but you have to also
use
> the table2
>       in the from clause.  Like this...
> 
>       SELECT table1.failed_parts FROM table1, table2 WHERE
> table1.failed_parts =
>       table2.valid_parts;
> 
>       Ilya Sterin
> 
> 
> 
>       -----Original Message-----
>       From: [EMAIL PROTECTED]
>       To: [EMAIL PROTECTED]
>       Sent: 05/01/2001 8:04 AM
>       Subject: sql table joins
> 
>       Hi,
>       I am using perl DBI to access an sql server database.
>       One table has component part numbers that have failed, keyed in
by
>       operators. I need to read in and count these which is no problem
but
> I
>       also
>       need to compare them with an approved parts table to make sure
that
> they
>       are
>       valid part numbers. Currently I am doing this by reading the
failed
>       parts
>       into a hash and then using the hash keys as placeholders to
query
> the
>       parts
>       valid table. 
>       Is it possible with DBI to do something like 
>       SELECT table1.failed_parts FROM table1 WHERE table1.failed_parts
=
>       table2.valid_parts
> 
>       thanks Willie
> 
> 
>       Willie McSweeney
>       Memory Component Engineer
>       EMC,
>       Ovens, 
>       Co.Cork, Ireland.
>       Tel +00353-21-4281412
>       Fax +00353-21-4281898
>       Email <[EMAIL PROTECTED] >

Reply via email to