in reply to SQL Query

Hi there

Consider taking off the semicolon from the end of your query. DBI doesn't need (or allow?) the semicolon, since it can only do one query per prepare. You will probably have better luck without the semicolon (I have never tried a query in DBI with a semicolon, so I don't know if this is expressly forbidden or not).

And as was mentioned before, a space between color and varchar(60)...

Also, try checking $DBI::errstr after you do the execute(), you will probably find something resembling a syntax error concerning colorvarchar(60) or an unknown column type MyISAM; (notice semicolon)..

good luck!
blokhead
  • Comment on Re: SQL Query (blokhead's first node that has a really really really really really really really really really really really really really really really really really really really really really really really really really really really rea
  • Select or Download Code

Replies are listed 'Best First'.
(jeffa) 2Re: SQL Query
by jeffa (Bishop) on Jan 11, 2002 at 08:23 UTC
    A bit of advice for you. I have been told this a couple of times myself at this site.;)

    Checking $DBI::errstr is best done when instantiating a DBI::db object, since you will not have a reference to the object if the connect fails. After the instantiation, say to the var $dbh, you should check the err() method or the more useful errstr() method: or die $dbh->errstr(). But....

    An even lazier solution is to force errors to raise exceptions via the RaiseError attribute. You do so by passing a hash ref to the constructor like so:

    my $dbh = DB->connect( 'DBI:vendor:database:host','user','pass', { RaiseError => 1}, );

    Now you don't have to 'or die' after every query (method call).

    Setting 'PrintError' to false is useful in conjunction with 'RaiseError' set to true when you use eval to catch exceptions, rather than die on them. Doing so supresses the 'error messages' that are generated when DBI calls die.

    just tryin to be helpful ;)

    jeffa

    L-LL-L--L-LL-L--L-LL-L--
    -R--R-RR-R--R-RR-R--R-RR
    F--F--F--F--F--F--F--F--
    (the triplet paradiddle)