#40452 [Com]: ODBC and SQL Server datetime parameter fields fail on insert

From: Date: Fri, 23 Nov 2007 11:04:34 +0000
Subject: #40452 [Com]: ODBC and SQL Server datetime parameter fields fail on insert
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-119987@lists.php.net to get a copy of this message
ID: 40452 Comment by: rob at tdd dot org dot uk Reported By: aspen dot olmsted at alliance dot biz Status: Assigned Bug Type: PDO related Operating System: Windows 2003, XP PHP Version: 5.2.1 Assigned To: wez New Comment: I was experiencing the same problem with a stored procedure (SQL SERVER), however I found that I was calling the parameters in a different order in which they where expected, even though I was specifying the parameter name. -- replcate CREATE PROC hello @world VARCHAR(100), @repeat INT AS SELECT 'hello ' + REPLICATE(@world, @repeat) GO -- both give same output EXEC hello @world = 'world', @repeat = 5 EXEC hello @repeat = 5, @world = 'world' If I was to call the first exec equivalent in php using bound parameters then it works, however the php equivalent using bound parameters it fails with a function sequence error. Previous Comments: ------------------------------------------------------------------------ [2007-10-11 14:22:29] jfdsmit at gmail dot com I have a similar experience, running PHP 5.2.4 on Windows 2003. The server /does/ accept values when they are formatted exactly yyyy-mm-dd (as per the date() format Y-m-d) /or/ if the supplied value == NULL. Empty strings and dates formatted otherwise (2007-3-12 for instance) result in a HY010 SQLSTATE Sequence error. So contrary to what daniel dot tams at gmail dot com says, the bug is formatting-dependant in my experience ------------------------------------------------------------------------ [2007-04-24 19:05:14] daniel dot tams at gmail dot com Just wanted to clarify that the error is unrelated to the format of the datetime. ------------------------------------------------------------------------ [2007-04-24 19:00:09] daniel dot tams at gmail dot com I can confirm this problem on PHP 5.2.1. The exact error is the following: Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY010]: Function sequence error: 0 [Microsoft][ODBC Driver Manager] Function sequence error (SQLExecute[0] at ext\pdo_odbc\odbc_stmt.c:133)' in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\iptaa\lib\IPTAA_CRUD.class.php:135 Stack trace: #0 C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\iptaa\lib\IPTAA_CRUD.class.php(135): PDOStatement->execute() #1 C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\iptaa\lib\IPTAA_CRUD.class.php(414): IPTAA_CRUD->create(Array) #2 C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\iptaa\users.php(15): IPTAA_CRUD->handleHttpPost() #3 {main} thrown in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\iptaa\lib\IPTAA_CRUD.class.php on line 135 Fatal error: Exception thrown without a stack frame in Unknown on line 0 This is a pretty serious limitation of the PDO ODBC driver. ------------------------------------------------------------------------ [2007-02-13 01:31:36] aspen dot olmsted at alliance dot biz Yes. If you insert into sql other ways it works perfect. Including through php ------------------------------------------------------------------------ [2007-02-12 22:22:23] tony2001@php.net Are you sure "2007-02-12 14:5" is correct timestamp for MSSQL? Doesn't it lack the last symbol? ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/40452 -- Edit this bug report at http://bugs.php.net/?id=40452&edit=1

« previous php.bugs (#119987) next »