You are viewing a plain text version of this content. The canonical link for it is here.
Posted to embperl@perl.apache.org by Terrence Brannon <me...@urth.org> on 2003/12/23 11:04:34 UTC

Re: DBIx::Recordset updates dying with ambiguous column errors

Joshua Gerrish wrote:

> I'm not sure if this is the right place to ask about DBIx::Recordset, 
> my apologies if it isn't.

The original author of DBIx::Recordset hangs out on his HTML::Embperl 
list and answers questions there:

     http://perl.apache.org/embperl/pod/doc/Embperl.-page-12-.htm

>
> The error I'm getting is this:  "DB:  ERROR Column: 'id' in where 
> clause is ambiguous"
>
> The problem, as far as I can see, is that I've got a recordset with 
> two tables in it, and both have an id field.  When it goes to update a 
> field, it uses id as the primary key, but it doesn't qualify it with a 
> table name, so the query bombs out.
>
> Is there any way to specify which table is the "primary" table?  For 
> example, in my database I've got a table called referrers that has a 
> 1-1 relationship with a table called accounts.  referrers.account_ref 
> points to accounts.id.  But referrers also has an id field.  I want to 
> specify for the !PrimKey parameter that it is in table referrers.


Can't you table-qualify the field name? E.g.

'!PrimKey' => 'accounts.id'

>
> Here's a copy of my setup parametrs:
>
>    $self->{set} = DBIx::Recordset->Setup({'!DataSource' => 
> 'dbi:mysql:referrals',
>                        '!Table'      => 'referrers, accounts',
>                        '!TabRelation' => 'referrers.account_ref = 
> accounts.id',
>                        '!PrimKey'      =>  'id',
>
>                        '!Links'      => ...
>
> Any help would be cool.





---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org