       p_first_column_is_template => true);
   end generate_text;
 
+
+  procedure generate_text(
+    p_stmt in clob,
+    p_result out varchar2,
+    p_delimiter in varchar2 default null) 
+  as
+    l_row_tab row_tab;
+  begin
+    copy_table_to_row_tab(
+      p_stmt => p_stmt,
+      p_row_tab => l_row_tab,
+      p_first_column_is_template => true);
+
+    bulk_replace(
+      p_template => null,
+      p_row_tab => l_row_tab,
+      p_delimiter => p_delimiter,
+      p_result => p_result,
+      p_first_column_is_template => true);
+  end generate_text;
+
+
+  procedure generate_text(
+    p_stmt in clob,
+    p_result out dbms_sql.varchar2a,
+    p_delimiter in varchar2 default null) 
+  as
+    l_row_tab row_tab;
+  begin
+    copy_table_to_row_tab(
+      p_stmt => p_stmt,
+      p_row_tab => l_row_tab,
+      p_first_column_is_template => true);
+
+    bulk_replace(
+      p_template => null,
+      p_row_tab => l_row_tab,
+      p_delimiter => p_delimiter,
+      p_result => p_result,
+      p_first_column_is_template => true);
+  end generate_text;
+
+
+  function generate_text(
+    p_stmt in clob,
+    p_delimiter in varchar2 default null) 
+    return varchar2 
+  as
+    l_string varchar2(32767);
+  begin
+    generate_text(
+      p_stmt => p_stmt,
+      p_result => l_string,
+      p_delimiter => p_delimiter);
+    return l_string;
+  end generate_text;
+
+
+  function generate_text(
+    p_cursor in sys_refcursor,
+    p_delimiter in varchar2 default null) 
+    return varchar2 
+  as
+    l_string varchar2(32767);
+    l_cur sys_refcursor := p_cursor;
+  begin
+    generate_text(
+      p_cursor => l_cur,
+      p_result => l_string,
+      p_delimiter => p_delimiter);
+    return l_string;
+  end generate_text;
+
+
 begin
   initialize;
 end code_generator;

  as
    l_column_name varchar2(30);
    l_column_count integer := 1;
  begin
    -- DESCRIBE_COLUMNS ist deprecated wegen limitierter Spaltenlaenge
    dbms_sql.describe_columns2(
      c => p_cur, 
      col_cnt => l_column_count,
      desc_t => p_cur_desc);
      
    for i in 1 .. l_column_count loop
      if i = 1 and p_first_column_is_template then
        l_column_name := C_ROW_TEMPLATE;
      else
        l_column_name := p_cur_desc(i).col_name;
      end if;
        
      -- Spalte als leeren Wert in der PL/SQL-Tabelle anlegen, um ihn als Variable
      -- referenzieren zu koennen
      p_key_value_tab(l_column_name) := null;
        
      -- Registriere Variable als Ausgabevariable dieser Spalte
      dbms_sql.define_column(
        c => p_cur, 
        position => i,
        column => p_key_value_tab(l_column_name));
    end loop;
  end describe_columns;
    
  
  /* Prozedur zum Beschreiben eines Cursors
   * %param p_stmt SQL-Anweisung, die analysiert werden soll
   * %param p_cur ID des Cursors

        end if;
      end if;
    end loop;

    if l_missing_anchors is not null then
      l_missing_anchors := trim('|' from l_missing_anchors);
      -- msg_log.error(msg_pkg.code_gen_missing_anchors, msg_args(l_missing_anchors));
    end if;

  end bulk_replace;


  procedure bulk_replace(
    p_template in varchar2,
    p_row_tab in row_tab,
    p_delimiter in varchar2,
    p_result out varchar2,
    p_first_column_is_template boolean default false) 
  as
    l_result varchar2(32767);
    l_template varchar2(4000);
    l_key_value_tab key_value_tab;
  begin
    l_template := p_template;
    if p_row_tab.count > 0 then
      for i in p_row_tab.first .. p_row_tab.last loop
        l_key_value_tab := p_row_tab(i);

        if p_first_column_is_template then
          l_template := l_key_value_tab(c_row_template);
        end if;

        bulk_replace(
          p_template => l_template,
          p_key_value_tab => l_key_value_tab,
          p_result => l_result);

        if i < p_row_tab.last then
          l_result := l_result || p_delimiter;
        end if;

        p_result := p_result || l_result;
      end loop;
    else
      raise no_data_found;
    end if;
  end bulk_replace;


  procedure bulk_replace(
    p_template in varchar2,
    p_row_tab in row_tab,
    p_delimiter in varchar2,
    p_result out dbms_sql.varchar2a,
    p_first_column_is_template boolean default false)
  as
    l_result varchar2(32767);
    l_template varchar2(4000);
    l_key_value_tab key_value_tab;
  begin
    l_template := p_template;
    if p_row_tab.count > 0 then
      for i in p_row_tab.first .. p_row_tab.last loop
        l_key_value_tab := p_row_tab(i);

        if p_first_column_is_template then
          l_template := l_key_value_tab(c_row_template);
        end if;

        bulk_replace(
          p_template => l_template,
          p_key_value_tab => l_key_value_tab,
          p_result => l_result);

        if i < p_row_tab.last then
          l_result := l_result || p_delimiter;
        end if;

        p_result(i) := l_result;
      end loop;
    else
      raise no_data_found;
    end if;
  end bulk_replace;


  procedure generate_text(
    p_template in varchar2,
    p_stmt in clob,
    p_result out varchar2,
    p_delimiter in varchar2 default null)
  as
