in reply to Undefined value from DBI

Hi,

that's a hint that your line

my $sth = $dbh->prepare($sql);

results in an error assigning undef to $sth.

Without handle attribute RaiseError you have to check EVERY DBI call for errors. So in this case it's probably a simple SQL error.

Change the prepare line to

my $sth = $dbh->prepare($sql) or die "Prepare Error: $DBI::errstr";

Regards
McA

Replies are listed 'Best First'.
Re^2: Undefined value from DBI
by Anonymous Monk on Sep 10, 2014 at 17:17 UTC
    I know, the issue is how I use this kind on SQl statement with out causing any errors, if I use a simple
    "select * from my_table"
    it works, but because of the nature of the SQL statement DBI does not like it, and it gets worse by trying to add place holders to it.
      Which database are you using ? Your code works fine for me on MS SQL Server Express.
      poj

      Sorry, I misuderstood your question.

      In such cases I try these SQL statements in a database dependant client to find out what is wrong. Any hints from that?

      McA