System details:
Table schema
CREATE TABLE [rate] ([id] INT IDENTITY NOT NULL, [dat] NVARCHAR(255), [bid] DOUBLE PRECISION, [ask] DOUBLE PRECISION, PRIMARY KEY ([id]))
Current behaviour & expected behavior
Consider valid PDO connection $pdo created with PDO::ERRMODE_EXCEPTION.
Code
$pdo->exec('insert into [rate] ([dat], [bid], [ask]) values (\'18/12/12\', (\'1.5\' + 0), (2.5 + 0))');
throws
PDOException: SQLSTATE[22018]: [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Conversion failed when converting the varchar value '1.5' to data type int
this is expected and I post it here only to provide a proof the PDO connection and PHP error handling is working.
Now let's run the same query wrapped inside begin try SQL block, code
$pdo->exec('begin try begin
insert into [rate] ([dat], [bid], [ask]) values (\'18/12/12\', (\'1.5\' + 0), (2.5 + 0))
return
end end try
begin catch
throw
end catch');
does NOT throw an exception but it should throw exactly the same exception as the simple test code above.
as in web sandpit https://dbfiddle.uk/?rdbms=sqlserver_2019&fiddle=e683f9880d5b5b490854244f4ff95eb7 the error is correctly thrown/detected I belive the issue is not in SQL Server itself but in this php extension
Raising error is critical, with the current behaviour, system data can be easily corrupted. For example, when the execution of query above pass and the last AI is read, the AI of previous/different insert is read.
System details:
PHP: 7.4 - 8.1
pdo_sqlsrv: 5.10.0
SQL Server: latest docker image mcr.microsoft.com/mssql/server
OS: Windows & linux
Table schema
Current behaviour & expected behavior
Consider valid PDO connection
$pdocreated withPDO::ERRMODE_EXCEPTION.Code
throws
this is expected and I post it here only to provide a proof the PDO connection and PHP error handling is working.
Now let's run the same query wrapped inside
begin trySQL block, codedoes NOT throw an exception but it should throw exactly the same exception as the simple test code above.
as in web sandpit https://dbfiddle.uk/?rdbms=sqlserver_2019&fiddle=e683f9880d5b5b490854244f4ff95eb7 the error is correctly thrown/detected I belive the issue is not in SQL Server itself but in this php extension
Raising error is critical, with the current behaviour, system data can be easily corrupted. For example, when the execution of query above pass and the last AI is read, the AI of previous/different insert is read.