in reply to Re: SQL ERROR
in thread SQL ERROR

I am doing some error checking. Here is my code:
sub executeQuery { eval{$sqlH = $dbh->prepare($sql);}; if ($@) {print "Database Error: " . $dbh->errstr();exit;} print "Prepared\n"; eval{$sqlH->execute();}; if ($@) {print "Database Error: " . $dbh->errstr();exit;} }

Replies are listed 'Best First'.
Re^3: SQL ERROR
by CountZero (Bishop) on Nov 15, 2004 at 19:10 UTC
    I think the error might be in your connect statement. Try something like

    my $dbh=DBI->connect(YOUR_CONNECT_INFO_HERE) or die "Cannot connect to the database: $DBI::errstr";

    and see what it says.

    CountZero

    "If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law

      I have connected to my database, using your method. I am trying to get a 7day week of anniversaries. I can get 2 days worth and then it errors off. See previous SQL statement. When I run the code i get the following error but it still runs
      Use of uninitialized value in string ne at Test.pl line 213.
        At least you got the database part working now.

        Pray, tell us now, what might be in line 213 of your script?

        I'm sorry but my crystal ball is not working today ;-)

        CountZero

        "If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law

        I am trying to get a 7day week of anniversaries.

        Since you are using DBD::CSV, I'm assuming you're not concerned with speed. Might I suggest you are using the wrong tool? I recommend Date::Manip for it's event and calendar functionality. It might require a little bit of work to massage your CSV file into the new format, but not as much as crafting new SQL statements for each specific time period, IMO.

        --Solo

        --
        You said you wanted to be around when I made a mistake; well, this could be it, sweetheart.
      I have a database connection statement.
        Do you care to share these lines of code with the Monastery?

        CountZero

        "If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law