/*****************************************************************************
*
* Filename         - $Workfile:   flight_trace_v2.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 View
*
* Language         - Oracle SQL*Plus script
*
* Classification   - Commercial In Confidence
*
*          (c) Ultra Electronics Limited, 1997
*
*****************************************************************************/
/****************************************************************************
* @(#)$Workfile:   flight_trace_v2.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:   /pvcsarch/db_ora/db/source/live/views/flight_trace_v2.svl  $
* 
*    Rev 1.4   21 Jun 2001 15:37:10   tagtrak
* OR:
* CR:
* Re-baseline version 4.0.0 to include patches.
* 
*    Rev 1.3   20 Sep 1999 15:17:40   tagtrak
*  
* 
*    Rev 1.2   25 Sep 1998 10:07:44   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.1.2.0   18 Aug 1998 09:37:44   tagtrak
* OR: 12484
* CR: 12484
* REV:
* Merging Vienna (0.3.1E) and Core Product (0.2.5E).
* Andrew Walker
* 
*    Rev 1.1.1.0   04 Jun 1998 15:34:16   tagtrak
* OR:
* CR: 12098
* REV:
* Vienna Modifications
* Andrew Walker
* 
*    Rev 1.1   02 Apr 1998 19:47:56   tagtrak
* OR:
* CR:
* REV:
* Initial Issue
* See label for concession
* 
*    Rev 1.0   22 Oct 1997 16:50:50   tagtrak
* OR:
* CR:
* REV:
* Initial check-in
*
****************************************************************************/

PROMPT Creating view   FLIGHT_TRACE_V2   ;
CREATE OR REPLACE FORCE VIEW   FLIGHT_TRACE_V2   (FLIGHT_ID  , FLIGHT_NO,  FLIGHT_DATE, 
FLT_TRACE_TIME  , 
NEW_FLIGHT_STATUS, NEW_FLIGHT_STATUS_NAME  , USER_ID  , SCANNER_ID  ,LOCATION,
LOGINNAME
) as
select
  ft.flight_id,
	fl.flight_no,
	fl.flight_date,
  to_char(ft.flt_trace_time, 'DD/MM/YYYY HH24:MI'),
  ft.new_flight_status,
  decode (ft.new_flight_status,
		'FO', 'Flight Open',
		'GC', 'Gate Closed',
		'FC', 'Flight Closed',
		'FD', 'Flight Delayed',
		'PD', 'Post Departure',
		'FG', 'Flight Gated',
		'DL', 'Flight Delayed',
		'Invalid Status'),
  ft.user_id,
  ft.scanner_id,
  'location',
	tu.loginname
from
  tagtrak_users tu, flight_trace ft, flight fl
where
	fl.flight_id = ft.flight_id and
	fl.op_flight_id is null     and
	tu.user_id   = ft.user_id
;

