/*****************************************************************************
*
* Filename         - $Workfile:   gaddrc.sql  $
*
*                     Name              Date      Version     CR Number
* Author           - See revision history below.
* Last Update      - See revision history below.
*
* Project Name     - TAGTRAK(Oracle Database)
*
* Source Code
* Identifier       - 0/3/300/8010/112
*
* Design Spec
* Section          - 
*
* Contents         - Live Schema Stored Procedure
*
* Language         - Oracle SQL*Plus script
*
* Classification   - Commercial In Confidence
*
*          (c) Ultra Electronics Limited, 1997
*
*****************************************************************************/
/****************************************************************************
* @(#)$Workfile:   gaddrc.sql  $  $Revision:   1.4  $
*
* Revision History
*
* Note that user tagtrak is many users. For these users the user
* name is entered as the last line in the change description.
*
* $Log:   /shared/pvcs/tagtarch/db_ora/db/source/live/procedures/gaddrc.sqv  $
* 
*    Rev 1.4   02 Apr 1998 19:34:32   tagtrak
* OR:
* CR:
* REV:
* Initial Issue
* See label for concession
* 
*    Rev 1.3   15 Jan 1998 12:12:20   tagtrak
* OR: OR11101, TN13, TN15
* CR:
* REV:
* Phase 2C to Phase 3 upgrade plus code review actions and resolving some technical isses.
* 
*    Rev 1.2   24 Oct 1997 11:07:26   tagtrak
* Added PVCS header information
*
****************************************************************************/


PROMPT create or replace procedure get_addr_count

create or replace procedure get_addr_count (
	dproc in      char,
	dunit in      char,
	rv    in out  number
)
as

begin

	/*
	 * - IF the dproc parameter is equal to 'ALL' then
	 *   Count the process names from the system_cfg table where the
	 *   process name is not equal to 'DUMMY'.
	 * - ELSEIF the dunit parameter is equal to '0' then
	 *   Count the process names from the system_cfg table where the
	 *   process name is equal to the dproc parameter.
	 * - ELSE
	 *   Count the process names from the system_cfg table where the
	 *   process name is equal to the dproc parameter and the unit_name
	 *   is equal to the dunit parameter.
	 */

	if (dproc = 'ALL') then 

		/*
		 * Send to every process, but not the DUMMY DCS used by the
		 * MWS Flight Create screen.
		 */

		select
			count(process_name) 
		into
			rv 
		from
			system_cfg
		where
			process_name != 'DUMMY';

	elsif (dunit = '0') then 

		/*
		 * Send to all processes with name dproc.
		 */

		select
			count(process_name) 
		into
			rv 
		from
			system_cfg
		where
			process_name = dproc;

	else 

		/*
		 * Send to the process with name dproc and unit dunit.
		 */

		select
			count(process_name) 
		into
			rv 
		from
			system_cfg
		where
			process_name = dproc and
			unit_name    = dunit;

	end if;

end get_addr_count;
/
