/*****************************************************************************
*
* Filename         - $Workfile:   extract_carrier.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         - extract_carrier stored function
*
* Language         - Oracle SQL*Plus script
*
* Classification   - Commercial In Confidence
*
*          (c) Ultra Electronics Limited, 1998
*
*****************************************************************************/
/****************************************************************************
* @(#)$Workfile:   extract_carrier.sql  $  $Revision:   1.2  $
*
* 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:   /pvcsarch/db_ora/db/source/live/procedures/extract_carrier.svl  $
* 
*    Rev 1.2   20 Sep 1999 14:40:38   tagtrak
*  
* 
*    Rev 1.1   02 Apr 1998 19:33:02   tagtrak
* OR:
* CR:
* REV:
* Initial Issue
* See label for concession
* 
*    Rev 1.0   26 Feb 1998 10:19:52   tagtrak
* OR:
* CR:
* REV:
* Initial core product version
*
****************************************************************************/

/*
 * extract_carrier
 * Accepts a 'normalised' (see validate_flight) flight number
 * and returns the carrier alpha code segment.
 */
PROMPT create or replace function extract_carrier

create or replace function extract_carrier (
	flight_no  in   flight.flight_no%type
)
	return carrier_lookup.alpha_code%type

is
begin

	/*
	 * Carrier alpha code is the first three characters of the
	 * normalised flight number.
	 */
	return rtrim(substr(flight_no,1,3));

end extract_carrier;
/
