Skip to main content
Question

Documentation vs sql script creator.


Iain Sharp
Forum|alt.badge.img+5

We use MS SQL server, with the following params. 
 


[DRIVER_SETTINGS]
MSS U5.4

USYS$MSS_PARAMS ri: uniface, procs: off, ids:quoted, hold statements:on, locktime:infinite,gran:row, stmtcache:off,iso:ru,os:96, sql92npw=on, mars:on

As I read the documentation here, this should be using SQL mapping 2 (default). In sql mapping 2, packing code E is mapped to datetime2 (unclear as to what precision). 

When I run the create scripts utility, the data fields mapped as E are being set to datetime. 

Is this an oversight, or is the utility configured to run to lowest common denominator for SQL versions (all supported versions of SQL server now support datetime2). 
Is there any setting or otherwise I can use to change the behaviour of the create scripts utility? 
Our database is full of datetime at the moment, but the 0.003s rounding occasionally trips us up, and I’d like to be able to decide on precision on the datetimes stored. 
I can obviously hand modify all the scripts created before enacting them. 

Also, if I leave uniface to create the tables ‘on the fly’ (not likely for an actual app), what data type does it create? What is the default uniface precision for datetime2? 

Regards, 

Iain

3 replies

Peter Beugel
Forum|alt.badge.img+1

Hello Iain

 

Here there is a misunderstanding about the 2 due to missing Notes:

Data Packing for Microsoft SQL Server 
The overview "Uniface to MS SQL Storage Formats" contains references to notes.
So E goes to Datetime and refers to Note 2.
The Notes were there in Uniface 9.7 library but seem to have gone lost in the Uniface 10 library.

I copy them here:
Notes:
1 If the nls connector option is enabled, this is remapped to Nchar and the maximum field length is 4000 characters. 
2 When mapping=23 is used, fields with packing codes D, D1-D11, and D13 are stored in Date fields. 
  Fields with packing codes for time and datetime (T, Tn, E, and En) are stored in Datetime fields. 
3 Only applicable when mapping=22. 
4 Only applicable when mapping=11 
5 If the nls connector option is enabled, this is mapped to Ntext and the maximum field length is 4000 characters. 
6 If the nls connector option is enabled, this is mapped to Nvarchar and the maximum field length is 4000 characters. 


There is an old issue that has not been implemented yet
MSS connector with mapping:23 should use Datetime2 datatype instead of Datetime
Summary:
With Uniface version 9.5 the MSS connector mapping:23 was introduced in order
to support the SQL Server Date datatype. For combined date and time fields the
connector still is using the Datetime datatype instead of Datetime2 (that
supports the same year range as Date).

Environment:
+Uniface: All Versions
+Operating System: OS independent
+Database: Microsoft SQL Server 2008 (and higher) with MSS Connector U4.x (and higher)

Symptoms:
Since Uniface version 9.5 the MSS connector supports the SQL Server Date
datatype (that allows dates in the range 0001-01-01 through 9999-12-31) when
using mapping:23. But for combined date and time fields the connector does not
use the Datetime2 datatype (that also allows dates in the range 0001-01-01
through 9999-12-31). Instead the Datetime datatype (that only allows dates
between 1753-01-01 and 9999-12-31) is still used.

Workaround:
It is possible to change the datatype (for combined date and time field) in a
create table script (generated by Uniface) from Datetime to Datetime2 and
create the table with that script (and not on the fly). The MSS connector can
handle Datetime2 columns when mapping:23 is used.

 

KInd regards

Peter


Iain Sharp
Forum|alt.badge.img+5
  • Author
  • Inspiring
  • October 23, 2026

Aha, so the problem was I was misreading what should have been datetime² as datetime2? 

datetime2 would require me to change the mapping the parameters quoted above as well as manually changing the scripts?

Regards, 

Iain


Peter Beugel
Forum|alt.badge.img+1

Yes datetime²  should have been there.

I have reported this documentation issue via the online feedback button

for the Uniface library.

 

For datetime2 you would indeed need connector option mapping:23 and a manual change of the scripts.