× 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.



7.3 Knowledge center
https://www.ibm.com/support/knowledgecenter/ssw_ibm_i_73/rzahg/welcome.htm
Database, Reference, SQL Reference, Statements, CREATE TABLE,
WITH DEFAULT CURRENT TIMESTAMP


CREATE TABLE QTEMP.JR
(
MYCHAR CHAR(5),
MYTS TIMESTAMP WITH DEFAULT CURRENT TIMESTAMP
);

INSERT INTO QTEMP.JR (MYCHAR) VALUES('A');

SELECT * FROM QTEMP.JR;
myts has the time the transaction was completed.

UPDATE QTEMP.JR
SET MYCHAR='B'
WHERE MYCHAR='A';

SELECT * FROM QTEMP.JR;
The value of myts did not change from the insert.

See also these cool functions from 7.3:

create table qtemp.jr2
(
mychar char(5),
CreatedTS timestamp with default current timestamp,
audit_user VARCHAR(128) GENERATED ALWAYS AS (SESSION_USER),
audit_op CHAR(1) GENERATED ALWAYS AS (DATA CHANGE OPERATION),
Row_Change_TS timestamp for each row on update as row change timestamp not
null
);

insert into qtemp.jr2 (mychar) values('#ENFB');
select * from qtemp.jr2;
#ENFB, 2017-08-22 08:51:26.570501, ROB, I, 2017-08-22 08:51:26.570546

update qtemp.jr2
set mychar='Rocks'
where mychar='#ENFB';

select * from qtemp.jr2;

Rocks, 2017-08-22 08:51:26.570501, ROB, U, 2017-08-22 08:53:28.175547



Rob Berendt

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.