in reply to undefined value as a hash reference?

Assumption: you are using DBI.

First, I would use placeholders:

my $SQL_UserUpdate = q(update ClassRoster set Reminded={ fn NOW() } wh +ere idEnrollee = '?'); ... ... $stmt = $db->prepare($SQL_UserUpdate); $stmt->execute($RS_UsersToRemind->Fields('idEnrollee')->{Value});

However, the real cause of the error is that, because your string is in single quotes, the parser is trying to resolve the stuff between "{" and "}" as a hashref. Since fn NOW() apparently has a value of undef, {undef} generates the error you are seeing. what ccn said above.

--MidLifeXis

Replies are listed 'Best First'.
Re^2: undefined value as a hash reference?
by grashoper (Monk) on Nov 05, 2008 at 08:31 UTC
    These are the errors I get what could be the problem?
    prepare('SELECT ClassSchedule.EventDate AS EventDate,DATEDIFF(Day,{fn +NOW()},ClassSchedule.EventDate) AS Until,,DATEDIFF(Day,ClassRoster.En +rolled, ClassSchedule.EventDate) AS Since,,Classes.Duration AS Durati +on, Classes.Topic AS Topic, Classes.Description AS Description, ClassLocation.Location AS Location, ClassLocation.Address AS Address, ClassLocation.Directions AS Directions, Cl...')= DBI::st=HASH(0x37642dc) at test5.pl line 55 !! ERROR: 1 '[Microsoft][ODBC SQL Server Driver][SQL Server]Line 1 +: Incorrect syntax near ','. (SQL-42000) [Microsoft][ODBC SQL Server Driver][SQL Server]Statement(s) could not +be prepared. (SQL-42000)' (err#2) <- execute= undef at test5.pl line 57 ERROR: 1 '[Microsoft][ODBC SQL Server Driver][SQL Server]Line 1 +: Incorrect syntax near ','. (SQL-42000) [Microsoft][ODBC SQL Server Driver][SQL Server]Statement(s) could not +be prepared. (SQL-42000)' (err#2) <- DESTROY(DBI::st=HASH(37641ec))= undef at test5.pl line 57 ERROR: 1 '[Microsoft][ODBC SQL Server Driver][SQL Server]Line 1 +: Incorrect syntax near ','. (SQL-42000) [Microsoft][ODBC SQL Server Driver][SQL Server]Statement(s) could not +be prepared. (SQL-42000)' (err#0) <- DESTROY(DBI::db=HASH(376401c))= undef at test5.pl line 57 !! ERROR: 1 CLEARED by call to disconnect_all method <- disconnect_all= '' at DBI.pm line 715 ! <- DESTROY(DBI::dr=HASH(3763b8c))= undef during global destruction

      Search for m/,,/, you have Since,,Classes.Doration. I would guess that this would be the cause.

      --MidLifeXis

        I removed the comma and now I get invalid syntax near DATEDIFf, this query is driving me crazy! It works fine on sql server, I have been stuck on this problem for days.