-create or replace package body code_generator
+create or replace package body code_generator 
 as
-  
-  C_ROW_TEMPLATE constant varchar2(30) := '$$ROW_TEMPLATE';
+
+  c_row_template constant varchar2(30) := '$$ROW_TEMPLATE';
+  c_date_type constant binary_integer := 12;
+  c_date_format constant varchar2(30) := 'dd.mm.yyyy hh24:mi:ss';
   g_ignore_missing_anchors boolean;
-  
+
+  type ref_rec_type is record(
+    r_string varchar2(32767),
+    r_date date,
+    r_clob clob);
+  l_ref_rec ref_rec_type;
+
+
   /* Hilfsfunktionen */
-  
+
   /* Prozedur zum Oeffnen eines Cursors
    * %param p_cur ID des Cursors
    * %usage Oeffnet einen neuen Cursor fuer eine uebergebene SQL-Anweisung
    */
   procedure open_cursor(
-    p_cur out integer)
-  as
-  begin
-    p_cur := dbms_sql.open_cursor;
+    p_cur out integer) 
+  as
+  begin
+    if not dbms_sql.is_open(c => p_cur) then
+      p_cur := dbms_sql.open_cursor;
+    end if;
   end open_cursor;
-  
-  
+
+
   /* Prozedur zum Oeffnen eines Cursors
    * %param p_cur ID des Cursors
    * %param p_cursor SYS_REFCURSOR, Ueberladung fuer einen bereits geoffneten Cursor

   */
  procedure open_cursor(
    p_cur out integer,
    p_cursor in out nocopy sys_refcursor)
  as
  begin
    p_cur := dbms_sql.to_cursor_number(p_cursor);
  end open_cursor;
  
  
  /* Prozedur zum Analysieren eines Cursor
   * %param p_cur ID des Cursors
   * %param p_cur_desc DBMS_SQL.DESC_TAB2 mit den Details zu einem Cursor

    p_cur in out nocopy integer,
    p_cur_desc in out nocopy dbms_sql.desc_tab2,
    p_key_value_tab in out nocopy key_value_tab,
    p_first_column_is_template boolean default false) 
  as
  begin
    open_cursor(p_cur, p_cursor);

    describe_columns(
      p_cur => p_cur,
      p_cur_desc => p_cur_desc,
      p_key_value_tab => p_key_value_tab,
      p_first_column_is_template => p_first_column_is_template);
  end describe_cursor;


  /* Pozedur zum Kopieren einer Zeile in die vorbereitete PL/SQL-Tabelle
   * %param p_cur ID des Cursor
   * %param p_cur_desc DBMS_SQL.DESC_TAB2 mit den Details zu einem Cursor
