Page 1 of 1

TUniQuery 's execute function giving exception while using AsSQLTimeStampOffset as data typpe for query parameter

Posted: Fri 15 Sep 2017 10:17
by rupendra
I am using insert query for posting data from embarcadero(firebird as DB) to SQL server using Unidac.
I am using the following query as a parameter for storing TSQLTimeStampOffset data type.

UQuery->ParamByName("DayLightTimeOfET")->AsSQLTimeStampOffset = PModels.DayLightTimeOfET;

where "UQuery " is a pointer to TUniQuery and "PModels" is a class and DayLightTimeOfET is variable of data type SQLTimeStampOffset of PModels class.

while executing the query I am getting the following exception.

"Invalid internal field type $19 (25) (D:\Projects\Delphi\Dac\SqlServer\Source\OLEDBAccess.pas, line 1214)"
Can Anyone help? my other queries are working fine.

Re: TUniQuery 's execute function giving exception while using AsSQLTimeStampOffset as data typpe for query parameter

Posted: Mon 18 Sep 2017 07:25
by azyk
Please specify the data type you are using in the Firebird table and in the SQL Server table.

Re: TUniQuery 's execute function giving exception while using AsSQLTimeStampOffset as data typpe for query parameter

Posted: Mon 18 Sep 2017 07:30
by rupendra
In SQlServer data type is DateTimeOffset and i am creating a new datatype in firebird ie; TSQLTimeStampOffset.
Note: I am not using it in firebird DB Table.

Re: TUniQuery 's execute function giving exception while using AsSQLTimeStampOffset as data typpe for query parameter

Posted: Mon 18 Sep 2017 13:25
by azyk
You can work with the data type datetimeoffset as with a string value, presented in the format

Code: Select all

YYYY-MM-DD hh:mm:ss[.nnnnnnn] [+|-]hh:mm 
For this, you need set the 'Provider' option to 'prSQL'.

For example:

Code: Select all

UniConnection1->SpecificOptions->Values["SQL Server.Provider"] = "prSQL";
...
UQuery->ParamByName("DayLightTimeOfET")->DataType = ftWideString;
UQuery->ParamByName("DayLightTimeOfET")->AsString = SQLTimeStampOffsetToStr("YYYY-MM-DD hh:mm:ss", PModels.DayLightTimeOfET);

Re: TUniQuery 's execute function giving exception while using AsSQLTimeStampOffset as data typpe for query parameter

Posted: Tue 19 Sep 2017 03:15
by rupendra
Yesterday i got following from your page.
"yyyy-mm-dd hh:nn:ss"
It works.

Re: TUniQuery 's execute function giving exception while using AsSQLTimeStampOffset as data typpe for query parameter

Posted: Tue 19 Sep 2017 04:34
by rupendra
Thank you !