Small Talk About AS400 & DB2

These are the points that I can share

  1. If we you speak about AS400 machine or RPG, then you are talking about DB2.
  2. There are available DB2 for different platform that you can download and install locally (www.db2University.com,  this website has provide link to DB2 express even you can take a course freely)

MSSQL VERSION

  • SELECT  TOP 10  *  FROM [TABLE_NAME]
  • SELECT TOP 10 * FROM [TABLE_NAME] WITH (NOLOCK)
  • SELECT TOP 10 A.*,(SELECT TOP 1 PROJNO FROM EMPPROJACT AS X WHERE X.EMPNO = A.EMPNO) AS PRO FROM EMPLOYEE WITH (NOLOCK) AS A
    INNER JOIN EMPMDC AS B WITH (NOLOCK) 
    ON A.EMPNO = B.EMPNO

* Note: WITH (NOLOCK) was used for faster query, this concept as solved problem when two query access the same record at the same time that will make the query become slower because the second query should wait for the first query to finish,  by doing WITH NOLOCK the second query should not wait for the first query to finish and the result set can be modified by other query because that is no locking on the result set, so this keyword is very useful especially if you would like to prevent MSSQL to lock a table.

 

DB2 VERSION

  • SELECT * FROM  [TABLE_NAME] FETCH FIRST 10 ROWS ONLY
  • SELECT * FROM [TABLE_NAME] FETCH FIRST 10 ROWS ONLY FOR READ ONLY
  • SELECT A.*,(SELECT PROJNO FROM EMPPROJACT AS X WHERE X.EMPNO = A.EMPNO FETCH FIRST 1 ROW ONLY) AS PRO FROM LUCIAN."EMPLOYEE" AS A
    INNER JOIN EMPMDC AS B
    ON A.EMPNO = B.EMPNO
    FETCH FIRST 10 ROWS ONLY
    FOR READ ONLY

0 comments:

Post a Comment