Re: Interesting issue with create()

[prev] [thread] [next] [Date index for 2004/10/30]

From: Jess Robinson
Subject: Re: Interesting issue with create()
Date: 10:24 on 30 Oct 2004
On Sun, 24 Oct 2004 15:24:17 -0400, Perrin Harkins <perrin@xxxx.xxx> wrote:

> On Sun, 2004-10-24 at 13:50, Drew Taylor wrote:
>> My first thought is to patch create() to not accept values for the
>> primary key(s).
>
> Not all tables use an auto_increment or sequence, so specifying primary
> keys is necessary.

Hi,
I'm currently having problems with this. DB2's identity (generated by  
default as identity) fields seem to insist that in order to autogenerate a  
value, one just doesnt include this field at all, when using insert. So  
I'm getting the following error:

Tk::Error: Can't insert new Bank::Category: DBD::DB2::st execute failed:  
[IBM][CLI Driver][DB2/LINUX] SQL0407N  Assignment of a NULL value to a NOT  
NULL column "TBSPACEID=2, TABLEID=6, COLNO=0" is not allowed.   
SQLSTATE=23502
  [for Statement "INSERT INTO Categories (category_id, essential, name)
VALUES (?, ?, ?)
"] at /usr/lib/perl5/site_perl/5.8.4/DBIx/ContextualFetch.pm line 51.
  at bankdb.pl line 226
  DBIx::ContextualFetch::st::_untaint_execute at  
/usr/lib/perl5/site_perl/5.8.4/DBIx/ContextualFetch.pm line 51
  DBIx::ContextualFetch::st::execute at  
/usr/lib/perl5/site_perl/5.8.4/DBIx/ContextualFetch.pm line 31
  Carp::croak at /usr/lib/perl5/5.8.4/Carp.pm line 191
  Class::DBI::_croak at /usr/lib/perl5/site_perl/5.8.4/Class/DBI.pm line 233
  Class::DBI::_insert_row at /usr/lib/perl5/site_perl/5.8.4/Class/DBI.pm  
line 644
  Class::DBI::_create at /usr/lib/perl5/site_perl/5.8.4/Class/DBI.pm line  
590
  Class::DBI::create at /usr/lib/perl5/site_perl/5.8.4/Class/DBI.pm line 470

Changing the definition to 'generated always as identity' (which means you  
cant supply the value yourself), gets a similar error:

SQL0798N  A value cannot be specified for column "CATEGORY_ID" which is
defined as GENERATED ALWAYS.  SQLSTATE=428C9

The help about this says that one can also get the right efffect by  
sending something like:
INSERT INTO Categories ( category_id, essenial, name)
VALUES(DEFAULT, 1, 'blah')

But I don't see how to send that DEFAULT with CDBI either..

Any ideas?

Jess

        -- 
        Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/

(message missing)

Interesting issue with create()
Drew Taylor 17:50 on 24 Oct 2004

Re: Interesting issue with create()
Perrin Harkins 19:24 on 24 Oct 2004

Re: Interesting issue with create()
Jess Robinson 10:24 on 30 Oct 2004

Re: Interesting issue with create()
Drew Taylor 17:14 on 30 Oct 2004

Re: Interesting issue with create()
Jess Robinson 06:37 on 31 Oct 2004

Re: Interesting issue with create()
Drew Taylor 18:07 on 31 Oct 2004

Re: Interesting issue with create()
Lance A. Brown 18:21 on 31 Oct 2004

Re: Interesting issue with create()
Jess Robinson 06:31 on 02 Nov 2004

Re: Interesting issue with create()
Jess Robinson 06:28 on 02 Nov 2004

Generated at 11:34 on 01 Dec 2004 by mariachi v0.52