Re: Interesting issue with create()
[prev]
[thread]
[next]
[Date index for 2004/10/31]
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
Drew
--
----------------------------------------------------------------
Drew Taylor * Web development & consulting
Email: drew@xxxxxxxxxx.xxx * Site implementation & hosting
Web : www.drewtaylor.com * perl/mod_perl/DBI/mysql/postgres
----------------------------------------------------------------
|
(message missing)
|