On Mon, 2004-03-22 at 18:04, Guay Jean-SÃbastien wrote:
> Hello Mike,
>
> > $row=$dbh->prepare("SELECT contact_id,first_name,last_name,organisation
> > FROM tb_contacts WHERE organisation ILIKE ?");
>
> [...]
>
> > while(($id,$first_name,$last_name,$organisation) = $row->fetchrow_array())
> {
>
> [...]
>
> > $row=$dbh->prepare("SELECT id,contact_id,type_of_contact,priority FROM
> > tb_contact_role WHERE contact_id ILIKE ?");
>
> [...]
>
> >}
>
> [...]
>
> > This only produces on record at the top-level, if I dont have the select
> > inside the loop, then all matching records appear
> >
> > Anyone any idea where I am going wrong
>
> You are using the same variable as the statement handle for both queries
> ($row). In effect, since your second SELECT probably returns only one row
> (probably the detail of the contact you got in the first SELECT), the
> enclosing while ends afterwards because there are no more rows to get from
> that statement handle (the second SELECT).
>
Yeah I worked this out just after I posted.
> I would suggest you declare a new variable inside your while, say $contact.
> Something like this:
>
> my $contact = $dbh->prepare(qq[SELECT id, contact_id, type_of_contact,
> priority
> FROM tb_contact_role
> WHERE contact_id ILIKE ?]);
>
> I also suggest better indentation and whitespace usage in your code. That
> will get very hard to read very fast...
>
> Hope that helps,
>
> J-S
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>