return: text
lang: plpgsql
src: |
  DECLARE	
  	result TEXT;
  BEGIN
  	
  	-- Standard
  		UPDATE activite.t_gmt_c
  		SET
  			gmt_code = t_gmt.code,
  			gmt_texte = t_gmt.texte
  		FROM base.t_gmt
  		WHERE 
  			t_gmt_c.gmt_id = t_gmt.oid 
  			AND (
  				t_gmt_c.gmt_code IS DISTINCT FROM t_gmt.code OR
  				t_gmt_c.gmt_texte IS DISTINCT FROM t_gmt.texte
  			);
  		INSERT INTO activite.t_gmt_c(
  			 gmt_id, gmt_code,gmt_texte) 
  		SELECT 
  			t_gmt.oid, 
  			t_gmt.code,
  			t_gmt.texte
  		FROM  base.t_gmt
  		WHERE t_gmt.oid NOT IN (SELECT gmt_id FROM activite.t_gmt_c)
  		ORDER BY t_gmt.oid;
  	
  		
  	RETURN 'OK';
  END;