SQL Server 2008 and time(0)

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
hughespa
Posts: 81
Joined: Sat 23 Aug 2008 08:36
Location: W. Australia

SQL Server 2008 and time(0)

Post by hughespa » Tue 20 Jul 2010 07:06

Hi,

This is using SQL Server 2008, D2010 and UniDAC 3.00.0.10

I have the following table definition:

Code: Select all

CREATE TABLE JOBS 
(
JOB_ID int NOT NULL,
JOB_DATE date NOT NULL,
JOB_TIME time(0) NOT NULL, --also same error with time(7)
PER_ID int NOT NULL,
CONSTRAINT PK_JOBS PRIMARY KEY ( JOB_ID ASC )
)

When I use a {date... and {time.. macros, the generated SQL for a particular update is:

Code: Select all

UPDATE JOBS SET JOB_DATE = CONVERT(DATETIME, '2010-07-20'), JOB_TIME = CONVERT(DATETIME, '17:05:00')
WHERE ( JOB_ID = 2913525 ) 
AND ( JOB_DATE = CONVERT(DATETIME, '2010-07-20') )  
AND ( JOB_TIME = CONVERT(DATETIME, '17:00:00') ) 
AND ( PER_ID = 181412 )
However, this raises an error on the last comparison:
( JOB_TIME = CONVERT(DATETIME, '17:00:00') )
error:
"The data types time and datetime are incompatible in the equal to operator"

I have worked around it for now by changing the following functions in the SQLServerUniProvider:

Code: Select all

MSFunctions.AddObject('__DATE_LITERAL',TObject(PChar('CONVERT(DATE, %s)')));

MSFunctions.AddObject('__TIME_LITERAL',TObject(PChar('CONVERT(TIME, %s)')));
I realize this may not be compatible with earlier versions of SQL server but I wonder if you are able to detect the version or add an option to change the function to produce DATE or TIME instead of DATETIME ?

Regards, Paul.

Dimon
Devart Team
Posts: 2910
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Wed 21 Jul 2010 13:59

Thank you for information. We have fixed this problem. This fix will be included in the next UniDAC build.

hughespa
Posts: 81
Joined: Sat 23 Aug 2008 08:36
Location: W. Australia

Post by hughespa » Wed 21 Jul 2010 15:07

Great, thank you.

Regards, Paul.

Post Reply