return: text
lang: plpgsql
parameters:
  p0:
    type: text
    name: i_column_name
src: |
  DECLARE	
  	to_column_name text;
  BEGIN
  	to_column_name = i_column_name;
  	
    to_column_name = regexp_replace(to_column_name, '\[LISTE:(.*?)\]', '(SELECT to_id FROM rh.t_listes JOIN rh.t_listes_contenu ON t_listes.oid = t_listes_contenu.liste_id WHERE t_listes.code = ''\1'')', 'g');
    to_column_name = regexp_replace(to_column_name, '\[CLASSE:(.*?)\]', '(SELECT to_id FROM rh.t_classes JOIN rh.t_classes_sections ON classe_id = t_classes.oid JOIN rh.t_classes_sections_elements ON section_id = t_classes_sections.oid WHERE t_classes.code || '':'' || t_classes_sections.code = ''\1'')', 'g');
  		
  	RETURN to_column_name;
  END;