      /*  $Revision$
 *  $Id$
 */

/*
 * Dit is een frame, de echte functionaliteit zit in de verschillende includes
 *
 * Ambitie is om deze includes zodanig te definieren dat ze tbv development als los script gedraaid kunnen worden
 * en ze hier pas in de proc komen, maar dat is nog maar de vraag of dat lukt. JE mag dan iig geen SQLPlus gebruiken.
 */

#include "comsql.h"

CREATE OR REPLACE PACKAGE ini
AS
   FUNCTION getImportKey (p_import_app_code VARCHAR2) RETURN NUMBER;
   PROCEDURE fmis_ini;
   PROCEDURE itsm_ini;
   PROCEDURE init (modulenaam IN VARCHAR2);
END ini;
/

CREATE OR REPLACE PACKAGE BODY ini AS

   -- Local tooling for INI
   FUNCTION getImportKey (p_import_app_code VARCHAR2)
   RETURN NUMBER
   AS
      v_import_key     NUMBER;
      v_import_app_key NUMBER;

   BEGIN
      SELECT fac_import_app_key
        INTO v_import_app_key
        FROM fac_import_app
       WHERE fac_import_app_code = UPPER(p_import_app_code);

      INSERT INTO fac_import (fac_import_app_key, fac_import_datum_gelezen)
         VALUES (v_import_app_key, SYSDATE)
         RETURNING fac_import_key INTO v_import_key;

      RETURN v_import_key;
   END;
   -- End of local tooling


   PROCEDURE fmis_ini
   AS
   BEGIN
#include "fmis/fmis_ini.sql"
   END;

   PROCEDURE itsm_ini
   AS
   BEGIN
#include "itsm/itsm_ini.sql"
   END;

   PROCEDURE init (modulenaam IN VARCHAR2)
   AS
   BEGIN
      -- not yet supported
      NULL;
   END;

END ini;
/

REGISTERRUN('$Id$')
