AnsweredAssumed Answered

Last 24 Hours Gel Script on sql server

Question asked by vick.chahal on Nov 26, 2018
Latest reply on Nov 27, 2018 by vick.chahal

I am writing a gel script to look at the audit tables to do an insert based on updates made in the last 24 hours.  I am able to create the query and test it on SQL Server but when I put it into GEL the process fails.  I have tried multiple different date methods and they all work on SQL Server when I directly query the DB but the do not work in a gel script If i can get any assistance I would really appreciate it. 

VERSION 1

Select
srm.FULL_NAME,
srm.UNIQUE_NAME,
srm.id,
cmn.ATTRIBUTE_CODE,
CASE WHEN cmn.ATTRIBUTE_CODE='manager_id' THEN 'nis_mgr_change'
WHEN cmn.ATTRIBUTE_CODE='prprimaryroleid' THEN 'nis_role'
ELSE 'N/A' END Resource_history_type,
cmn.VALUE_BEFORE,
cmn.RAW_VALUE_BEFORE,
cmn.VALUE_AFTER,
cmn.RAW_VALUE_AFTER,
cmn.CREATED_DATE
from CMN_AUDITS cmn
join srm_resources srm on srm.id=cmn.OBJECT_ID
where cmn.object_code='resource'
and cmn.OPERATION_CODE='U'
and cmn.CREATED_DATE >= DATEADD(day, -1, GETDATE())

 

VERSION 2

Select
srm.FULL_NAME,
srm.UNIQUE_NAME,
srm.id,
cmn.ATTRIBUTE_CODE,
CASE WHEN cmn.ATTRIBUTE_CODE='manager_id' THEN 'nis_mgr_change'
WHEN cmn.ATTRIBUTE_CODE='prprimaryroleid' THEN 'nis_role'
ELSE 'N/A' END Resource_history_type,
cmn.VALUE_BEFORE,
cmn.RAW_VALUE_BEFORE,
cmn.VALUE_AFTER,
cmn.RAW_VALUE_AFTER,
cmn.CREATED_DATE
from niku.CMN_AUDITS cmn
join niku.srm_resources srm on srm.id=cmn.OBJECT_ID
where cmn.object_code='resource'
and cmn.OPERATION_CODE='U'
and cmn.CREATED_DATE >= CURRENT_TIMESTAMP -1

Outcomes