[CDBI] Can't insert a null record?

"Eduardo Grosclaude" <[email protected]>
Newsgroups gmane.comp.lang.perl.modules.class-dbi
Message-ID <[email protected]>
Dear Gentlemen,

I am using CDBI from CGI::Application callback routines. My table "Dictado"
has been created with:
        CREATE TABLE dictado (
            did integer NOT NULL PRIMARY KEY AUTOINCREMENT,
            mid integer,
            ...

Upon returning from edition/insertion page, I want to have the following
done:

    if(defined $q->param('submit')) {
        my $d;
        if($q->param('did') == 0) {
            $d = Ctl::Dictado->create({});
        } else {
            $d = Ctl::Dictado->find_or_create(did => $q->param('did'));
        }
        foreach my $f (qw/... names of fields ... /) {
            $d->${f}($q->param($f));
        }
        $d->update;
    }

As you can see, when did==0, I want to create a blank object and then
populate fields with values coming from $q query object. There may be other
ways to do the trick, but this particular one USED TO WORK. However, now I
get:

Error executing run mode 'dic': Can't insert new Ctl::Dictado:
DBD::SQLite::db prepare_cached failed: near ")": syntax error(1) at
dbdimp.cline 269 [for Statement "INSERT INTO dictado ()
VALUES ()
"] at /usr/lib/perl5/site_perl/5.8.6/Ima/DBI.pm line 381.
 at /var/www/html/linux/admin/admin.pl line 256
 at /usr/lib/perl5/site_perl/5.8.6/CGI/Application.pm line 160
    CGI::Application::run('Admin=HASH(0x9650de8)') called at
/var/www/html/linux/admin/admin.pl line 517

I understand CDBI has undergone some change as I can no longer find any
reference to the create() function in the docs. However, insert() does
exist, which I had not known of before.

I have tried insert(), insert({}), find_or_create(did => 0), but every time
some kind of error creeps up. Can I have any way to insert a null record so
as to keep the logic presented above? Or, is the above logic hopelessly
flawed?

Thank you in advance

sqlite-devel-3.1.2-3
sqlite-3.1.2-3

       Tue May 16 17:35:17 2006: "Module" DBD::SQLite
       ·   "installed into: /usr/lib/perl5/site_perl/5.8.6"
       ·   "LINKTYPE: dynamic"
       ·   "VERSION: 1.12"
       ·   "EXE_FILES: "
       Tue May 16 17:48:31 2006: "Module" Class::DBI
       ·   "installed into: /usr/lib/perl5/site_perl/5.8.6"
       ·   "LINKTYPE: dynamic"
       ·   "VERSION: v3.0.14"
       ·   "EXE_FILES: "


-- 
Eduardo Grosclaude
Universidad Nacional del Comahue
Neuquen, Argentina

_______________________________________________
ClassDBI mailing list
ClassDBI-Ra3b/[email protected]
http://lists.digitalcraftsmen.net/mailman/listinfo/classdbi
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.