note 81488 added to ref.pdo-odbc

From: Date: Fri, 29 Feb 2008 22:15:34 +0000
Subject: note 81488 added to ref.pdo-odbc
Groups: php.notes 
Request: Send a blank email to php-notes+get-136621@lists.php.net to get a copy of this message
Using SQL 2005, PDO_ODBC and datetime fields is a royal pain. MSDN documentation on CAST CONVERT shows that there is supposed to be an implicit convert between character types and datetime types. That's true... until you put it in a stored procedure and use variable declarations. For instance this fails: declare @date varchar; SET @date = '20080101'; SELECT cast(@date AS datetime) AS poo While this succeeds: declare @date varchar(19); SET @date = '20080101'; SELECT cast(@date AS datetime) AS poo The PDO Driver appears to attempt an implicit conversion and so it fails whenever you try to insert data into datetime column types. So to workaround this nuance in SQL, declare a character column type with explicit width. Then your implicit type conversion will work. ---- Server IP: 208.69.120.35 Probable Submitter: 140.211.84.125 ---- Manual Page -- http://www.php.net/manual/en/ref.pdo-odbc.php Edit -- https://master.php.net/note/edit/81488 Del: integrated -- https://master.php.net/note/delete/81488/integrated Del: useless -- https://master.php.net/note/delete/81488/useless Del: bad code -- https://master.php.net/note/delete/81488/bad+code Del: spam -- https://master.php.net/note/delete/81488/spam Del: non-english -- https://master.php.net/note/delete/81488/non-english Del: in docs -- https://master.php.net/note/delete/81488/in+docs Del: other reasons-- https://master.php.net/note/delete/81488 Reject -- https://master.php.net/note/reject/81488 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#136621) next »