Stored Procedures for Database Import

The following sample procedures return all records for the "SampleDatabase" for both an Oracle database and a Microsoft SQL Server database.

The following sample procedure is used to 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.

Oracle Server

CREATE OR REPLACE PROCEDURE sp_GetSampleTable (p_recordset OUT SYS_REFCURSOR) AS
BEGIN
 -- Insert statements for example to log the data access
  OPEN p_recordset FOR
    SELECT * FROM SampleDatabase;
END sp_GetSampleTable;

Microsoft SQL Server

USE [SampleDatabase]
GO
/****** Object: StoredProcedure [dbo].[ p_GetSampleTable] Script Date: 04/13/2011 04:47:06 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[sp_GetSampleTable]
 -- Add the parameters for the stored procedure here
AS
BEGIN
  -- SET NOCOUNT ON added to prevent extra result sets from
  -- interfering with SELECT statements.
  SET NOCOUNT ON;

  -- Insert statements for example to log the data access
  -- Insert statements for procedure here
  SELECT [SupplierNumber]
  ,[Name_1]
  ,[Name_2] 
  ,[Street]
  ,[PostCode_1]
  ,[City]
  From SampleDatabase.dbo.Vendor;
END