Re: Interesting issue with create()

[prev] [thread] [next] [Date index for 2004/11/02]

From: Jess Robinson
Subject: Re: Interesting issue with create()
Date: 06:31 on 02 Nov 2004
On Sun, 31 Oct 2004 13:07:37 -0500, Drew Taylor  
<taylor.andrew.j@xxxxx.xxx> wrote:

> On Sun, 31 Oct 2004 07:37:18 +0100, Jess Robinson
> <castaway@xxxxxxxxxxxxx.x.xxxx.xx> wrote:
>> 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.
>
> I remember an article on the wiki [1] that mentions overriding the
> default SQL used for creating new entries. This would avoid the
> quoting issue you ran into.
>
> [1] http://www.class-dbi.com/cgi-bin/wiki/index.cgi?SettingDefaultValues

Yup, I could have done. It's just as fugly as my actual solution though.

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