Stored Procedures for Automatic Update

The following sample stored procedures check for a "SampleDatabase" if the Vendor has changed. It accesses the table, VendorLastChanged for the field, LastDate. Note that for any change that altered the Vendor this field must be updated, otherwise the automatic update is never performed. Examples for both Oracle Server and Microsoft SQL Server are shown.

Oracle Server

CREATE OR REPLACE PROCEDURE sp_GetLastChangedDateForSampleDatabase (l_result OUT DATE) 
AS
BEGIN
SELECT LastDate INTO l_result FROM VendorLastChanged WHERE rownum < 2;
END sp_GetLastChangedDateForSampleDatabase;

Microsoft SQL Server

USE [SampleDatabase]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[sp_ChangedDate] 
@lastChangeDate as DateTime output
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from interfering with SELECT statements.
SET NOCOUNT ON;

-- Insert statements for procedure here
SET @lastChangeDate = (SELECT TOP 1 LastDate FROM SampleDatabase.dbo.VendorLastChanged);
END