× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



On 17-Apr-2015 11:39 -0500, Dan wrote:
We're still on v7r1 here. How does the new 12 digit precision
affect timestamp fields in tables defined prior to v7r2?

No effect. The timestamp values that were stored in prior releases [with 6-digit precision] remain the same, because the TIMESTAMP columns were implicitly created with 6-digit precision; i.e. TIMESTAMP(6) as implied in the data-type portion of the CREATE TABLE syntax diagram:

.-(--6--)-.
'-TIMESTAMP--+---------+-

Thus any TIMESTAMP values stored with the 6-digit precision [no matter how many more digits of precision may have been provided in a timestamp string] will have stored the timestamp value with only the six digits of precision; the effectively truncated value for the timestamp, will remain the same for comparison and presentation in the newer releases since IBM i 7.2.

Note the effects on this older release script:

create table ts
( t timestamp not null /* TIMESTAMP(6) is implicit */
, constraint ts_pk primary key (t)
)
;
insert into ts values
/* '....+....1....+....2....+....3..' */
('2015-04-17-10.04.22.932533985351')
, ('2015-04-17-10.04.22.932533999999')
; -- SQL0803 "Duplicate key value specified."
select * from ts
; -- report follows; only first value is a row:
....+....1....+....2....+.
T
2015-04-17-10.04.22.932533
******** End of data ***

Prior to v7r2, the SQL would accept only the first 26 bytes of the TIMESTAMP strings. The internal storage of the value was therefore truncated to the value representing only those 6-digits of precision. The above script should operate the same on all releases, because the syntax is unchanged for the default; defaulting to TIMESTAMP(6). If the precision argument for the TIMESTAMP is specified as eight or greater, then the above script should insert the two distinct values without the duplicate-key exception.

With the additional 6 digits, I presume that more space is needed to
store them than before.

No. Same internal storage irrespective the specified precision. The difference is merely the amount of precision /visible/ both for storage and for presentation. IIRC the total amount of storage for the TIMESTAMP value is 10-bytes, irrespective the amount of precision from 0 to 12 digits.


Also, because when you absolutely, positively must have a unique key
but can't rely on a timestamp (even with 12 digit precision for the
second!) to provide it, what was the impetus to increase the
precision? Curious mind(s?) wants to know.


AFaIK the increased precision is similar to the effect for UUID whereby the additional precision is not actual portions of time, but instead are just [up to whatever is the precision beyond six] uniquely assigned values; thus I suspect the TIMESTAMP with a sufficiently large precision [over 6-digits] would serve for UNIQUE values without having to depend on the UUID.

Poking about in the IBM i 7.2 KnowledgeCenter I found the following which may be the source for my above thinking:
<https://www.ibm.com/support/knowledgecenter/api/content/ssw_ibm_i_72/sqlp/rbafydtts.htm>
_Date, time, and timestamp data types_
"...
When the CURRENT TIMESTAMP special register or a variable with the TIMESTAMP data type is used with a precision greater than 6, the timestamp value is a combination of the system clock and uniqueness bits. The uniqueness bits are assigned in an ascending order. Therefore, comparison operations for timestamps with any precision will represent an accurate order of when the timestamps were assigned.
..."


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.