/*****************************************************************************
*
* Filename         - $Workfile:   convert_class.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:   convert_class.sql  $  $Revision:   1.5  $
*
* 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/convert_class.sqv  $
* 
*    Rev 1.5   25 Sep 1998 10:03:02   tagtrak
* OR: 12484
* CR: 12484
* REV:
* Merged Vienna (0.3.1E) and Core Product (0.2.5E) -
* branch ATS revision moved to trunk.
* Andrew Walker
* 
*    Rev 1.4.2.0   18 Aug 1998 09:34:52   tagtrak
* OR: 12484
* CR: 12484
* REV:
* Merging Vienna (0.3.1E) and Core Product (0.2.5E).
* Andrew Walker
* 
*    Rev 1.4.1.0   14 Jul 1998 13:38:46   tagtrak
* OR: 12309
* CR: 12309
* REV:
* Fixed problem with assigning parameter value directly to asingle char variable.
* Andrew
* 
*    Rev 1.4   02 Apr 1998 19:32:34   tagtrak
* OR:
* CR:
* REV:
* Initial Issue
* See label for concession
* 
*    Rev 1.3   15 Jan 1998 12:11:30   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:02:44   tagtrak
* Added PVCS header information
*
****************************************************************************/


           
PROMPT create or replace function convert_class
           
create or replace function convert_class (
	pcls in char
)
	return char
is

 conv_cls char(1);
  
begin

	/*
	 * - if pcls = 'F', 'P' or 'A' then
	 *   conv_cls = 'F'
	 * - else
	 *   if pcls = 'J', 'C', 'D' or 'Z' then
	 *     conv_cls = 'J'
	 *   else
	 *     if pcls = 'Y', 'S', 'W', 'B', 'H', 'Q', 'M', 'T', 'K', 'L'
	 *     'V' or 'G' then
	 *       conv_cls = 'Y'
	 *     else
	 *       conv_cls = pcls
	 */

	if (pcls = 'F' or pcls = 'P' or pcls = 'A') then 
		conv_cls := 'F';
	else 
		if (pcls = 'J' or pcls = 'C' or pcls = 'D' or pcls = 'Z') then 
			conv_cls := 'J';
		else 
			if (pcls = 'Y' or pcls = 'S' or pcls = 'W' or pcls = 'B' or
				pcls = 'H' or pcls = 'Q' or pcls = 'M' or pcls = 'T' or
				pcls = 'K' or pcls = 'L' or pcls = 'V' or pcls = 'G') then 

				conv_cls := 'Y';
			else
				conv_cls := substr(pcls,1,1);
			end if;
		end if;
	end if;
 
	return conv_cls;

end convert_class;
/
