Humble Trader

Saturday, September 16, 2006

Control Repository - ctl_gen_b.sql

-- ------------------------------------------------------------------------- --
-- --
-- Title: ctl_gen_b.sql --
-- Author: Steve Roach --
-- Date: 23-AUG-2006 --
-- Version: 01.00 --
-- --
-- Description: A package for general control procedures. --
-- --
-- History: --
-- --
-- Date Ver Author Description --
-- --------- ----- ------ -------------------------------------------------- --
-- 23-AUG-06 01.00 SRR First release --
-- --
-- ------------------------------------------------------------------------- --

-- Package body definition.
CREATE OR REPLACE PACKAGE BODY ctl_gen
AS
-- Generate a timestamp and run number for the run.
-- Create a mapping_histories row to start the run.
PROCEDURE initialise_mapping(
p_mapping IN VARCHAR2
,p_run_no OUT NUMBER)
IS
BEGIN
-- Generate a run number for the run. Create a mapping_histories row
-- to start the run.
INSERT INTO mapping_histories
(
run_no
,mapping_library
,start_tsp
,end_tsp
)
VALUES
(
run_no_s.NEXTVAL
,p_mapping
,SYSDATE
,NULL
)
RETURNING run_no
INTO p_run_no;

EXCEPTION
WHEN OTHERS THEN
RAISE_APPLICATION_ERROR(-20001,
'ctl_gen.initialise_mapping Error: [' || SQLERRM ||
']. p_mapping = [' || p_mapping || '], p_run_no = [' || p_run_no ||
'].');
END initialise_mapping;

-- Close the mapping_histories row by adding an end timestamp.
PROCEDURE finalise_mapping(
p_run_no IN NUMBER)
IS
BEGIN
-- Close the mapping_histories row by adding an end timestamp.
UPDATE mapping_histories SET
end_tsp = SYSDATE
WHERE run_no = p_run_no;

EXCEPTION
WHEN OTHERS THEN
RAISE_APPLICATION_ERROR(-20001,
'ctl_gen.finalise_mapping Error: [' || SQLERRM ||
']. p_run_no = [' || p_run_no || '].');
END finalise_mapping;
END ctl_gen;
/

SHOW ERRORS

0 Comments:

Post a Comment

<< Home