/*****************************************************************************
*
* Filename         - $Workfile:   flightpax_bags.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:   flightpax_bags.sql  $  $Revision:   1.6  $
*
* 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/flightpax_bags.sqv  $
* 
*    Rev 1.6   25 Sep 1998 10:03:30   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.5.2.0   18 Aug 1998 09:35:14   tagtrak
* OR: 12484
* CR: 12484
* REV:
* Merging Vienna (0.3.1E) and Core Product (0.2.5E).
* Andrew Walker
* 
*    Rev 1.5.1.0   04 Jun 1998 15:32:16   tagtrak
* OR:
* CR: 12098
* REV:
* Vienna Modifications
* Andrew Walker
* 
*    Rev 1.5   02 Apr 1998 19:33:58   tagtrak
* OR:
* CR:
* REV:
* Initial Issue
* See label for concession
* 
*    Rev 1.4   15 Jan 1998 12:12:06   tagtrak
* OR: OR11101, TN13, TN15
* CR:
* REV:
* Phase 2C to Phase 3 upgrade plus code review actions and resolving some technical isses.
* 
*    Rev 1.3   24 Oct 1997 11:06:14   tagtrak
* Added PVCS header information
*
****************************************************************************/

PROMPT create or replace procedure flightpax_bags 

create or replace procedure flightpax_bags (
	fltno   in out  char,
	fltdate in out  char,
  siteid  in out  number,
	seqno   in out  number,
	fltid   in out  number,
	paxid      out  number,
	nobags     out  number
) 

as  
begin

	/*
	 * - Initialise Variables
	 * - Call the flight_id procedure
	 * - IF the fltid variable is greater than 0 then (obtained from the
	 *   flight_id procedure call.
	 *   Select the pax_id and no_of_bags from the pax table where the
	 *    pax_sequenence_no equals the seqno parameter and the flight_id
	 *    equals the fltid parameter and the delete_marker != 1.  If no
	 *    data is found then initialise variables to error condition.
	 */

	fltid  := -1;
	paxid  := -1;
	nobags := -1;
 
	/* get flight id (booked) */
	flight_id (fltno, fltdate, siteid, fltid);
 
	if (fltid > 0) then 
	begin
		/* get pax and bags */
		select 
			pax_id,
			no_of_bags 
		into 
			paxid,
			nobags 
		from
			pax
		where
			pax_sequence_no =  seqno and
			booked_flight_id =  fltid and
			delete_marker  != 1;

		exception when NO_DATA_FOUND then
		begin
			paxid  := -1;
			nobags := -1;
		end;
	end;

	end if;
 
end flightpax_bags;
/
