Hi,
I'm hitting difficulty in formatting an UPDATE statement, because I need
to use both % and _ in it.
I need to change the status of records where the last three characters
are underscore, followed by two numbers.
>From dbish, the following works fine:
UPDATE table2 SET Status = 110 WHERE Status <> 110 AND Key LIKE '%\___'
ESCAPE '\'
However I've tried various different ways of quoting and escaping etc.
from within my script, but the execute always fails...
<- quote= ''UPDATE table2 SET Status = 110 WHERE Status <> 110 AND
Key LIKE ''%\___'' ESCAPE ''\'''' at insert.sql line 51
<- prepare(''UPDATE table2 SET Status = 110 WHERE Status <> 110 AND
Key LIKE ''%\___'' ESCAPE ''\'''' CODE)= DBI::st=HASH(0x140012d88) at
insert.sql line 53
!! ERROR: -1 '[OpenLink][ODBC][SQL Server]Line 1: Incorrect syntax
near 'UPDATE table2 SET Status = 110 WHERE Status <> 110 AND Key LIKE
'%\___' ESCAPE '\''. (SQL-S1000)(DBD: st_execute/SQLExecute err=-1)'
<- execute(CODE)= undef at insert.sql line 74
I'm currently doing this with:
$string = "UPDATE table2 SET Status = 110 WHERE Status <> 110 AND Key
LIKE '\%\\___' ESCAPE '\\'";
$quotedstring = $dbh->quote( $string );
$sth2 = $dbh->prepare($quotedstring);
$sth2->execute();
This is using OpenLink's ODBC drivers to connect to MS SQL Server 7.
Could someone give some pointers as to the best where I'm going wrong ...
Cheers,
Rob
This message is intended only for the use of the person(s) ("The intended
Recipient(s)") to whom it is addressed. It may contain information which
is privileged and confidential within the meaning of applicable law. If
you are not the intended recipient, please contact the sender as soon as
possible. The views expressed in this communication are not necessarily
those held by LYNX Express Limited.