Functions for Automatic Update

The following examples show how to use a function to determine when to update a database automatically.

Oracle Server

create or replace 
function function_GetLastModificationDateForMyTable return date as 
begin
    -- please write the logic for returning the date when MyTable changed 
    -- for the last time
    
     -- The code below is for test purpose: returning systimestamp will force
     -- to update by each check.
     -- return systimestamp;
end function_ GetLastModificationDateForMyTable;

Microsoft SQL Server

USE [MyDatabase]
GO

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE FUNCTION [dbo].[GetLastModificationDateForMyTable] 
(      
)
RETURNS datetime
AS
BEGIN
       DECLARE @ModificationDate datetime

          -- please write here the logic returning the date when MyTable changed 
       -- for the last time


                     -- The code below is for test purpose: returning CURRENT_TIMESTAMP will force
       -- to update by each check.
          -- SELECT @ModificationDate = CURRENT_TIMESTAMP;
       
       RETURN @ModificationDate
END