in reply to SQL error

Can you post your code? I guess you're having problems with string delimiters or something like that.

Replies are listed 'Best First'.
Re^2: SQL error
by Anonymous Monk on Aug 13, 2004 at 13:20 UTC
    #Windows-based Perl/DBI/MS Access example use DBI; #open connection to Access database $dbh = DBI->connect( "dbi:ODBC:driver=Microsoft Access Driver (*.mdb); +dbq=C:TestCasesXP2K.mdb", "", "" ); #prepare and execute SQL statement $stg = $dbh->prepare('SELECT REFERENCE, REQUIREMENTS FROM TestCasesOut +put WHERE PassFail = "fail"; $stg->execute || die "Could not execute SQL statement ... maybe invalid?"; """""THE ERROR OCCURS RIGHT HERE""""" $sth = $dbh->prepare('SELECT REFERENCE FROM TestCasesOutput'); $sth->execute || die "Could not execute SQL statement ... maybe invalid?"; #output database results $stt = $dbh->prepare('SELECT REQUIREMENT FROM TestCasesOutput'); $stt->execute || die "Could not execute SQL statement ... maybe invalid?"; #output database results while (@row=$stg->fetchrow_array) { @row1=$sth->fetchrow_array; @row2=$stt->fetchrow_array; open(fileOUT, ">>log.txt") or dienice("Can't open log.txt for writ +ing: $!"); flock(fileOUT, 2); seek(fileOUT, 0, 2); print fileOUT "Reference: @row1\n"; print fileOUT "Requirement: @row2\n\n\n\n"; } close(fileOUT);

    janitore<d by ybiC: Remove HTML markup formatting and replace with balanced <code> tags, as per Monastery convention

      Just what it seemed, close the quote in $stg = $dbh->prepare('SELECT REFERENCE, REQUIREMENTS FROM TestCasesOutput WHERE PassFail = "fail";

      Should be:

      $stg = $dbh->prepare('SELECT REFERENCE, REQUIREMENTS FROM TestCasesOutput WHERE PassFail = "fail"');

      BTW, try reading Writeups Formatting Tips and How do I post a question effectively?, they can help you a lot.

      deibyz