I'm getting the following error after attempting to insert into a table
where i have setup an oracle sequence:
DBIx::Class::ResultSet::create(): Can't get last insert id
This is happening because dbic is attempting to do a SELECT
STORE_CART_SEQ.CURRVAL FROM DUAL, without a preceding NEXTVAL.
Here's the create statement:
$c->model('StoreDB::Cart')->create({ session_id => $session_id });
I'm under the assumption that the NEXTVAL will be handled
automatically and that I don't need to specify anything in the create
Here's the table model:
package StoreDB::Cart;
use strict;
use base qw/DBIx::Class/;
use DateTime ();
__PACKAGE__->load_components(qw/PK::Auto Core InflateColumn::DateTime/);
__PACKAGE__->table('store_cart');
__PACKAGE__->add_columns(qw/cart_id session_id created updated/);
__PACKAGE__->set_primary_key('cart_id');
__PACKAGE__->sequence('store_cart_seq');
__PACKAGE__->has_many(items => 'StoreDB::Cart::Item', {
'foreign.cart_id' => 'self.cart_id'});
Here's the DBIC_TRACE:
-> DBI->connect(dbi:Oracle:XXXX, xxxx, ****, HASH(0xa2c02ec))
-> DBI->install_driver(Oracle) for linux perl=5.008007 pid=2781
ruid=501 euid=501
install_driver: DBD::Oracle version 1.16 loaded from
/usr/local/lib/perl5/site_perl/5.8.7/i686-linux/DBD/Oracle.pm
<- STORE('ShowErrorStatement' 1)= 1 at Oracle.pm <http://oracle.pm/> line 61
<- install_driver= DBI::dr=HASH(0xa6cf5a0)
ORACLE_HOME environment variable not set
<- connect('XXXXX' 'xxxxxx' ...)= DBI::db=HASH(0xa9333cc) at
DBI.pm line 625
<- STORE('RaiseError' 0)= 1 at DBI.pm line 672
<- STORE('PrintError' 0)= 1 at DBI.pm line 672
<- STORE('AutoCommit' 1)= 1 at DBI.pm line 672
<- STORE('Username' 'xxxx')= 1 at
DBI.pm line 675
<> FETCH('Username')= 'xxxx' ('Username' from cache) at DBI.pm line 675
<- connect= DBI::db=HASH(0xa9333cc)
<- STORE('dbi_connect_closure' CODE(0xa933468))= 1 at
DBI.pm line 691
<- FETCH('Driver')= DBI::dr=HASH(0xa6cf5a0) at DBI.pm line 630
<> FETCH('Name')= 'Oracle' ('Name' from cache) at DBI.pm line 630
INSERT INTO store_cart (session_id) VALUES (?):
'5d6630ab21bbffd47e534530e254ab39b7246656'
<- FETCH('Active')= 1 at DBI.pm line 538
<- ping= 1 at DBI.pm line 538
<- prepare_cached('INSERT INTO store_cart (session_id) VALUES (?)'
HASH(0xa990674) ...)= DBI::st=HASH(0xa990734) at
DBI.pm line 890
<- execute('5d6630ab21bbffd47e534530e254ab39b7246656')= 1 at DBI.pm line 782
<- FETCH('Active')= 1 at DBI.pm line 538
<- ping= 1 at DBI.pm line 538
<- FETCH('RaiseError')= '' at
DBI.pm line 906
<- STORE('RaiseError' undef)= 1 at DBI.pm line 906
<- STORE('RaiseError' 1)= 1 at DBI.pm line 906
<- FETCH('PrintError')= '' at DBI.pm line 907
<- STORE('PrintError' undef)= 1 at DBI.pm line 907
<- STORE('PrintError' 0)= 1 at DBI.pm line 907
<- column_info(undef undef ...)= DBI::st=HASH(0xa8efb6c) at DBI.pm line 910
<- execute= '0E0' at DBI.pm line 911
<- fetchrow_hashref= HASH(0xa8efec0)18keys row1 at DBI.pm line 913
<- fetchrow_hashref= undef row4 at DBI.pm line 922
<- DESTROY(DBI::st=HASH(a8efb00))= undef at
DBI.pm line 925
<- STORE('PrintError' '')= 1 at Oracle.pm <http://oracle.pm/> line 44
<- STORE('RaiseError' '')= 1 at Oracle.pm <http://oracle.pm/>
line 44
!! ERROR: '8002' 'ORA-08002: sequence STORE_CART_SEQ.CURRVAL is
not yet defined in this session (DBD ERROR: OCIStmtExecute)' (err#0)
<- selectrow_array('SELECT store_cart_seq.currval FROM DUAL')= (
undef ) [1 items] at
Oracle.pm <http://oracle.pm/> line 16
ERROR: '8002' 'ORA-08002: sequence STORE_CART_SEQ.CURRVAL is
not yet defined in this session (DBD ERROR: OCIStmtExecute)' (err#1)
<- DESTROY(DBI::st=HASH(a8efc80))= undef at
Oracle.pm <http://oracle.pm/> line 17
Any direction in the proper way to handle oracle sequences would be
greatly appreciate.
_______________________________________________
List: http://lists.rawmode.org/cgi-bin/mailman/listinfo/dbix-class
Wiki: http://dbix-class.shadowcatsystems.co.uk/
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/trunk/DBIx-Class/
Searchable Archive: http://www.mail-archive.com/[email protected]/