Skip to content

ODBC HY010 when binding parameter that is larger than the column definition #9372

Closed
@jfowler8708

Description

@jfowler8708

Description

The following code:

<?php
$connection = new \PDO("odbc:DRIVER={ODBC Driver 17 for SQL Server};host=<host>", "<username>", "<password>");
$query = "select itm_code from item where itm_number = :itemNumber";
$parameters = [":itemNumber" => "123456"]; // itm_number column defined as varchar(5) parameter is char(6)
$prepared = $connection->prepare($query);
$results = $prepared->execute($parameters);
?>

Resulted in this output:

SQLSTATE[HY010]: Function sequence error: [unixODBC][Driver Manager]Function sequence error (SQLExecute[0] at /build/php8.1-8.1.9/ext/pdo_odbc/odbc_stmt.c:254)

The error only happens when the bound parameter is larger than the column as defined. Does not happen when using literals within the query string. I would expect to just receive 0 results not an error.

PHP Version

PHP 8.1.9

Operating System

Debain 10.11

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions