[CDBI] Class::DBI classes with a default primary key

marcus baker marcus.baker at gmail.com
Tue Aug 23 18:51:01 BST 2005


i've inherited a table from someone else (that i'd rather not alter),
setup somewhat like this:

CREATE TABLE mytable (
    userid  INTEGER NOT NULL,
    building VARCHAR2 (100),
    room VARCHAR2 (100),
    browser VARCHAR2 (500),
    cdate TIMESTAMP(6) DEFAULT current_timestamp NOT NULL
)

note that nothing is auto incremented, and that no actual primary keys
have been set.

i'd like to integrate the table into Class::DBI, defining the two
columns of 'userid' and 'cdate' as primary keys.  create() fails under
that setup, as Class::DBI wants both primary keys defined in the
hashref passed in.  is there a way to let Class::DBI proceed creating
without having specified the cdate column, since it's generated by the
system?

i understand that i could programmatically set the cdate column in the
hashref passed to the create() method, just alter the table to have
'real' primary keys, or just set any other column as a primary key and
run the search() method instead of retrieve() when it's needd, but i
would like to know this kind of information for future reference.

thanks
-marcus




More information about the ClassDBI mailing list