[Catalyst] Catalyst and Oracle
Simon Miner
sminer at christianbook.com
Mon Aug 15 20:07:33 CEST 2005
Hi,
I am researching the possibility of integrating Catalyst into my
company's high-traffic e-commerce site. My firm uses Oracle as its
production database, so I am trying to get Catalyst and Oracle to work
together. As a first stab, I am trying to get the MiniMojo Wiki from
the perl.com article (which I successfully set up) to use Oracle.
Here's what I've done so far...
* Created a table called "page" in Oracle with the same structure
as the SqlLite version in the article.
* Updated the MiniMojo::M::CDBI package to use dsn to connect to
our Oracle database.
* Installed Class::DBI::Oracle and Class::DBI::Loader::Oracle
(since they didn't come with the Class::DBI or Catalyst packages).
* Created an Oracle sequence called "page_seq" according to the
convention outlined in the Class::DBI::Oracle docs.
* Added a constraint => '^page$' argument to the call to config()
in MiniMojo::M::CDBI, so it wouldn't try to load all of the tables in
the (very large) Oracle database. (Is this the best/only way to specify
which tables to load?)
* Browsed to http://localhost:3000 <http://localhost:3000/> and
got the following error.
Caught exception "Can't insert new MiniMojo::M::CDBI::Page:
DBD::Oracle::st execute failed: ORA-01400: cannot insert NULL into
("CBD"."PAGE"."ID") (DBD ERROR: OCIStmtExecute) [for Statement "INSERT
INTO page (title, id) VALUES (?, ?) " with ParamValues: :p1='Frontpage',
:p2=undef] at
/usr/local/lib/perl5/site_perl/5.8.3/DBIx/ContextualFetch.pm line 51. at
/home/simon/catalyst/MiniMojo/script/../lib/MiniMojo/C/Page.pm line 41"
It appears that the MiniMojo::M::CDBI::Page class isn't using the
page_seq sequence. I looked at the source for this class and noticed it
doesn't appear to do anything whatsoever (not even declare a base
class). There must be magic at work here. Nonetheless, I tried adding
the following code, but to no avail.
use base 'MiniMojo::M::CDBI';
__PACKAGE__->set_up_table( 'page' );
Can anyone tell me why the Page class is not finding its sequence or
using this code? How can I code logic and configuration specific to
this table?
Also, is there a way to bypass the Class::DBI::Loader action at server
startup in favor of explicitly defining table columns, sequences, etc?
The auto-loading is a great feature, but it takes a while for the query
to run against the user_tables view for our large database. Along this
same line, when auto-generating model classes, the minimojo_create.pl
help script crashes if it hits a "bad" table (i.e. one without a primary
key). Is there a way to be more specific about which tables the helper
script loads (ala the "constraint" parameter in the call to config())?
Thanks for your help.
- Simon
-----------------------------------------------
Simon Miner
Applications Engineer
Christianbook.com
E: sminer at christianbook.com <mailto:sminer at christianbook.com>
T: (978) 573-2233
F: (978) 573-8233
-----------------------------------------------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.rawmode.org/pipermail/catalyst/attachments/20050815/5e7be910/attachment-0001.htm
More information about the Catalyst
mailing list