git-svn-id: http://locode01.ad.dom/svn/WEBMIP/trunk@50874 248e525c-4dfb-0310-94bc-949c084e9493
This commit is contained in:
398
Data/BulkLoad/EFT/Nominations/plsql/caco_utilities.spc
Normal file
398
Data/BulkLoad/EFT/Nominations/plsql/caco_utilities.spc
Normal file
@@ -0,0 +1,398 @@
|
||||
CREATE OR REPLACE PACKAGE caco_utilities IS
|
||||
/**
|
||||
-- Package containing the general utility modules used by the Access Manager application
|
||||
*/
|
||||
|
||||
g_header CONSTANT VARCHAR2(160) := '$Header: /Isle Of Grain/database/PLSQL/caco_utilities.pck 1 7/01/05 12:54 Gilberta $';
|
||||
g_revision CONSTANT VARCHAR2(160) := '$Revision: 1 $';
|
||||
--
|
||||
-- Number format which is used in inserting the thousand separator for numbers
|
||||
--
|
||||
g_number_format CONSTANT VARCHAR2(100) := 'FM999,999,999,999';
|
||||
g_thousand_separator CONSTANT VARCHAR2(1) := ' ';
|
||||
--
|
||||
-- Constants
|
||||
--
|
||||
C_Yes CONSTANT VARCHAR2(1) := 'Y';
|
||||
C_No CONSTANT VARCHAR2(1) := 'N';
|
||||
/*
|
||||
* $History: caco_utilities.pck $
|
||||
*
|
||||
* ***************** Version 1 *****************
|
||||
* User: Gilberta Date: 7/01/05 Time: 12:54
|
||||
* Created in $/Isle Of Grain/database/PLSQL
|
||||
* Initial Version
|
||||
*
|
||||
*/
|
||||
|
||||
--
|
||||
-- Definitions for the hash-key array
|
||||
-- functions
|
||||
--
|
||||
|
||||
/**
|
||||
-- Stores the string to be hashed by the GET_HASH_VALUE function.
|
||||
*/
|
||||
SUBTYPE t_hash_key IS VARCHAR2(80);
|
||||
|
||||
/** Specifies the substitution values that could be passed into any generated error message */
|
||||
TYPE g_t_substitution_list IS TABLE OF VARCHAR2(1024) INDEX BY BINARY_INTEGER;
|
||||
c_empty_substitution_list g_t_substitution_list;
|
||||
|
||||
/**
|
||||
-- Stores the hash value derived from a string passed into GET_HASH_VALUE.
|
||||
*/
|
||||
SUBTYPE t_hash_value IS NUMBER;
|
||||
|
||||
TYPE t_string_record IS RECORD(
|
||||
stringpart VARCHAR2(32767)
|
||||
,delimiter VARCHAR2(1));
|
||||
|
||||
TYPE t_string_table IS TABLE OF t_string_record INDEX BY BINARY_INTEGER;
|
||||
--
|
||||
TYPE t_vc_table IS TABLE OF VARCHAR2(2000) INDEX BY BINARY_INTEGER;
|
||||
--
|
||||
/**
|
||||
-- Logs an error message on the ERROR_LOGS table.
|
||||
*/
|
||||
PROCEDURE log_error(p_error_rec IN error_logs%ROWTYPE);
|
||||
/**
|
||||
-- Splits the file name into its component portions.
|
||||
*/
|
||||
PROCEDURE disassemble_file_name(p_file_name IN VARCHAR2
|
||||
,p_file_prefix OUT VARCHAR2
|
||||
,p_date_created OUT VARCHAR2
|
||||
,p_file_suffix OUT VARCHAR2
|
||||
,p_error_msg OUT VARCHAR2);
|
||||
|
||||
/**
|
||||
--Converts a deliomited record string into a PL/SQL table with an entry for each item in the record.
|
||||
*/
|
||||
FUNCTION delimiter_to_table(p_string IN VARCHAR2
|
||||
,p_delimiter IN VARCHAR2
|
||||
,p_error_msg OUT VARCHAR2) RETURN t_vc_table;
|
||||
/**
|
||||
-- Converts (hashes) the passed in string into an integer.
|
||||
-- This function is used to generate a unique (or at least probably unique)
|
||||
-- integer for the text string passed into it.
|
||||
-- @param p_hash_key The string to be hashed into an integer.
|
||||
-- @return The integer value for the string passed in.
|
||||
*/
|
||||
FUNCTION get_hash_value(p_hash_key IN t_hash_key) RETURN t_hash_value;
|
||||
|
||||
-- FUNCTION EXISTS(p_plsql_table_name IN t_plsql_table_name
|
||||
-- ,p_hash_key IN t_hash_key) RETURN BOOLEAN;
|
||||
|
||||
-- FUNCTION COUNT(p_plsql_table_name IN t_plsql_table_name) RETURN NUMBER;
|
||||
|
||||
-- FUNCTION FIRST(p_plsql_table_name IN t_plsql_table_name) RETURN t_hash_value;
|
||||
|
||||
-- FUNCTION NEXT(p_plsql_table_name IN t_plsql_table_name
|
||||
-- ,p_hash_value IN t_hash_value) RETURN t_hash_value;
|
||||
|
||||
-- FUNCTION LAST(p_plsql_table_name IN t_plsql_table_name) RETURN t_hash_value;
|
||||
|
||||
-- PROCEDURE test;
|
||||
/**
|
||||
-- Get the language defined for the specified system user. If no system user identifier is passed, it will
|
||||
-- default to the connected user.
|
||||
-- @param p_syus_id The system user identifier, optional.
|
||||
-- @return The language specified for the suppied or current system user.
|
||||
*/
|
||||
--
|
||||
FUNCTION get_syus_lang(p_syus_id IN system_users.syus_id%TYPE DEFAULT NULL)
|
||||
RETURN system_users.LANGUAGE%TYPE;
|
||||
|
||||
/**
|
||||
Generic procedure to generate exceptions, based on the passed exception number
|
||||
The execption is looked up on the EXCEPTION_MESSAGES table using the exception number.
|
||||
#param p_exception_number The number of the exception message stored on the EXCEPTION_MESSAGES table.
|
||||
#param p_substitution_list Optional list of values to be subsituted into returned message
|
||||
#return Exception message
|
||||
--
|
||||
*/
|
||||
PROCEDURE raise_exception_error(p_exception_number IN exception_messages.exception_number%TYPE
|
||||
,p_substitution_list IN g_t_substitution_list DEFAULT c_empty_substitution_list);
|
||||
|
||||
/**
|
||||
-- Generic procedure to display exceptions with an additional message.
|
||||
-- Generic procedure to generate exceptions, based on the passed exception number
|
||||
-- The exception is looked up on the EXCEPTION_MESSAGES table using the exception number;
|
||||
-- An additional message passed in is then added to the end of the message from the table and displayed.
|
||||
-- @param p_exception_number The number of the exception message stored on the EXCEPTION_MESSAGES table.
|
||||
-- @param p_additional_message The additional message to be displayed after the generic message obtained from EXCEPTION_MESSAGES.
|
||||
--
|
||||
*/
|
||||
PROCEDURE raise_exception_error(p_exception_number IN exception_messages.exception_number%TYPE
|
||||
,p_additional_message IN VARCHAR2);
|
||||
|
||||
/**
|
||||
-- Generic procedure to lookup a custom exception message based on an exception number.
|
||||
-- The procedure loops through all the message record that match the exception number on the EXCEPTION_MESSAGES table
|
||||
-- and assembles the message from these components.
|
||||
-- @param p_exception_number The lookup number for the message(s) on EXCEPTION_MESSAGES
|
||||
-- @param p_message The exception message assembled from all the retrieved record for the message number used.
|
||||
-- @param p_exme_type The type of exception message (ERROR, WARNING, INFORMATION).
|
||||
*/
|
||||
|
||||
PROCEDURE get_exception_message(p_exception_number IN exception_messages.exception_number%TYPE
|
||||
,p_message IN OUT exception_messages.message%TYPE
|
||||
,p_exme_type IN OUT exception_messages.exme_type%TYPE
|
||||
,p_substitution_list IN g_t_substitution_list := c_empty_substitution_list
|
||||
,p_language IN system_users.LANGUAGE%TYPE DEFAULT caco_utilities.get_syus_lang);
|
||||
|
||||
FUNCTION raise_error(p_error_number IN exception_messages.exception_number%TYPE
|
||||
,p_substitution_list IN g_t_substitution_list DEFAULT c_empty_substitution_list)
|
||||
RETURN BOOLEAN;
|
||||
|
||||
/**
|
||||
-- Returns an array of integers.
|
||||
--
|
||||
-- @param p_how_many The number of integers to return.
|
||||
-- @return array type containing the number of integers requested.
|
||||
*/
|
||||
FUNCTION get_ints(p_how_many IN NUMBER) RETURN t_int_array;
|
||||
|
||||
FUNCTION cgrefvalue(p_domain IN cg_ref_codes.rv_domain%TYPE
|
||||
,p_meaning IN cg_ref_codes.rv_meaning%TYPE)
|
||||
RETURN VARCHAR2;
|
||||
|
||||
FUNCTION cgrefmeaning(p_domain IN cg_ref_codes.rv_domain%TYPE
|
||||
,p_value IN cg_ref_codes.rv_low_value%TYPE)
|
||||
RETURN VARCHAR2;
|
||||
|
||||
--
|
||||
-- Function to return value of global package defined variable g_global_date
|
||||
--
|
||||
FUNCTION get_global_date RETURN DATE;
|
||||
--
|
||||
-- Global variable used by function get_global_date
|
||||
--
|
||||
g_global_date DATE;
|
||||
|
||||
---
|
||||
-- Moved to caco_calculations.
|
||||
---
|
||||
/* FUNCTION hours_between(p_start_date IN DATE
|
||||
,p_end_date IN DATE) RETURN NUMBER;
|
||||
*/
|
||||
|
||||
FUNCTION get_syus_first_last_db_names(p_syus_id IN system_users.syus_id%TYPE)
|
||||
RETURN VARCHAR2;
|
||||
|
||||
FUNCTION chk_overlap(p_requested_start IN DATE
|
||||
,p_requested_end IN DATE
|
||||
,p_existing_start IN DATE
|
||||
,p_existing_end IN DATE) RETURN VARCHAR2;
|
||||
|
||||
FUNCTION get_system_name RETURN VARCHAR2;
|
||||
--
|
||||
FUNCTION get_system_customer RETURN NUMBER;
|
||||
--
|
||||
FUNCTION get_system_intermediary RETURN NUMBER;
|
||||
--
|
||||
FUNCTION get_system_user RETURN NUMBER;
|
||||
--
|
||||
FUNCTION get_syus_id RETURN system_users.syus_id%TYPE;
|
||||
--
|
||||
FUNCTION get_syus_name(p_syus_id IN system_users.syus_id%TYPE DEFAULT NULL)
|
||||
RETURN system_users.db_username%TYPE;
|
||||
--
|
||||
FUNCTION get_cust_id RETURN customers.cust_id%TYPE;
|
||||
--
|
||||
FUNCTION get_cust_name(p_cust_id IN customers.cust_id%TYPE DEFAULT NULL
|
||||
,p_default IN VARCHAR2 DEFAULT 'No Customer Name')
|
||||
RETURN customers.NAME%TYPE;
|
||||
--
|
||||
FUNCTION get_inte_id RETURN intermediaries.inte_id%TYPE;
|
||||
--
|
||||
FUNCTION get_inte_name(p_inte_id IN intermediaries.inte_id%TYPE DEFAULT NULL
|
||||
,p_default IN VARCHAR2 DEFAULT 'No Intermediary Name')
|
||||
RETURN intermediaries.NAME%TYPE;
|
||||
|
||||
--
|
||||
FUNCTION get_sypr_name(p_sypr_id IN system_profiles.sypr_id%TYPE
|
||||
,p_default IN VARCHAR2 DEFAULT 'No Profile Name')
|
||||
RETURN system_profiles.NAME%TYPE;
|
||||
--
|
||||
/* Moved to CACO_SECURITY 24-APR-2003
|
||||
|
||||
PROCEDURE change_cust_inte(p_inte_id IN intermediaries.inte_id%TYPE DEFAULT NULL
|
||||
,p_cust_id IN customers.cust_id%TYPE DEFAULT NULL
|
||||
,p_savebtn IN VARCHAR2 DEFAULT NULL
|
||||
,p_cancbtn IN VARCHAR2 DEFAULT NULL
|
||||
,p_message IN VARCHAR2 DEFAULT NULL);
|
||||
*/
|
||||
--
|
||||
PROCEDURE get_user_data(p_reload IN BOOLEAN DEFAULT FALSE);
|
||||
--
|
||||
|
||||
/**
|
||||
-- Function to return the text assocuation with a particular number and language.
|
||||
-- @param p_text_number The identifier for a particular string.
|
||||
-- @param p_language Two digit identifier for the language of the return text, defined in cg_ref_codes, optional.
|
||||
-- @return The text associated with the identifier and language passed in.
|
||||
--
|
||||
*/
|
||||
FUNCTION get_module_text(p_text_number IN NUMBER
|
||||
,p_language IN system_users.LANGUAGE%TYPE DEFAULT caco_utilities.get_syus_lang)
|
||||
RETURN VARCHAR;
|
||||
/**
|
||||
-- translate_lang
|
||||
-- A function to translate the suppled text from the source language to the desination language.
|
||||
-- This function uses an Internet translation service so will only work if an internet connection
|
||||
-- is available and may not return particularly accurate results (word for word rather than phrase)
|
||||
--
|
||||
*/
|
||||
FUNCTION translate_lang(p_text IN VARCHAR2 --module_text.text%TYPE
|
||||
,p_language_source IN VARCHAR2 DEFAULT 'EN'
|
||||
,p_language_destination IN VARCHAR2 DEFAULT 'EN')
|
||||
RETURN VARCHAR2;
|
||||
/**
|
||||
-- string_to_table
|
||||
*/
|
||||
PROCEDURE string_to_table(p_string IN VARCHAR2
|
||||
,p_delimiter IN VARCHAR2 := ','
|
||||
,p_table OUT t_string_table
|
||||
,p_count OUT NUMBER);
|
||||
/**
|
||||
-- add_module_text
|
||||
-- Function to add text into the module_text table for use within the application
|
||||
-- with the advantage that the text is automatically translated
|
||||
*/
|
||||
FUNCTION add_module_text(p_text IN module_text.text%TYPE
|
||||
,p_language IN module_text.LANGUAGE%TYPE)
|
||||
RETURN module_text.text_number%TYPE;
|
||||
/**
|
||||
-- Procedure to send an HTML email from the database.
|
||||
-- @param p_to Email address to send the message to
|
||||
-- @param p_from Email address that the message should appear to be coming from
|
||||
-- @param p_subject Subject of the email
|
||||
-- @param p_text Body text of the email, if HTML is also supplied, this may not be displayed
|
||||
-- @param p_html HTML body text of the email
|
||||
-- @param p_smtp_hostname SMTP mail server
|
||||
-- @param p_smtp_portname TCP port number
|
||||
--
|
||||
*/
|
||||
PROCEDURE html_email(p_to IN VARCHAR2 DEFAULT cout_system_configuration.get_configuration_item('CONTACT_EMAIL')
|
||||
,p_from IN VARCHAR2 DEFAULT caco_utilities.get_system_name
|
||||
,p_subject IN VARCHAR2 DEFAULT 'Fax Message from ' ||
|
||||
caco_utilities.get_system_name
|
||||
,p_text IN VARCHAR2 DEFAULT NULL
|
||||
,p_html IN VARCHAR2 DEFAULT NULL
|
||||
,p_smtp_hostname IN VARCHAR2 DEFAULT cout_system_configuration.get_configuration_item('SYSTEM_SMTP_SERVER')
|
||||
,p_smtp_portnum IN VARCHAR2 DEFAULT cout_system_configuration.get_configuration_item('SYSTEM_SMTP_PORT'));
|
||||
/**
|
||||
-- convert_date_to_gas_day
|
||||
-- A function to convert a supplied date and time to the relavent gas day
|
||||
*/
|
||||
FUNCTION convert_date_to_gas_day(p_date IN DATE) RETURN DATE;
|
||||
/**
|
||||
-- get_dst_hours
|
||||
-- A function to return the number of hours in the supplied gas day, taking into account BST.
|
||||
*/
|
||||
FUNCTION get_dst_hours(p_gas_day IN DATE) RETURN NUMBER;
|
||||
/**
|
||||
-- get_hours
|
||||
-- A function to return an array of hours in a particular gas day,
|
||||
-- starting at the beginning of the gas day and taking into account BST.
|
||||
*/
|
||||
FUNCTION get_hours(p_gas_day IN DATE) RETURN t_int_array;
|
||||
/**
|
||||
-- Checks that two dates are sequentially correct and are in the future
|
||||
*/
|
||||
FUNCTION check_dates(p_period_start IN DATE
|
||||
,p_period_end IN DATE
|
||||
,p_check_past IN BOOLEAN) RETURN BOOLEAN;
|
||||
/**
|
||||
Function to return the customer_type code for the input customer
|
||||
|
||||
*/
|
||||
FUNCTION cuty_code_for_cust(p_cust_id IN customers.cust_id%TYPE) RETURN customer_types.code%TYPE;
|
||||
--
|
||||
/**
|
||||
Function to return the customer_type id for the user (based on the customer they are acting for i.e. no parameter required)
|
||||
|
||||
*/
|
||||
FUNCTION cuty_id_for_user RETURN customer_types.cuty_id%TYPE;
|
||||
/**
|
||||
Function to return the customer_type code for the user (based on the customer they are acting for i.e. no parameter required)
|
||||
|
||||
*/
|
||||
FUNCTION cuty_code_for_user RETURN customer_types.code%TYPE;
|
||||
--
|
||||
/**
|
||||
Function to return a flag to indicate the current user has the Access Manager SYSTEM privilege.
|
||||
|
||||
*/
|
||||
FUNCTION user_has_system RETURN VARCHAR2;
|
||||
/**
|
||||
Function to return a flag to indicate the current user has the Access Manager EFT Admin privilege.
|
||||
|
||||
*/
|
||||
FUNCTION user_has_EFT_admin RETURN VARCHAR2;
|
||||
--
|
||||
/**
|
||||
Function to return the name of a network point from a provided network point id.
|
||||
|
||||
*/
|
||||
FUNCTION get_nepo_name(p_nepo_id IN network_points.nepo_id%TYPE DEFAULT NULL)
|
||||
RETURN network_points.name%TYPE;
|
||||
--
|
||||
/**
|
||||
Function to output designer screen buttons for Maintain Categories screen so that they can be
|
||||
displayed above the record list.
|
||||
|
||||
*/
|
||||
FUNCTION efnow010_output_form_buttons RETURN VARCHAR2;
|
||||
--
|
||||
/**
|
||||
Function to output designer screen buttons for Maintain Parameters screen so that they can be
|
||||
displayed above the record list.
|
||||
|
||||
*/
|
||||
FUNCTION efnow020_output_form_buttons RETURN VARCHAR2;
|
||||
--
|
||||
/**
|
||||
Function to convert a string containing a number into a thousand separated string.
|
||||
|
||||
*/
|
||||
FUNCTION to_thousand_separated(p_val IN VARCHAR2)
|
||||
RETURN VARCHAR2;
|
||||
--
|
||||
/**
|
||||
Function to convert a number into a thousand separated string.
|
||||
|
||||
*/
|
||||
FUNCTION to_thousand_separated(p_val IN NUMBER)
|
||||
RETURN VARCHAR2;
|
||||
--
|
||||
/**
|
||||
Function to convert a string containing a thousand separated number into a number.
|
||||
|
||||
*/
|
||||
FUNCTION thousand_separated_to_num(p_val IN VARCHAR2)
|
||||
RETURN NUMBER;
|
||||
--
|
||||
/**
|
||||
Function to remove the thousand separators from a string containing a thousand separated number.
|
||||
|
||||
*/
|
||||
FUNCTION thousand_separated_to_char(p_val IN VARCHAR2)
|
||||
RETURN VARCHAR2;
|
||||
--
|
||||
/**
|
||||
Function to remove the thousand separators from an array containing strings of thousand separated numbers.
|
||||
|
||||
*/
|
||||
FUNCTION thousand_separated_to_char(p_val IN owa_util.vc_arr)
|
||||
RETURN owa_util.vc_arr;
|
||||
--
|
||||
/**
|
||||
Procedure to output a thousand separator javascript function.
|
||||
|
||||
*/
|
||||
PROCEDURE thousand_separator_js;
|
||||
--
|
||||
END caco_utilities;
|
||||
/
|
||||
Reference in New Issue
Block a user