[CDBI] ODBC / MS Access Carriage Return Problems

"James Hargreaves" <[email protected]>
Newsgroups gmane.comp.lang.perl.modules.class-dbi
Message-ID <[email protected]>
Hi everyone!

I'm having a bit of a problem with inserting data with carriage
returns into an MS Access database (via ODBC). If I remove the
carriage returns from my input it works fine, hence why I think there
is a problem. The error I receive is as follows:

DBD::ODBC::st execute failed: [Microsoft][ODBC Microsoft Access
Driver]Invalid precision value  (SQL-HY104)(DBD:
_rebind_ph/SQLBindParameter err=-1) [for Statement "INSERT INTO
newsitems (created, summary, story, title, news_category,
news_item_id)
VALUES (?, ?, ?, ?, ?, ?)
" with ParamValues: 6=undef, 1='2006-12-15', 4=undef, 3='e eiua oei
aoiue aiue oiau aoieuaoi eoaiue io e eiua oei aoiue aiue oiau aoieuaoi
eoaiue io e eiua oei aoiue aiue oiau aoieuaoi eoaiue io e eiua oei
aoiue aiue oiau aoieuaoi eoaiue io e eiua oei aoiue aiue oiau aoieuaoi
eoaiue io

aoiua oiua oiua iou oai uoiau oaiu', 2='aoiu eoiua eoiue oia eiuao i
eoiu a', 5=undef] at C:/Perl/site/lib/DBIx/ContextualFetch.pm line 52.

The statement works fine when I use MySQL as the backend database. I
don't think I should have to do the quoting myself for this - I would
have thought Class::DBI (well actually I'm using Class::DBI::MSAccess)
would do all that for me? The code where the problem occurs is fairly
simple:

  $s->debug .= $s->functions->dump($obj, 'obj');

  unless (eval { $module->create($obj) })
  { $MyPackage::errstr = $s->functions->handle_error($@);
    return undef;
  }

Has anyone got any idea why this doesn't work? Is there an easy fix,
without trying to quote the fields manually?

Another question - I note in the error message there are numerous
'undef' fields in the ParamValues list. These values are not undef -
as you can see from the object dump just prior to the create call:

obj : $VAR1 = {
          'created' => '2006-12-15',
          'story' => 'e eiua oei aoiue aiue oiau aoieuaoi eoaiue io e
eiua oei aoiue aiue oiau aoieuaoi eoaiue io e eiua oei aoiue aiue oiau
aoieuaoi eoaiue io e eiua oei aoiue aiue oiau aoieuaoi eoaiue io e
eiua oei aoiue aiue oiau aoieuaoi eoaiue io

aoiua oiua oiua iou oai uoiau oaiu',
          'summary' => 'aoiu eoiua eoiue oia eiuao i eoiu a',
          'title' => 'Test News Item 2',
          'news_category' => '13',
          'news_item_id' => '89329dfb745e7d76a5b93cc3798a21b1'
        };

Does anyone know what might be going on here? Is this a problem?? Or
is it caused by the carriage return problem above? As I say, it all
works fine with MySQL and if I remove the carriage returns...

Thanks
Jay

-- 
Bingo, bango, boshthedog.com
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.