PDA

View Full Version : SQL statement failing


macchisp
09-11-2007, 08:09 PM
I have a SQL statement that works in one script, and not in another. They are exactly the same statement, but the only difference is one I am using the #!/usr/local/bin/perl and the other I'm using #!/usr/bin/perl. (I know it seems odd that these are different but the boxes are a mess and it's what I have to work with!)

I am using the module DBI and the local bin has version 1.59 while the usr bin uses 1.48. The one in the usr bin works correctly.

Here is my SQL Statement:
SELECT * FROM JPDAR WHERE Position = '$Cposition' AND Year = '$Year'

I think it is failing because of the AND. I have tested by removing the AND and only using WHERE Position = '$Cposition' or Year = '$Year' and it works fine.

Has anyone run into a similar problem like this before? I know it seems wierd, but I am out of things to test.

Thanks for all your assistance on this.

Brodyaga
09-11-2007, 08:18 PM
Did you have any SQL-errors when executing this query?
Which database engine you use?

macchisp
09-11-2007, 09:39 PM
I did not receive any errors with this select statement. For the one that it worked, it returned the correct fields it was supposed to. For the one that did NOT work it did not return anything. I'm pretty sure it would execute (tested by putting print statements before and after).

By database engine, I don't know what you are asking. The database is csv and here is my database call.

my $ardbh = DBI->connect(qq{DBI:CSV:csv_eol=\n;csv_sep_char=\\~});
$ardbh->{'csv_tables'}->{'JAR'} = {'file' => 'data/annualreport.txt','col_names' => ["Position","Year","ExecSummary","Mission","ChangesInMission","PnPAccompl","Other","Addenda","UnitChallenges","pdf"]};
$ardbh->{'RaiseError'} = 1;
$@ = '';

Thanks!