[Dbix-class] last insert id problem with Oracle
Anthony Lincoln
ahlincoln at lbl.gov
Mon Jul 10 22:16:49 CEST 2006
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;
More information about the Dbix-class
mailing list