Sometimes, you may need to get the current stamp of the database server if you need for example to calculate the difference between the entry creation time and the current time.
In order to get the current database server timestamp in DB2, you can get it by querying the sysdummy1 table in the sysibm schema as follows:
SELECT CURRENT TIMESTAMP AS CURRENT_SERVER_TIME FROM sysibm.sysdummy1
You may face this problem when you try to run the JsTestDriver (JSTD) tests. The reason behind this error is that JsTestDriver is unable to find the configuration file that declares the server directive. In order to solve this error, you need to specify the configuration file path using the --config parameter in the test running command as follows:
java -jar JsTestDriver.jar --config jsTestDriver.conf --tests all
A very common requirement is to have pagination on the level of the database especially if your query result returns thousands of database records. This post shows you how to make database pagination in DB2.
In order to make a database pagination in DB2, you need to use the ROW_NUMBER() function as follows.
(SELECT column1, column2, column3,
ROW_NUMBER() OVER (ORDER BY column1) AS RN
FROM TABLE(OR VIEW)
WHERE column1=xyz1 and column2=xyz2)
SELECT column1, column2, column3 FROM
CVIEW WHERE RN BETWEEN X AND Y
ORDER BY RN
You can use this template query if you want to retrieve records from X to Y from the TABLE(OR VIEW). The template query shows you how to retrieve column1, column2, and column3 from the TABLE(OR VIEW) with the specified condition column1=xyz1 and column2=xyz2 ordered by column1.