[Dbix-class] last insert id problem with Oracle

Matt S Trout dbix-class at trout.me.uk
Mon Jul 10 22:24:01 CEST 2006


Anthony Lincoln wrote:
> Matt S Trout wrote:
>> Anthony Lincoln wrote:
>>
>>> package ccm::Model::CCMData::Issweb::CcmChange;
>>>
>>> use strict;
>>> use warnings;
>>> use base 'DBIx::Class::Core';
>>>
>>> __PACKAGE__->load_components(qw/PK::Auto Core/);
>>> __PACKAGE__->table('ccm_change');
>>> __PACKAGE__->add_columns(qw/id owner name prereq_id dependent description
>>>                          backout_plan visibility risk sys_criticality
>>>                          sys_affected qa_difficulty install_difficulty
>>>                          problem_visibility completed creator created/);
>>> __PACKAGE__->set_primary_key('id');
>>> __PACKAGE__->sequence('ccm_seq');
>>
>> Is your sequence "just a sequence" or do you have a trigger defined to 
>> populate ccm_change from it? PK::Auto expects the database to populate the key 
>> during INSERT; it doesn't read the sequence to populate it itself.
> 
> There's a trigger defined to autoincrement ccm_change.id.  All that 
> seems to work fine.
> 
> CREATE TRIGGER ccm_user_trig
>          BEFORE INSERT ON ccm_user
>          FOR EACH ROW
>          BEGIN
>                  SELECT ccm_seq.nextval INTO :new.id from dual;
>          END;
> .
> RUN;

That's on ccm_user, not ccm_change. Pasted the wrong trigger or did we just 
spot a typo?

(and dammit would somebody who's got live DBIC code on Oracle weigh in please, 
I've done both in isolation but nobody's wanted to pay shadowcat for the 
combination yet :)

-- 
      Matt S Trout       Offering custom development, consultancy and support
   Technical Director    contracts for Catalyst, DBIx::Class and BAST. Contact
Shadowcat Systems Ltd.  mst (at) shadowcatsystems.co.uk for more information

+ Help us build a better perl ORM: http://dbix-class.shadowcatsystems.co.uk/ +



More information about the Dbix-class mailing list