   LOOP
     IF vars IS NULL THEN
       vars := '';
+      child_ref_block := '';
       ref_block := '';
-      child_ref_block := '';
     END IF;
 
     IF (

DECLARE
  ddl_command TEXT := 'CREATE OR REPLACE FUNCTION '||$2||'.delete_' ||citydb_pkg.get_short_name($1);
  declare_block TEXT := E'\nDECLARE\n  deleted_ids int[] := ''{}'';';
  set_objclass_block TEXT := '';
  pre_block TEXT := '';
  post_block TEXT := '';
  delete_agg_start TEXT := E'\n  WITH delete_objects AS (\n  ';

DECLARE
  ddl_command TEXT := 'CREATE OR REPLACE FUNCTION '||$2||'.delete_'||citydb_pkg.get_short_name($1);
  declare_block TEXT := E'\nDECLARE\n  deleted_id INTEGER;';
  objclass_block TEXT := '';
  pre_block TEXT := '';
  post_block TEXT := '';
  delete_block TEXT := '';
