Re: [CDBI] Dealing with non-required primary keys

[prev] [thread] [next] [Date index for 2005/09/04]

From: Peter Speltz
Subject: Re: [CDBI] Dealing with non-required primary keys
Date: 11:46 on 04 Sep 2005
On 9/3/05, Rusty Phillips <rustyp@xxxxxxxxx.xxx> wrote:
> > > It's not really important to add a constraint to Class::DBI to handle
> > > the typename; the RDBMS will take care of that.  What is important is
> > > how to deal with the typeid.
> >
> > What do you mean - "how to deal with the typeid"?
> How to tell Class::DBI that the typeid is a generated by the database upo=
n insertion.

You do this by not specifying a sequence. From docs;

  sequence / auto_increment

               __PACKAGE__->sequence($sequence_name);

               $sequence_name =3D Class->sequence;
               $sequence_name =3D $obj->sequence;

       If you are using a database which supports sequences and you
       want to use a sequence to automatically supply values for the
       primary key of a table, then you should declare this using
       the sequence() method:

               __PACKAGE__->columns(Primary =3D> 'id');
               __PACKAGE__->sequence('class_id_seq');

       Class::DBI will use the sequence to generate a primary key
       value when objects are created without one.

       *NOTE* This method does not work for Oracle. However,
       Class::DBI::Oracle (which can be downloaded separately from
       CPAN) provides a suitable replacement sequence() method.

       If you are using a database with AUTO_INCREMENT (e.g. MySQL)
       then you do not need this, and any call to create() without a
       primary key specified will fill this in automagically.

       Sequence and auto-increment mechanisms only apply to tables
       that have a single column primary key. For tables with multi-
       column primary keys you need to supply the key values manu=AD
       ally.



--=20
pjs

_______________________________________________
ClassDBI mailing list
ClassDBI@xxxxx.xxxxxxxxxxxxxxxx.xxx
http://lists.digitalcraftsmen.net/mailman/listinfo/classdbi

(message missing)

[CDBI] Dealing with non-required primary keys
Rusty Phillips 01:20 on 04 Sep 2005

RE: [CDBI] Dealing with non-required primary keys
Rusty Phillips 02:39 on 04 Sep 2005

Re: [CDBI] Dealing with non-required primary keys
Peter Speltz 10:17 on 04 Sep 2005

Re: [CDBI] Dealing with non-required primary keys
Rusty Phillips 11:24 on 04 Sep 2005

Re: [CDBI] Dealing with non-required primary keys
Peter Speltz 11:44 on 04 Sep 2005

Re: [CDBI] Dealing with non-required primary keys
Peter Speltz 11:46 on 04 Sep 2005

Re: [CDBI] Dealing with non-required primary keys
Rusty Phillips 12:04 on 04 Sep 2005

Re: [CDBI] Dealing with non-required primary keys
Matt S Trout 12:12 on 04 Sep 2005

Generated at 13:57 on 10 Sep 2005 by mariachi v0.52