/*============================================================================*
 |                 Copyright (c) 2008 Applaud Solutions UK Ltd                |
 |                             All rights reserved                            |
 *===========================================================================*/
 
SET FEEDBACK OFF
SET VERIFY OFF
SET SERVEROUT ON

DECLARE

  l_host_name  varchar2(400) := '&1';
  l_patch_name varchar2(400) := '&2';
  l_sql        varchar2(400);
  l_node_type    varchar2(400) := 'master';
  
BEGIN

  --
  -- Retrieve the current node type using dynamic SQL
  -- in case the table does not yet exist.
  --
  l_sql := ' select node_type '
		|| ' from xxas_com_applied_patches '
		|| ' where node_name = ''' || l_host_name || ''''
		|| ' and patch_name = ''' || l_patch_name || '''';
		
	EXECUTE IMMEDIATE l_sql INTO l_node_type;

	dbms_output.put_line(l_node_type);

EXCEPTION

  WHEN others THEN
    --
    -- Table does not exist, invalid Oracle apps release
    --
    dbms_output.put_line(l_node_type);

END;
/
COMMIT;
EXIT;