/*****************************************************************************
*
* Filename         - $Workfile:   loading_prohibited.sql  $
*
*                     Name              Date      Version     CR Number
*                     Martin Helliwell 25/03/02     1.0         15580
* 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:   loading_prohibited.sql  $  $Revision:   1.0  $
*
* 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/loading_prohibited.sqv  $
* 
****************************************************************************/

PROMPT CREATE OR REPLACE FUNCTION loading_prohibited 

CREATE OR REPLACE
FUNCTION loading_prohibited 
   (p_flight_id IN flight.flight_id%TYPE
   ) RETURN BOOLEAN IS
  v_loading_prohibited PLS_INTEGER DEFAULT 0;
  BEGIN
    SELECT DECODE(INSTR(db_value,flight_status)
                 ,0,0
                 ,1)
    INTO v_loading_prohibited
    FROM flight
    ,db_config
    WHERE flight_id = p_flight_id
    AND db_item = 'LOADING_PROHIBITED';

    RETURN v_loading_prohibited = 1;
  EXCEPTION
    WHEN NO_DATA_FOUND THEN
      RETURN FALSE;
  END loading_prohibited;
/
