using DBD::CSV with REAL numbers

From: Joseph Paish (jpaish_at_freenet.edmonton.ab.ca)
Date: 04/13/04

  • Next message: mholme_at_vf.shawcable.net: "Donkey Fucking 1087"
    To: dbi-users@perl.org
    Date: Tue, 13 Apr 2004 11:07:21 -0600
    
    

    does DBD::CSV not work with REAL numbers?

    the reason i ask is that the following piece of code works :
    (apologies for the word wrap)
    ########################
    #!/usr/bin/perl -w

    use DBI;

    $dbh = DBI->connect("DBI:CSV:f_dir=./db") or die "Cannot connect :" .
    $DBI::errstr ;

    $sth = $dbh->prepare("CREATE TABLE customer
                                 (custID INTEGER NOT NULL,
                                  family CHAR(30) NOT NULL,
                                  given CHAR(30))")
        or die "Cannot prepare : " . $dbh->errstr() ;

    $sth->execute() or die "Cannot execute : " . $sth->errstr() ;

    $sth = $dbh->prepare("INSERT INTO customer VALUES (124, 'Rice', 'Phil')")
        or die "Cannot prepare #2 : " . $dbh->errstr() ;

    $sth->execute() or die "Cannot execute #2 : " . $sth->errstr() ;

    # the table looks like this, and the code works :
    custID,family,given
    123,Scott,Phil
    47,Martin,Mary

    #######################

    but this doesn't :

    #######################

    #!/usr/bin/perl -w

    use DBI;

    $dbh = DBI->connect("DBI:CSV:f_dir=./db") or die "Cannot connect :" .
    $DBI::errstr ;

    $sth = $dbh->prepare("CREATE TABLE customer
                                 (custID INTEGER NOT NULL,
                                  family CHAR(30) NOT NULL,
                                  given CHAR(30))
                                   orderVal REAL(8,2))")
        or die "Cannot prepare : " . $dbh->errstr() ;

    $sth->execute() or die "Cannot execute : " . $sth->errstr() ;

    $sth = $dbh->prepare("INSERT INTO customer VALUES (124, 'Rice', 'Phil',
    0.99)")
        or die "Cannot prepare #2 : " . $dbh->errstr() ;

    $sth->execute() or die "Cannot execute #2 : " . $sth->errstr() ;

    # the table for this (failing code) looks like this :
    custID,family,given,orderVal
    123,Scott,Phil,100.00
    47,Martin,Mary,29.99

    #######################

    i got this example from the La Trobe University website, and it works fine
    except that if i use a REAL, it complains that

    'REAL(8' is not a recognized data type!

    any suggestions?

    thanks

    joe


  • Next message: mholme_at_vf.shawcable.net: "Donkey Fucking 1087"