SQL Queries - Common SQL Queries - How to check the consistency on the next value to be allocated on local database for an Id

Purpose of Query

This page provides the Queries to check the consistency on the next value to be allocated on local database for an Id.

Applicable CAST Version
Release
Yes/No
8.3.x(tick)
Applicable RDBMS
RDBMS
Yes/No
CSS(tick)
Query for CSS

On the CENTRAL database execute the following query (maximum value of the ids on the central corresponding to the local):

SELECT   SITE_NAME      ,
         SITE_SERVER    ,
         SITE_USER      ,
         LOCAL_DSS_NAME ,
         MAX(SITE_OBJECT_ID) lastidfromLocal
FROM     DSS_TRANSLATION_TABLE tt
         JOIN DSS_SITES s
         ON       s.SITE_ID = tt.SITE_ID
GROUP BY SITE_NAME  ,
         SITE_SERVER,
         SITE_USER  ,
         LOCAL_DSS_NAME
Query result example
 "test820_local";"host";"operator";"test820_local";17958
Query result interpretation
 This provides information on the local database and the last id used on it that has been referenced on the central database.


Next, on the LOCAL database execute the following query (maximum values of the ids used on the local):

SELECT MAX(IdKey)
FROM   Keys
Query result example

17954

Query result interpretation
 This provides information on the last id used on the local database


Finally make sure that the above two numbers are LESS than the value produced below on the LOCAL database:


SELECT nextval('IDKEY_GENERATOR')
Query result example

18107

Query result interpretation
 This result should be greater than the numbers from the queries above (18107 > 17958 and 18107 > 17954) to ensure consistency
Notes/comments

 The following have not been validated, but may work for checking sequences on Oracle and SQL Server similar to above:

  • On SqlServer :
    Select IntVal from Parms where Lib='Id'
  • On Oracle
    select IDKEY_GENERATOR.nextval from dual



Related Pages