自動更新用の関数

次の例では、関数を使用してデータベースを自動的に更新するタイミングを決定する方法を示します。

Oracle サーバー

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