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

SET FEEDBACK OFF
SET VERIFY OFF
SET SERVEROUT ON

DECLARE

  l_filename varchar2(200) := '&1';
  l_sql      varchar2(400);
  l_result   number;

BEGIN

  --
  -- Fetch the file version using dynamic SQL for cases
  -- where the table does not yet exist.
  --
  l_sql := ' SELECT file_ver '
        || ' FROM   xxas_com_applied_files '
        || ' WHERE  file_name = ''' || l_filename || '''';
  
  EXECUTE IMMEDIATE l_sql INTO l_result;

  dbms_output.put_line(to_char(l_result));

EXCEPTION

  WHEN others THEN
    --
    -- File does not yet exist, so return zero
    --
    dbms_output.put_line('0');
 
END;
/
COMMIT;
EXIT;
