/*****************************************************************************
*
* Filename         - $Workfile:   flight_id.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
*
*****************************************************************************/

PROMPT create or replace procedure flight_id 

create or replace procedure flight_id (
   fltno        in   char,
   fltdate      in   char,
   psiteid      in   number,
   fltid        out  number,
   pflight_type in   flight.flight_type%TYPE DEFAULT 'O') 
as  
begin

   /*
    * - Initialise variable
    * - Select the flight_id from the flight table where the flight_no
    *   is equal to the flight_no passed in as a parameter and the
    *   flight_date is also equal to the flight_date passed in as a
    *   parameter.  If no data is found, then NULL.
    */

   fltid := 0;
 
   select
      flight_id 
   into
      fltid 
   from
      flight
   where
      flight_no   = fltno and
      flight_date = fltdate and
      site_id     = psiteid and
      flight_type = pflight_type; 

   exception WHEN NO_DATA_FOUND then
      NULL;

end flight_id;
/
