DBI ODBC

Discussion in 'Perl' started by Michael, Jan 6, 2004.

  1. Michael

    Michael Guest

    I have a small perl script that inserts data from a tab file to an Access
    database.

    my $sth = $dbh->prepare(<<SQL);
    INSERT INTO Notes ("Account Number", "NUM", "DESC", "UID", "NOTES")
    VALUES(?,?,?,?,?)
    SQL

    $sth->bind_param(1,$rec[0],SQL_VARCHAR);
    $sth->bind_param(2,$rec[1],SQL_VARCHAR);
    $sth->bind_param(3,$rec[2],SQL_VARCHAR);
    $sth->bind_param(4,$rec[3],SQL_VARCHAR);
    $sth->bind_param(5,$rec[4],SQL_VARCHAR);

    $sth->execute;

    ....


    The script is failing part way through the tab file with the error:

    DBD::ODBC::st bind_param failed: [Microsoft][ODBC Microsoft Access
    Driver]Invalid precision value ...


    Any help or hints about this error would be appreciated...


    Michael
     
    Michael, Jan 6, 2004
    #1
    1. Advertising

  2. Michael

    Michael Guest

    ok...I figured it out. For those of you interested:
    $sth->bind_param(5,$rec[4],SQL_VARCHAR); -> s.b.
    $sth->bind_param(5,$rec[4],SQL_LONGVARCHAR);

    Access requires the use of SQL_LONGVARCHAR ins this case as the field being
    inserted is quite large...


    thanks...


    Michael



    "Michael" <> wrote in message
    news:vGDKb.983972$9l5.525755@pd7tw2no...
    > I have a small perl script that inserts data from a tab file to an Access
    > database.
    >
    > my $sth = $dbh->prepare(<<SQL);
    > INSERT INTO Notes ("Account Number", "NUM", "DESC", "UID", "NOTES")
    > VALUES(?,?,?,?,?)
    > SQL
    >
    > $sth->bind_param(1,$rec[0],SQL_VARCHAR);
    > $sth->bind_param(2,$rec[1],SQL_VARCHAR);
    > $sth->bind_param(3,$rec[2],SQL_VARCHAR);
    > $sth->bind_param(4,$rec[3],SQL_VARCHAR);
    > $sth->bind_param(5,$rec[4],SQL_VARCHAR);
    >
    > $sth->execute;
    >
    > ...
    >
    >
    > The script is failing part way through the tab file with the error:
    >
    > DBD::ODBC::st bind_param failed: [Microsoft][ODBC Microsoft Access
    > Driver]Invalid precision value ...
    >
    >
    > Any help or hints about this error would be appreciated...
    >
    >
    > Michael
    >
    >
    >
     
    Michael, Jan 6, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Marc Ederis

    py2exe odbc:cannot import dbi module

    Marc Ederis, Mar 2, 2004, in forum: Python
    Replies:
    4
    Views:
    892
    Thomas Heller
    Mar 4, 2004
  2. Replies:
    5
    Views:
    452
  3. Dave Halliday
    Replies:
    3
    Views:
    187
    Dave Halliday
    Sep 12, 2003
  4. Oliver Osterholz

    DBI:ODBC-Question

    Oliver Osterholz, Nov 18, 2003, in forum: Ruby
    Replies:
    0
    Views:
    91
    Oliver Osterholz
    Nov 18, 2003
  5. Wes Gamble
    Replies:
    1
    Views:
    161
    Gerardo Santana Gómez Garrido
    Apr 5, 2006
Loading...

Share This Page