Re: Interesting issue with create()

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

From: Jess Robinson
Subject: Re: Interesting issue with create()
Date: 06:37 on 31 Oct 2004
On Sat, 30 Oct 2004 13:14:38 -0400, Drew Taylor  
<taylor.andrew.j@xxxxx.xxx> wrote:

> On Sat, 30 Oct 2004 12:24:55 +0200, Jess Robinson
> <castaway@xxxxxxxxxxxxx.x.xxxx.xx> wrote:
>
>> 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.
>> But I don't see how to send that DEFAULT with CDBI either..
>
> How about using a before_create trigger to set the value of the
> primary column to 'DEFAULT'?
>
> MyClass->add_trigger('before_create' => \&before_create);
>
> sub before_create {
>   my $self = shift;
>   my $primary = $self->primary_column;
>   $self->_attribute_set($primary, 'DEFAULT');
> }

It's a nice idea, but as I feared, that doesn't work. I assume because it  
ends up quoting the 'DEFAULT' value before sending it to the database.

Hohum, I kind of cheated by doing this:

sub _insert_row
{
     my ($self, $data) = @_;
      delete $data->{category_id};
      $self->SUPER::_insert_row($data);
}

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