/* $Id$ */
/*============================================================================*
 |                 Copyright (c) 2008 Applaud Solutions UK Ltd                |
 |                             All rights reserved                            |
 *===========================================================================*/

SET FEEDBACK OFF
SET VERIFY OFF
SET SERVEROUT ON

DECLARE

  l_input        varchar2(400) := '&1';
  l_sql          varchar2(400);
  l_return       varchar2(400) := 'N';

BEGIN

  --
  -- Fetch the result using dynamic SQL in case
  -- the table does not exist, ie, an invalid
  -- Oracle Apps Release.
  --
  l_sql := ' SELECT distinct ''Y'' '
        || ' FROM   ad_bugs '
        || ' WHERE  bug_number = ''' ||l_input||'''';
  
  EXECUTE IMMEDIATE l_sql INTO l_return;

  dbms_output.put_line(l_return);

EXCEPTION

  WHEN others THEN
    --
    -- Table does not exist, invalid Oracle apps release
    --
    dbms_output.put_line('N');
 
END;
/
COMMIT;
EXIT;
