-- Name: a_xnat_reconstructedimagedata_scanid(integer, integer, character varying, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.a_xnat_reconstructedimagedata_scanid(integer, integer, character varying, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     row_ct int4;
    begin
      row_ct := 0;
       --UPDATE LOCAL ROW
      FOR current_row IN SELECT xnat_reconstructedImageData_scanID.*, meta.meta_data_id, meta.status AS meta_status FROM xnat_reconstructedImageData_scanID LEFT JOIN xnat_reconstructedImageData_scanID_meta_data meta ON xnat_reconstructedImageData_scanID.reconstructedImageData_scanID_info=meta.meta_data_id WHERE  xnat_reconstructedimagedata_scanid_id=$1
      LOOP
           row_ct := row_ct+1;
           IF (current_row.meta_status!=$3) THEN
         UPDATE xnat_reconstructedImageData_scanID_meta_data SET status=$3,activation_date=NOW(),activation_user_xdat_user_id=$2 WHERE meta_data_id=current_row.meta_data_id;
           END IF;
          
      END LOOP;
	
	 RETURN '';
    end;
$_$;


ALTER FUNCTION public.a_xnat_reconstructedimagedata_scanid(integer, integer, character varying, boolean) OWNER TO xnat;

--
-- Name: a_xnat_regionresource(integer, integer, character varying, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.a_xnat_regionresource(integer, integer, character varying, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     row_ct int4;
    begin
      row_ct := 0;
       --UPDATE LOCAL ROW
      FOR current_row IN SELECT xnat_regionResource.*, meta.meta_data_id, meta.status AS meta_status FROM xnat_regionResource LEFT JOIN xnat_regionResource_meta_data meta ON xnat_regionResource.regionResource_info=meta.meta_data_id WHERE  xnat_regionresource_id=$1
      LOOP
           row_ct := row_ct+1;
           IF (current_row.meta_status!=$3) THEN
         UPDATE xnat_regionResource_meta_data SET status=$3,activation_date=NOW(),activation_user_xdat_user_id=$2 WHERE meta_data_id=current_row.meta_data_id;
           END IF;
          
        IF ((current_row.file_xnat_abstractresource_id IS NOT NULL)) THEN
          PERFORM  a_xnat_abstractResource(current_row.file_xnat_abstractresource_id, $2,$3,false);
        END IF;
        IF ((current_row.baseimage_xnat_abstractresource_id IS NOT NULL)) THEN
          PERFORM  a_xnat_abstractResource(current_row.baseimage_xnat_abstractresource_id, $2,$3,false);
        END IF;
        DECLARE 
        parent_row RECORD; 
        BEGIN 
        FOR parent_row IN SELECT * FROM xnat_regionResource_label WHERE subregionlabels_label_xnat_regi_xnat_regionresource_id=current_row.xnat_regionresource_id
        LOOP
          PERFORM  a_xnat_regionResource_label( parent_row.xnat_regionresource_label_id, $2,$3,false);
        END LOOP;
        END;
      END LOOP;
	
	 RETURN '';
    end;
$_$;


ALTER FUNCTION public.a_xnat_regionresource(integer, integer, character varying, boolean) OWNER TO xnat;

--
-- Name: a_xnat_regionresource_label(integer, integer, character varying, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.a_xnat_regionresource_label(integer, integer, character varying, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     row_ct int4;
    begin
      row_ct := 0;
       --UPDATE LOCAL ROW
      FOR current_row IN SELECT xnat_regionResource_label.*, meta.meta_data_id, meta.status AS meta_status FROM xnat_regionResource_label LEFT JOIN xnat_regionResource_label_meta_data meta ON xnat_regionResource_label.regionResource_label_info=meta.meta_data_id WHERE  xnat_regionresource_label_id=$1
      LOOP
           row_ct := row_ct+1;
           IF (current_row.meta_status!=$3) THEN
         UPDATE xnat_regionResource_label_meta_data SET status=$3,activation_date=NOW(),activation_user_xdat_user_id=$2 WHERE meta_data_id=current_row.meta_data_id;
           END IF;
          
      END LOOP;
	
	 RETURN '';
    end;
$_$;


ALTER FUNCTION public.a_xnat_regionresource_label(integer, integer, character varying, boolean) OWNER TO xnat;

--
-- Name: a_xnat_resource(integer, integer, character varying, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.a_xnat_resource(integer, integer, character varying, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
    begin
      FOR current_row IN SELECT * FROM (SELECT table0.xnat_abstractresource_id AS xnat_resource0, table2.element_name AS xdat_meta_element33, table4.insert_date AS xnat_resource_meta_data109 FROM xnat_resource xnat_resource   LEFT JOIN xnat_abstractResource table0 ON xnat_resource.xnat_abstractresource_id=table0.xnat_abstractresource_id   LEFT JOIN xdat_meta_element table2 ON table0.extension=table2.xdat_meta_element_id   LEFT JOIN xnat_resource_meta_data table4 ON xnat_resource.resource_info=table4.meta_data_id) SEARCH WHERE 
 ( (xnat_resource0=$1))
      LOOP
         IF (current_row.xdat_meta_element33 IS NULL) THEN 
            PERFORM  ae_xnat_resource( $1, $2,$3,$4);
         ELSE
            --CALL EXTENDER 
            declare
               matches int4:=0;
            begin
            IF (current_row.xdat_meta_element33='xnat:imageResource') THEN
            PERFORM  a_xnat_imageResource( $1, $2,$3,$4);
                matches:=1;
            END IF;
            IF (current_row.xdat_meta_element33='xnat:resourceCatalog') THEN
            PERFORM  a_xnat_resourceCatalog( $1, $2,$3,$4);
                matches:=1;
            END IF;
                IF (matches=0) THEN
            PERFORM  ae_xnat_resource( $1, $2,$3,$4);
                END IF;
            end;
         end IF;
      END LOOP;
	
	RETURN '';
    end;
$_$;


ALTER FUNCTION public.a_xnat_resource(integer, integer, character varying, boolean) OWNER TO xnat;

--
-- Name: a_xnat_resourcecatalog(integer, integer, character varying, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.a_xnat_resourcecatalog(integer, integer, character varying, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     row_ct int4;
    begin
      row_ct := 0;
       --UPDATE LOCAL ROW
      FOR current_row IN SELECT xnat_resourceCatalog.*, meta.meta_data_id, meta.status AS meta_status FROM xnat_resourceCatalog LEFT JOIN xnat_resourceCatalog_meta_data meta ON xnat_resourceCatalog.resourceCatalog_info=meta.meta_data_id WHERE  xnat_abstractresource_id=$1
      LOOP
           row_ct := row_ct+1;
           IF (current_row.meta_status!=$3) THEN
         UPDATE xnat_resourceCatalog_meta_data SET status=$3,activation_date=NOW(),activation_user_xdat_user_id=$2 WHERE meta_data_id=current_row.meta_data_id;
           END IF;
          
        IF ((current_row.xnat_abstractresource_id IS NOT NULL)) THEN
          PERFORM  ae_xnat_resource(current_row.xnat_abstractresource_id, $2,$3,false);
        END IF;
      END LOOP;
      IF (row_ct=0) THEN 
          PERFORM  ae_xnat_resource( $1, $2,$3,$4);
          
      END IF;
	
	 RETURN '';
    end;
$_$;


ALTER FUNCTION public.a_xnat_resourcecatalog(integer, integer, character varying, boolean) OWNER TO xnat;

--
-- Name: a_xnat_resourceseries(integer, integer, character varying, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.a_xnat_resourceseries(integer, integer, character varying, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
    begin
      FOR current_row IN SELECT * FROM (SELECT table0.xnat_abstractresource_id AS xnat_resourceSeries0, table2.element_name AS xdat_meta_element35, table4.insert_date AS xnat_resourceSeries_meta_data54 FROM xnat_resourceSeries xnat_resourceSeries   LEFT JOIN xnat_abstractResource table0 ON xnat_resourceSeries.xnat_abstractresource_id=table0.xnat_abstractresource_id   LEFT JOIN xdat_meta_element table2 ON table0.extension=table2.xdat_meta_element_id   LEFT JOIN xnat_resourceSeries_meta_data table4 ON xnat_resourceSeries.resourceSeries_info=table4.meta_data_id) SEARCH WHERE 
 ( (xnat_resourceSeries0=$1))
      LOOP
         IF (current_row.xdat_meta_element35 IS NULL) THEN 
            PERFORM  ae_xnat_resourceSeries( $1, $2,$3,$4);
         ELSE
            --CALL EXTENDER 
            declare
               matches int4:=0;
            begin
            IF (current_row.xdat_meta_element35='xnat:imageResourceSeries') THEN
            PERFORM  a_xnat_imageResourceSeries( $1, $2,$3,$4);
                matches:=1;
            END IF;
                IF (matches=0) THEN
            PERFORM  ae_xnat_resourceSeries( $1, $2,$3,$4);
                END IF;
            end;
         end IF;
      END LOOP;
	
	RETURN '';
    end;
$_$;


ALTER FUNCTION public.a_xnat_resourceseries(integer, integer, character varying, boolean) OWNER TO xnat;

--
-- Name: a_xnat_rfscandata(integer, integer, character varying, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.a_xnat_rfscandata(integer, integer, character varying, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     row_ct int4;
    begin
      row_ct := 0;
       --UPDATE LOCAL ROW
      FOR current_row IN SELECT xnat_rfScanData.*, meta.meta_data_id, meta.status AS meta_status FROM xnat_rfScanData LEFT JOIN xnat_rfScanData_meta_data meta ON xnat_rfScanData.rfScanData_info=meta.meta_data_id WHERE  xnat_imagescandata_id=$1
      LOOP
           row_ct := row_ct+1;
           IF (current_row.meta_status!=$3) THEN
         UPDATE xnat_rfScanData_meta_data SET status=$3,activation_date=NOW(),activation_user_xdat_user_id=$2 WHERE meta_data_id=current_row.meta_data_id;
           END IF;
          
        IF ((current_row.xnat_imagescandata_id IS NOT NULL)) THEN
          PERFORM  ae_xnat_imageScanData(current_row.xnat_imagescandata_id, $2,$3,false);
        END IF;
      END LOOP;
      IF (row_ct=0) THEN 
          PERFORM  ae_xnat_imageScanData( $1, $2,$3,$4);
          
      END IF;
	
	 RETURN '';
    end;
$_$;


ALTER FUNCTION public.a_xnat_rfscandata(integer, integer, character varying, boolean) OWNER TO xnat;

--
-- Name: a_xnat_rfsessiondata(character varying, integer, character varying, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.a_xnat_rfsessiondata(character varying, integer, character varying, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     row_ct int4;
    begin
      row_ct := 0;
       --UPDATE LOCAL ROW
      FOR current_row IN SELECT xnat_rfSessionData.*, meta.meta_data_id, meta.status AS meta_status FROM xnat_rfSessionData LEFT JOIN xnat_rfSessionData_meta_data meta ON xnat_rfSessionData.rfSessionData_info=meta.meta_data_id WHERE  id=$1
      LOOP
           row_ct := row_ct+1;
           IF (current_row.meta_status!=$3) THEN
         UPDATE xnat_rfSessionData_meta_data SET status=$3,activation_date=NOW(),activation_user_xdat_user_id=$2 WHERE meta_data_id=current_row.meta_data_id;
           END IF;
          
        IF ((current_row.id IS NOT NULL)) THEN
          PERFORM  ae_xnat_imageSessionData(current_row.id, $2,$3,false);
        END IF;
      END LOOP;
      IF (row_ct=0) THEN 
          PERFORM  ae_xnat_imageSessionData( $1, $2,$3,$4);
          
      END IF;
	
	 RETURN '';
    end;
$_$;


ALTER FUNCTION public.a_xnat_rfsessiondata(character varying, integer, character varying, boolean) OWNER TO xnat;

--
-- Name: a_xnat_rtimagescandata(integer, integer, character varying, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.a_xnat_rtimagescandata(integer, integer, character varying, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     row_ct int4;
    begin
      row_ct := 0;
       --UPDATE LOCAL ROW
      FOR current_row IN SELECT xnat_rtImageScanData.*, meta.meta_data_id, meta.status AS meta_status FROM xnat_rtImageScanData LEFT JOIN xnat_rtImageScanData_meta_data meta ON xnat_rtImageScanData.rtImageScanData_info=meta.meta_data_id WHERE  xnat_imagescandata_id=$1
      LOOP
           row_ct := row_ct+1;
           IF (current_row.meta_status!=$3) THEN
         UPDATE xnat_rtImageScanData_meta_data SET status=$3,activation_date=NOW(),activation_user_xdat_user_id=$2 WHERE meta_data_id=current_row.meta_data_id;
           END IF;
          
        IF ((current_row.xnat_imagescandata_id IS NOT NULL)) THEN
          PERFORM  ae_xnat_imageScanData(current_row.xnat_imagescandata_id, $2,$3,false);
        END IF;
      END LOOP;
      IF (row_ct=0) THEN 
          PERFORM  ae_xnat_imageScanData( $1, $2,$3,$4);
          
      END IF;
	
	 RETURN '';
    end;
$_$;


ALTER FUNCTION public.a_xnat_rtimagescandata(integer, integer, character varying, boolean) OWNER TO xnat;

--
-- Name: a_xnat_rtsessiondata(character varying, integer, character varying, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.a_xnat_rtsessiondata(character varying, integer, character varying, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     row_ct int4;
    begin
      row_ct := 0;
       --UPDATE LOCAL ROW
      FOR current_row IN SELECT xnat_rtSessionData.*, meta.meta_data_id, meta.status AS meta_status FROM xnat_rtSessionData LEFT JOIN xnat_rtSessionData_meta_data meta ON xnat_rtSessionData.rtSessionData_info=meta.meta_data_id WHERE  id=$1
      LOOP
           row_ct := row_ct+1;
           IF (current_row.meta_status!=$3) THEN
         UPDATE xnat_rtSessionData_meta_data SET status=$3,activation_date=NOW(),activation_user_xdat_user_id=$2 WHERE meta_data_id=current_row.meta_data_id;
           END IF;
          
        IF ((current_row.id IS NOT NULL)) THEN
          PERFORM  ae_xnat_imageSessionData(current_row.id, $2,$3,false);
        END IF;
      END LOOP;
      IF (row_ct=0) THEN 
          PERFORM  ae_xnat_imageSessionData( $1, $2,$3,$4);
          
      END IF;
	
	 RETURN '';
    end;
$_$;


ALTER FUNCTION public.a_xnat_rtsessiondata(character varying, integer, character varying, boolean) OWNER TO xnat;

--
-- Name: a_xnat_scscandata(integer, integer, character varying, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.a_xnat_scscandata(integer, integer, character varying, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     row_ct int4;
    begin
      row_ct := 0;
       --UPDATE LOCAL ROW
      FOR current_row IN SELECT xnat_scScanData.*, meta.meta_data_id, meta.status AS meta_status FROM xnat_scScanData LEFT JOIN xnat_scScanData_meta_data meta ON xnat_scScanData.scScanData_info=meta.meta_data_id WHERE  xnat_imagescandata_id=$1
      LOOP
           row_ct := row_ct+1;
           IF (current_row.meta_status!=$3) THEN
         UPDATE xnat_scScanData_meta_data SET status=$3,activation_date=NOW(),activation_user_xdat_user_id=$2 WHERE meta_data_id=current_row.meta_data_id;
           END IF;
          
        IF ((current_row.xnat_imagescandata_id IS NOT NULL)) THEN
          PERFORM  ae_xnat_imageScanData(current_row.xnat_imagescandata_id, $2,$3,false);
        END IF;
      END LOOP;
      IF (row_ct=0) THEN 
          PERFORM  ae_xnat_imageScanData( $1, $2,$3,$4);
          
      END IF;
	
	 RETURN '';
    end;
$_$;


ALTER FUNCTION public.a_xnat_scscandata(integer, integer, character varying, boolean) OWNER TO xnat;

--
-- Name: a_xnat_segscandata(integer, integer, character varying, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.a_xnat_segscandata(integer, integer, character varying, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     row_ct int4;
    begin
      row_ct := 0;
       --UPDATE LOCAL ROW
      FOR current_row IN SELECT xnat_segScanData.*, meta.meta_data_id, meta.status AS meta_status FROM xnat_segScanData LEFT JOIN xnat_segScanData_meta_data meta ON xnat_segScanData.segScanData_info=meta.meta_data_id WHERE  xnat_imagescandata_id=$1
      LOOP
           row_ct := row_ct+1;
           IF (current_row.meta_status!=$3) THEN
         UPDATE xnat_segScanData_meta_data SET status=$3,activation_date=NOW(),activation_user_xdat_user_id=$2 WHERE meta_data_id=current_row.meta_data_id;
           END IF;
          
        IF ((current_row.xnat_imagescandata_id IS NOT NULL)) THEN
          PERFORM  ae_xnat_imageScanData(current_row.xnat_imagescandata_id, $2,$3,false);
        END IF;
      END LOOP;
      IF (row_ct=0) THEN 
          PERFORM  ae_xnat_imageScanData( $1, $2,$3,$4);
          
      END IF;
	
	 RETURN '';
    end;
$_$;


ALTER FUNCTION public.a_xnat_segscandata(integer, integer, character varying, boolean) OWNER TO xnat;

--
-- Name: a_xnat_smscandata(integer, integer, character varying, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.a_xnat_smscandata(integer, integer, character varying, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     row_ct int4;
    begin
      row_ct := 0;
       --UPDATE LOCAL ROW
      FOR current_row IN SELECT xnat_smScanData.*, meta.meta_data_id, meta.status AS meta_status FROM xnat_smScanData LEFT JOIN xnat_smScanData_meta_data meta ON xnat_smScanData.smScanData_info=meta.meta_data_id WHERE  xnat_imagescandata_id=$1
      LOOP
           row_ct := row_ct+1;
           IF (current_row.meta_status!=$3) THEN
         UPDATE xnat_smScanData_meta_data SET status=$3,activation_date=NOW(),activation_user_xdat_user_id=$2 WHERE meta_data_id=current_row.meta_data_id;
           END IF;
          
        IF ((current_row.xnat_imagescandata_id IS NOT NULL)) THEN
          PERFORM  ae_xnat_imageScanData(current_row.xnat_imagescandata_id, $2,$3,false);
        END IF;
      END LOOP;
      IF (row_ct=0) THEN 
          PERFORM  ae_xnat_imageScanData( $1, $2,$3,$4);
          
      END IF;
	
	 RETURN '';
    end;
$_$;


ALTER FUNCTION public.a_xnat_smscandata(integer, integer, character varying, boolean) OWNER TO xnat;

--
-- Name: a_xnat_smsessiondata(character varying, integer, character varying, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.a_xnat_smsessiondata(character varying, integer, character varying, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     row_ct int4;
    begin
      row_ct := 0;
       --UPDATE LOCAL ROW
      FOR current_row IN SELECT xnat_smSessionData.*, meta.meta_data_id, meta.status AS meta_status FROM xnat_smSessionData LEFT JOIN xnat_smSessionData_meta_data meta ON xnat_smSessionData.smSessionData_info=meta.meta_data_id WHERE  id=$1
      LOOP
           row_ct := row_ct+1;
           IF (current_row.meta_status!=$3) THEN
         UPDATE xnat_smSessionData_meta_data SET status=$3,activation_date=NOW(),activation_user_xdat_user_id=$2 WHERE meta_data_id=current_row.meta_data_id;
           END IF;
          
        IF ((current_row.id IS NOT NULL)) THEN
          PERFORM  ae_xnat_imageSessionData(current_row.id, $2,$3,false);
        END IF;
      END LOOP;
      IF (row_ct=0) THEN 
          PERFORM  ae_xnat_imageSessionData( $1, $2,$3,$4);
          
      END IF;
	
	 RETURN '';
    end;
$_$;


ALTER FUNCTION public.a_xnat_smsessiondata(character varying, integer, character varying, boolean) OWNER TO xnat;

--
-- Name: a_xnat_srscandata(integer, integer, character varying, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.a_xnat_srscandata(integer, integer, character varying, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     row_ct int4;
    begin
      row_ct := 0;
       --UPDATE LOCAL ROW
      FOR current_row IN SELECT xnat_srScanData.*, meta.meta_data_id, meta.status AS meta_status FROM xnat_srScanData LEFT JOIN xnat_srScanData_meta_data meta ON xnat_srScanData.srScanData_info=meta.meta_data_id WHERE  xnat_imagescandata_id=$1
      LOOP
           row_ct := row_ct+1;
           IF (current_row.meta_status!=$3) THEN
         UPDATE xnat_srScanData_meta_data SET status=$3,activation_date=NOW(),activation_user_xdat_user_id=$2 WHERE meta_data_id=current_row.meta_data_id;
           END IF;
          
        IF ((current_row.xnat_imagescandata_id IS NOT NULL)) THEN
          PERFORM  ae_xnat_imageScanData(current_row.xnat_imagescandata_id, $2,$3,false);
        END IF;
      END LOOP;
      IF (row_ct=0) THEN 
          PERFORM  ae_xnat_imageScanData( $1, $2,$3,$4);
          
      END IF;
	
	 RETURN '';
    end;
$_$;


ALTER FUNCTION public.a_xnat_srscandata(integer, integer, character varying, boolean) OWNER TO xnat;

--
-- Name: a_xnat_srsessiondata(character varying, integer, character varying, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.a_xnat_srsessiondata(character varying, integer, character varying, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     row_ct int4;
    begin
      row_ct := 0;
       --UPDATE LOCAL ROW
      FOR current_row IN SELECT xnat_srSessionData.*, meta.meta_data_id, meta.status AS meta_status FROM xnat_srSessionData LEFT JOIN xnat_srSessionData_meta_data meta ON xnat_srSessionData.srSessionData_info=meta.meta_data_id WHERE  id=$1
      LOOP
           row_ct := row_ct+1;
           IF (current_row.meta_status!=$3) THEN
         UPDATE xnat_srSessionData_meta_data SET status=$3,activation_date=NOW(),activation_user_xdat_user_id=$2 WHERE meta_data_id=current_row.meta_data_id;
           END IF;
          
        IF ((current_row.id IS NOT NULL)) THEN
          PERFORM  ae_xnat_imageSessionData(current_row.id, $2,$3,false);
        END IF;
      END LOOP;
      IF (row_ct=0) THEN 
          PERFORM  ae_xnat_imageSessionData( $1, $2,$3,$4);
          
      END IF;
	
	 RETURN '';
    end;
$_$;


ALTER FUNCTION public.a_xnat_srsessiondata(character varying, integer, character varying, boolean) OWNER TO xnat;

--
-- Name: a_xnat_statisticsdata(integer, integer, character varying, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.a_xnat_statisticsdata(integer, integer, character varying, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     row_ct int4;
    begin
      row_ct := 0;
       --UPDATE LOCAL ROW
      FOR current_row IN SELECT xnat_statisticsData.*, meta.meta_data_id, meta.status AS meta_status FROM xnat_statisticsData LEFT JOIN xnat_statisticsData_meta_data meta ON xnat_statisticsData.statisticsData_info=meta.meta_data_id WHERE  xnat_abstractstatistics_id=$1
      LOOP
           row_ct := row_ct+1;
           IF (current_row.meta_status!=$3) THEN
         UPDATE xnat_statisticsData_meta_data SET status=$3,activation_date=NOW(),activation_user_xdat_user_id=$2 WHERE meta_data_id=current_row.meta_data_id;
           END IF;
          
        IF ((current_row.xnat_abstractstatistics_id IS NOT NULL)) THEN
          PERFORM  ae_xnat_abstractStatistics(current_row.xnat_abstractstatistics_id, $2,$3,false);
        END IF;
        DECLARE 
        parent_row RECORD; 
        BEGIN 
        FOR parent_row IN SELECT * FROM xnat_statisticsData_additionalStatistics WHERE xnat_statisticsData_xnat_abstractstatistics_id=current_row.xnat_abstractstatistics_id
        LOOP
          PERFORM  a_xnat_statisticsData_additionalStatistics( parent_row.xnat_statisticsdata_additionalstatistics_id, $2,$3,false);
        END LOOP;
        END;
        DECLARE 
        parent_row RECORD; 
        BEGIN 
        FOR parent_row IN SELECT * FROM xnat_statisticsData_addField WHERE xnat_statisticsData_xnat_abstractstatistics_id=current_row.xnat_abstractstatistics_id
        LOOP
          PERFORM  a_xnat_statisticsData_addField( parent_row.xnat_statisticsdata_addfield_id, $2,$3,false);
        END LOOP;
        END;
      END LOOP;
      IF (row_ct=0) THEN 
          PERFORM  ae_xnat_abstractStatistics( $1, $2,$3,$4);
          
      END IF;
	
	 RETURN '';
    end;
$_$;


ALTER FUNCTION public.a_xnat_statisticsdata(integer, integer, character varying, boolean) OWNER TO xnat;

--
-- Name: a_xnat_statisticsdata_addfield(integer, integer, character varying, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.a_xnat_statisticsdata_addfield(integer, integer, character varying, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     row_ct int4;
    begin
      row_ct := 0;
       --UPDATE LOCAL ROW
      FOR current_row IN SELECT xnat_statisticsData_addField.*, meta.meta_data_id, meta.status AS meta_status FROM xnat_statisticsData_addField LEFT JOIN xnat_statisticsData_addField_meta_data meta ON xnat_statisticsData_addField.statisticsData_addField_info=meta.meta_data_id WHERE  xnat_statisticsdata_addfield_id=$1
      LOOP
           row_ct := row_ct+1;
           IF (current_row.meta_status!=$3) THEN
         UPDATE xnat_statisticsData_addField_meta_data SET status=$3,activation_date=NOW(),activation_user_xdat_user_id=$2 WHERE meta_data_id=current_row.meta_data_id;
           END IF;
          
      END LOOP;
	
	 RETURN '';
    end;
$_$;


ALTER FUNCTION public.a_xnat_statisticsdata_addfield(integer, integer, character varying, boolean) OWNER TO xnat;

--
-- Name: a_xnat_statisticsdata_additionalstatistics(integer, integer, character varying, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.a_xnat_statisticsdata_additionalstatistics(integer, integer, character varying, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     row_ct int4;
    begin
      row_ct := 0;
       --UPDATE LOCAL ROW
      FOR current_row IN SELECT xnat_statisticsData_additionalStatistics.*, meta.meta_data_id, meta.status AS meta_status FROM xnat_statisticsData_additionalStatistics LEFT JOIN xnat_statisticsData_additionalStatistics_meta_data meta ON xnat_statisticsData_additionalStatistics.statisticsData_additionalStatistics_info=meta.meta_data_id WHERE  xnat_statisticsdata_additionalstatistics_id=$1
      LOOP
           row_ct := row_ct+1;
           IF (current_row.meta_status!=$3) THEN
         UPDATE xnat_statisticsData_additionalStatistics_meta_data SET status=$3,activation_date=NOW(),activation_user_xdat_user_id=$2 WHERE meta_data_id=current_row.meta_data_id;
           END IF;
          
      END LOOP;
	
	 RETURN '';
    end;
$_$;


ALTER FUNCTION public.a_xnat_statisticsdata_additionalstatistics(integer, integer, character varying, boolean) OWNER TO xnat;

--
-- Name: a_xnat_studyprotocol(integer, integer, character varying, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.a_xnat_studyprotocol(integer, integer, character varying, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     row_ct int4;
    begin
      row_ct := 0;
       --UPDATE LOCAL ROW
      FOR current_row IN SELECT xnat_studyProtocol.*, meta.meta_data_id, meta.status AS meta_status FROM xnat_studyProtocol LEFT JOIN xnat_studyProtocol_meta_data meta ON xnat_studyProtocol.studyProtocol_info=meta.meta_data_id WHERE  xnat_abstractprotocol_id=$1
      LOOP
           row_ct := row_ct+1;
           IF (current_row.meta_status!=$3) THEN
         UPDATE xnat_studyProtocol_meta_data SET status=$3,activation_date=NOW(),activation_user_xdat_user_id=$2 WHERE meta_data_id=current_row.meta_data_id;
           END IF;
          
        IF ((current_row.xnat_abstractprotocol_id IS NOT NULL)) THEN
          PERFORM  ae_xnat_abstractProtocol(current_row.xnat_abstractprotocol_id, $2,$3,false);
        END IF;
        DECLARE 
        parent_row RECORD; 
        BEGIN 
        FOR parent_row IN SELECT * FROM xnat_studyProtocol_condition WHERE acqconditions_condition_xnat_st_xnat_abstractprotocol_id=current_row.xnat_abstractprotocol_id
        LOOP
          PERFORM  a_xnat_studyProtocol_condition( parent_row.xnat_studyprotocol_condition_id, $2,$3,false);
        END LOOP;
        END;
        DECLARE 
        parent_row RECORD; 
        BEGIN 
        FOR parent_row IN SELECT * FROM xnat_studyProtocol_group WHERE subjectgroups_group_xnat_studyP_xnat_abstractprotocol_id=current_row.xnat_abstractprotocol_id
        LOOP
          PERFORM  a_xnat_studyProtocol_group( parent_row.xnat_studyprotocol_group_id, $2,$3,false);
        END LOOP;
        END;
        DECLARE 
        parent_row RECORD; 
        BEGIN 
        FOR parent_row IN SELECT * FROM xnat_studyProtocol_variable WHERE subjectvariables_variable_xnat__xnat_abstractprotocol_id=current_row.xnat_abstractprotocol_id
        LOOP
          PERFORM  a_xnat_studyProtocol_variable( parent_row.xnat_studyprotocol_variable_id, $2,$3,false);
        END LOOP;
        END;
        DECLARE 
        parent_row RECORD; 
        BEGIN 
        FOR parent_row IN SELECT * FROM xnat_studyProtocol_session WHERE imagesessiontypes_session_xnat__xnat_abstractprotocol_id=current_row.xnat_abstractprotocol_id
        LOOP
          PERFORM  a_xnat_studyProtocol_session( parent_row.xnat_studyprotocol_session_id, $2,$3,false);
        END LOOP;
        END;
      END LOOP;
      IF (row_ct=0) THEN 
          PERFORM  ae_xnat_abstractProtocol( $1, $2,$3,$4);
          
      END IF;
	
	 RETURN '';
    end;
$_$;


ALTER FUNCTION public.a_xnat_studyprotocol(integer, integer, character varying, boolean) OWNER TO xnat;

--
-- Name: a_xnat_studyprotocol_condition(integer, integer, character varying, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.a_xnat_studyprotocol_condition(integer, integer, character varying, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     row_ct int4;
    begin
      row_ct := 0;
       --UPDATE LOCAL ROW
      FOR current_row IN SELECT xnat_studyProtocol_condition.*, meta.meta_data_id, meta.status AS meta_status FROM xnat_studyProtocol_condition LEFT JOIN xnat_studyProtocol_condition_meta_data meta ON xnat_studyProtocol_condition.studyProtocol_condition_info=meta.meta_data_id WHERE  xnat_studyprotocol_condition_id=$1
      LOOP
           row_ct := row_ct+1;
           IF (current_row.meta_status!=$3) THEN
         UPDATE xnat_studyProtocol_condition_meta_data SET status=$3,activation_date=NOW(),activation_user_xdat_user_id=$2 WHERE meta_data_id=current_row.meta_data_id;
           END IF;
          
      END LOOP;
	
	 RETURN '';
    end;
$_$;


ALTER FUNCTION public.a_xnat_studyprotocol_condition(integer, integer, character varying, boolean) OWNER TO xnat;

--
-- Name: a_xnat_studyprotocol_group(integer, integer, character varying, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.a_xnat_studyprotocol_group(integer, integer, character varying, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     row_ct int4;
    begin
      row_ct := 0;
       --UPDATE LOCAL ROW
      FOR current_row IN SELECT xnat_studyProtocol_group.*, meta.meta_data_id, meta.status AS meta_status FROM xnat_studyProtocol_group LEFT JOIN xnat_studyProtocol_group_meta_data meta ON xnat_studyProtocol_group.studyProtocol_group_info=meta.meta_data_id WHERE  xnat_studyprotocol_group_id=$1
      LOOP
           row_ct := row_ct+1;
           IF (current_row.meta_status!=$3) THEN
         UPDATE xnat_studyProtocol_group_meta_data SET status=$3,activation_date=NOW(),activation_user_xdat_user_id=$2 WHERE meta_data_id=current_row.meta_data_id;
           END IF;
          
      END LOOP;
	
	 RETURN '';
    end;
$_$;


ALTER FUNCTION public.a_xnat_studyprotocol_group(integer, integer, character varying, boolean) OWNER TO xnat;

--
-- Name: a_xnat_studyprotocol_session(integer, integer, character varying, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.a_xnat_studyprotocol_session(integer, integer, character varying, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     row_ct int4;
    begin
      row_ct := 0;
       --UPDATE LOCAL ROW
      FOR current_row IN SELECT xnat_studyProtocol_session.*, meta.meta_data_id, meta.status AS meta_status FROM xnat_studyProtocol_session LEFT JOIN xnat_studyProtocol_session_meta_data meta ON xnat_studyProtocol_session.studyProtocol_session_info=meta.meta_data_id WHERE  xnat_studyprotocol_session_id=$1
      LOOP
           row_ct := row_ct+1;
           IF (current_row.meta_status!=$3) THEN
         UPDATE xnat_studyProtocol_session_meta_data SET status=$3,activation_date=NOW(),activation_user_xdat_user_id=$2 WHERE meta_data_id=current_row.meta_data_id;
           END IF;
          
      END LOOP;
	
	 RETURN '';
    end;
$_$;


ALTER FUNCTION public.a_xnat_studyprotocol_session(integer, integer, character varying, boolean) OWNER TO xnat;

--
-- Name: a_xnat_studyprotocol_variable(integer, integer, character varying, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.a_xnat_studyprotocol_variable(integer, integer, character varying, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     row_ct int4;
    begin
      row_ct := 0;
       --UPDATE LOCAL ROW
      FOR current_row IN SELECT xnat_studyProtocol_variable.*, meta.meta_data_id, meta.status AS meta_status FROM xnat_studyProtocol_variable LEFT JOIN xnat_studyProtocol_variable_meta_data meta ON xnat_studyProtocol_variable.studyProtocol_variable_info=meta.meta_data_id WHERE  xnat_studyprotocol_variable_id=$1
      LOOP
           row_ct := row_ct+1;
           IF (current_row.meta_status!=$3) THEN
         UPDATE xnat_studyProtocol_variable_meta_data SET status=$3,activation_date=NOW(),activation_user_xdat_user_id=$2 WHERE meta_data_id=current_row.meta_data_id;
           END IF;
          
      END LOOP;
	
	 RETURN '';
    end;
$_$;


ALTER FUNCTION public.a_xnat_studyprotocol_variable(integer, integer, character varying, boolean) OWNER TO xnat;

--
-- Name: a_xnat_subjectassessordata(character varying, integer, character varying, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.a_xnat_subjectassessordata(character varying, integer, character varying, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
    begin
      FOR current_row IN SELECT * FROM (SELECT table0.id AS xnat_subjectAssessorData0, table2.element_name AS xdat_meta_element140, table0.date AS xnat_experimentData4 FROM xnat_subjectAssessorData xnat_subjectAssessorData   LEFT JOIN xnat_experimentData table0 ON xnat_subjectAssessorData.id=table0.id   LEFT JOIN xdat_meta_element table2 ON table0.extension=table2.xdat_meta_element_id) SEARCH WHERE 
 ( (xnat_subjectAssessorData0=$1))
      LOOP
         IF (current_row.xdat_meta_element140 IS NULL) THEN 
            PERFORM  ae_xnat_subjectAssessorData( $1, $2,$3,$4);
         ELSE
            --CALL EXTENDER 
            declare
               matches int4:=0;
            begin
            IF (current_row.xdat_meta_element140='xnat:subjectVariablesData') THEN
            PERFORM  a_xnat_subjectVariablesData( $1, $2,$3,$4);
                matches:=1;
            END IF;
            IF (current_row.xdat_meta_element140='xnat:imageSessionData') THEN
            PERFORM  ae_xnat_imageSessionData( $1, $2,$3,$4);
                matches:=1;
            END IF;
            IF (current_row.xdat_meta_element140='xnat:mrSessionData') THEN
            PERFORM  a_xnat_mrSessionData( $1, $2,$3,$4);
                matches:=1;
            END IF;
            IF (current_row.xdat_meta_element140='xnat:petSessionData') THEN
            PERFORM  a_xnat_petSessionData( $1, $2,$3,$4);
                matches:=1;
            END IF;
            IF (current_row.xdat_meta_element140='xnat:petmrSessionData') THEN
            PERFORM  a_xnat_petmrSessionData( $1, $2,$3,$4);
                matches:=1;
            END IF;
            IF (current_row.xdat_meta_element140='xnat:ctSessionData') THEN
            PERFORM  a_xnat_ctSessionData( $1, $2,$3,$4);
                matches:=1;
            END IF;
            IF (current_row.xdat_meta_element140='xnat:crSessionData') THEN
            PERFORM  a_xnat_crSessionData( $1, $2,$3,$4);
                matches:=1;
            END IF;
            IF (current_row.xdat_meta_element140='xnat:dxSessionData') THEN
            PERFORM  a_xnat_dxSessionData( $1, $2,$3,$4);
                matches:=1;
            END IF;
            IF (current_row.xdat_meta_element140='xnat:mgSessionData') THEN
            PERFORM  a_xnat_mgSessionData( $1, $2,$3,$4);
                matches:=1;
            END IF;
            IF (current_row.xdat_meta_element140='xnat:ioSessionData') THEN
            PERFORM  a_xnat_ioSessionData( $1, $2,$3,$4);
                matches:=1;
            END IF;
            IF (current_row.xdat_meta_element140='xnat:usSessionData') THEN
            PERFORM  a_xnat_usSessionData( $1, $2,$3,$4);
                matches:=1;
            END IF;
            IF (current_row.xdat_meta_element140='xnat:ecgSessionData') THEN
            PERFORM  a_xnat_ecgSessionData( $1, $2,$3,$4);
                matches:=1;
            END IF;
            IF (current_row.xdat_meta_element140='xnat:hdSessionData') THEN
            PERFORM  a_xnat_hdSessionData( $1, $2,$3,$4);
                matches:=1;
            END IF;
            IF (current_row.xdat_meta_element140='xnat:epsSessionData') THEN
            PERFORM  a_xnat_epsSessionData( $1, $2,$3,$4);
                matches:=1;
            END IF;
            IF (current_row.xdat_meta_element140='xnat:xaSessionData') THEN
            PERFORM  a_xnat_xaSessionData( $1, $2,$3,$4);
                matches:=1;
            END IF;
            IF (current_row.xdat_meta_element140='xnat:rfSessionData') THEN
            PERFORM  a_xnat_rfSessionData( $1, $2,$3,$4);
                matches:=1;
            END IF;
            IF (current_row.xdat_meta_element140='xnat:xa3DSessionData') THEN
            PERFORM  a_xnat_xa3DSessionData( $1, $2,$3,$4);
                matches:=1;
            END IF;
            IF (current_row.xdat_meta_element140='xnat:dx3DCraniofacialSessionData') THEN
            PERFORM  a_xnat_dx3DCraniofacialSessionData( $1, $2,$3,$4);
                matches:=1;
            END IF;
            IF (current_row.xdat_meta_element140='xnat:nmSessionData') THEN
            PERFORM  a_xnat_nmSessionData( $1, $2,$3,$4);
                matches:=1;
            END IF;
            IF (current_row.xdat_meta_element140='xnat:srSessionData') THEN
            PERFORM  a_xnat_srSessionData( $1, $2,$3,$4);
                matches:=1;
            END IF;
            IF (current_row.xdat_meta_element140='xnat:esSessionData') THEN
            PERFORM  a_xnat_esSessionData( $1, $2,$3,$4);
                matches:=1;
            END IF;
            IF (current_row.xdat_meta_element140='xnat:esvSessionData') THEN
            PERFORM  a_xnat_esvSessionData( $1, $2,$3,$4);
                matches:=1;
            END IF;
            IF (current_row.xdat_meta_element140='xnat:gmSessionData') THEN
            PERFORM  a_xnat_gmSessionData( $1, $2,$3,$4);
                matches:=1;
            END IF;
            IF (current_row.xdat_meta_element140='xnat:gmvSessionData') THEN
            PERFORM  a_xnat_gmvSessionData( $1, $2,$3,$4);
                matches:=1;
            END IF;
            IF (current_row.xdat_meta_element140='xnat:smSessionData') THEN
            PERFORM  a_xnat_smSessionData( $1, $2,$3,$4);
                matches:=1;
            END IF;
            IF (current_row.xdat_meta_element140='xnat:xcSessionData') THEN
            PERFORM  a_xnat_xcSessionData( $1, $2,$3,$4);
                matches:=1;
            END IF;
            IF (current_row.xdat_meta_element140='xnat:xcvSessionData') THEN
            PERFORM  a_xnat_xcvSessionData( $1, $2,$3,$4);
                matches:=1;
            END IF;
            IF (current_row.xdat_meta_element140='xnat:opSessionData') THEN
            PERFORM  a_xnat_opSessionData( $1, $2,$3,$4);
                matches:=1;
            END IF;
            IF (current_row.xdat_meta_element140='xnat:optSessionData') THEN
            PERFORM  a_xnat_optSessionData( $1, $2,$3,$4);
                matches:=1;
            END IF;
            IF (current_row.xdat_meta_element140='xnat:rtSessionData') THEN
            PERFORM  a_xnat_rtSessionData( $1, $2,$3,$4);
                matches:=1;
            END IF;
            IF (current_row.xdat_meta_element140='xnat:otherDicomSessionData') THEN
            PERFORM  a_xnat_otherDicomSessionData( $1, $2,$3,$4);
                matches:=1;
            END IF;
            IF (current_row.xdat_meta_element140='xnat:megSessionData') THEN
            PERFORM  a_xnat_megSessionData( $1, $2,$3,$4);
                matches:=1;
            END IF;
            IF (current_row.xdat_meta_element140='xnat:eegSessionData') THEN
            PERFORM  a_xnat_eegSessionData( $1, $2,$3,$4);
                matches:=1;
            END IF;
            IF (current_row.xdat_meta_element140='xnat_a:sideEffectsPittsburghData') THEN
            PERFORM  a_xnat_a_sideEffectsPittsburghData( $1, $2,$3,$4);
                matches:=1;
            END IF;
            IF (current_row.xdat_meta_element140='xnat_a:ybocsData') THEN
            PERFORM  a_xnat_a_ybocsData( $1, $2,$3,$4);
                matches:=1;
            END IF;
            IF (current_row.xdat_meta_element140='xnat_a:ygtssData') THEN
            PERFORM  a_xnat_a_ygtssData( $1, $2,$3,$4);
                matches:=1;
            END IF;
            IF (current_row.xdat_meta_element140='xnat_a:updrs3Data') THEN
            PERFORM  a_xnat_a_updrs3Data( $1, $2,$3,$4);
                matches:=1;
            END IF;
            IF (current_row.xdat_meta_element140='xnat_a:scidResearchData') THEN
            PERFORM  a_xnat_a_scidResearchData( $1, $2,$3,$4);
                matches:=1;
            END IF;
                IF (matches=0) THEN
            PERFORM  ae_xnat_subjectAssessorData( $1, $2,$3,$4);
                END IF;
            end;
         end IF;
      END LOOP;
	
	RETURN '';
    end;
$_$;


ALTER FUNCTION public.a_xnat_subjectassessordata(character varying, integer, character varying, boolean) OWNER TO xnat;

--
-- Name: a_xnat_subjectdata(character varying, integer, character varying, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.a_xnat_subjectdata(character varying, integer, character varying, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     row_ct int4;
    begin
      row_ct := 0;
       --UPDATE LOCAL ROW
      FOR current_row IN SELECT xnat_subjectData.*, meta.meta_data_id, meta.status AS meta_status FROM xnat_subjectData LEFT JOIN xnat_subjectData_meta_data meta ON xnat_subjectData.subjectData_info=meta.meta_data_id WHERE  id=$1
      LOOP
           row_ct := row_ct+1;
           IF (current_row.meta_status!=$3) THEN
         UPDATE xnat_subjectData_meta_data SET status=$3,activation_date=NOW(),activation_user_xdat_user_id=$2 WHERE meta_data_id=current_row.meta_data_id;
           END IF;
          
        DECLARE 
        parent_row RECORD; 
        BEGIN 
        FOR parent_row IN SELECT * FROM xnat_projectParticipant WHERE subject_id=current_row.id
        LOOP
          PERFORM  a_xnat_projectParticipant( parent_row.xnat_projectparticipant_id, $2,$3,false);
        END LOOP;
        END;
        DECLARE 
        mapping_row RECORD; 
        BEGIN 
        FOR mapping_row IN SELECT * FROM xnat_subjectData_resource WHERE  xnat_subjectData_id=current_row.id
        LOOP
          PERFORM  a_xnat_abstractResource( mapping_row.xnat_abstractResource_xnat_abstractresource_id, $2,$3,false);
        END LOOP;
        END; 
        IF ((current_row.investigator_xnat_investigatordata_id IS NOT NULL)) THEN
          PERFORM  a_xnat_investigatorData(current_row.investigator_xnat_investigatordata_id, $2,$3,false);
        END IF;
        IF ((current_row.demographics_xnat_abstractdemographicdata_id IS NOT NULL)) THEN
          PERFORM  a_xnat_abstractDemographicData(current_row.demographics_xnat_abstractdemographicdata_id, $2,$3,false);
        END IF;
        IF ((current_row.metadata_xnat_abstractsubjectmetadata_id IS NOT NULL)) THEN
          PERFORM  a_xnat_abstractSubjectMetadata(current_row.metadata_xnat_abstractsubjectmetadata_id, $2,$3,false);
        END IF;
        DECLARE 
        parent_row RECORD; 
        BEGIN 
        FOR parent_row IN SELECT * FROM xnat_subjectData_addID WHERE xnat_subjectData_id=current_row.id
        LOOP
          PERFORM  a_xnat_subjectData_addID( parent_row.xnat_subjectdata_addid_id, $2,$3,false);
        END LOOP;
        END;
        DECLARE 
        parent_row RECORD; 
        BEGIN 
        FOR parent_row IN SELECT * FROM xnat_subjectData_field WHERE fields_field_xnat_subjectData_id=current_row.id
        LOOP
          PERFORM  a_xnat_subjectData_field( parent_row.xnat_subjectdata_field_id, $2,$3,false);
        END LOOP;
        END;
        DECLARE 
        parent_row RECORD; 
        BEGIN 
        FOR parent_row IN SELECT * FROM xnat_subjectAssessorData WHERE subject_ID=current_row.id
        LOOP
          PERFORM  a_xnat_subjectAssessorData( parent_row.id, $2,$3,false);
        END LOOP;
        END;
      END LOOP;
	
	 RETURN '';
    end;
$_$;


ALTER FUNCTION public.a_xnat_subjectdata(character varying, integer, character varying, boolean) OWNER TO xnat;

--
-- Name: a_xnat_subjectdata_addid(integer, integer, character varying, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.a_xnat_subjectdata_addid(integer, integer, character varying, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     row_ct int4;
    begin
      row_ct := 0;
       --UPDATE LOCAL ROW
      FOR current_row IN SELECT xnat_subjectData_addID.*, meta.meta_data_id, meta.status AS meta_status FROM xnat_subjectData_addID LEFT JOIN xnat_subjectData_addID_meta_data meta ON xnat_subjectData_addID.subjectData_addID_info=meta.meta_data_id WHERE  xnat_subjectdata_addid_id=$1
      LOOP
           row_ct := row_ct+1;
           IF (current_row.meta_status!=$3) THEN
         UPDATE xnat_subjectData_addID_meta_data SET status=$3,activation_date=NOW(),activation_user_xdat_user_id=$2 WHERE meta_data_id=current_row.meta_data_id;
           END IF;
          
      END LOOP;
	
	 RETURN '';
    end;
$_$;


ALTER FUNCTION public.a_xnat_subjectdata_addid(integer, integer, character varying, boolean) OWNER TO xnat;

--
-- Name: a_xnat_subjectdata_field(integer, integer, character varying, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.a_xnat_subjectdata_field(integer, integer, character varying, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     row_ct int4;
    begin
      row_ct := 0;
       --UPDATE LOCAL ROW
      FOR current_row IN SELECT xnat_subjectData_field.*, meta.meta_data_id, meta.status AS meta_status FROM xnat_subjectData_field LEFT JOIN xnat_subjectData_field_meta_data meta ON xnat_subjectData_field.subjectData_field_info=meta.meta_data_id WHERE  xnat_subjectdata_field_id=$1
      LOOP
           row_ct := row_ct+1;
           IF (current_row.meta_status!=$3) THEN
         UPDATE xnat_subjectData_field_meta_data SET status=$3,activation_date=NOW(),activation_user_xdat_user_id=$2 WHERE meta_data_id=current_row.meta_data_id;
           END IF;
          
      END LOOP;
	
	 RETURN '';
    end;
$_$;


ALTER FUNCTION public.a_xnat_subjectdata_field(integer, integer, character varying, boolean) OWNER TO xnat;

--
-- Name: a_xnat_subjectmetadata(integer, integer, character varying, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.a_xnat_subjectmetadata(integer, integer, character varying, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     row_ct int4;
    begin
      row_ct := 0;
       --UPDATE LOCAL ROW
      FOR current_row IN SELECT xnat_subjectMetadata.*, meta.meta_data_id, meta.status AS meta_status FROM xnat_subjectMetadata LEFT JOIN xnat_subjectMetadata_meta_data meta ON xnat_subjectMetadata.subjectMetadata_info=meta.meta_data_id WHERE  xnat_abstractsubjectmetadata_id=$1
      LOOP
           row_ct := row_ct+1;
           IF (current_row.meta_status!=$3) THEN
         UPDATE xnat_subjectMetadata_meta_data SET status=$3,activation_date=NOW(),activation_user_xdat_user_id=$2 WHERE meta_data_id=current_row.meta_data_id;
           END IF;
          
        IF ((current_row.xnat_abstractsubjectmetadata_id IS NOT NULL)) THEN
          PERFORM  ae_xnat_abstractSubjectMetadata(current_row.xnat_abstractsubjectmetadata_id, $2,$3,false);
        END IF;
      END LOOP;
      IF (row_ct=0) THEN 
          PERFORM  ae_xnat_abstractSubjectMetadata( $1, $2,$3,$4);
          
      END IF;
	
	 RETURN '';
    end;
$_$;


ALTER FUNCTION public.a_xnat_subjectmetadata(integer, integer, character varying, boolean) OWNER TO xnat;

--
-- Name: a_xnat_subjectvariablesdata(character varying, integer, character varying, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.a_xnat_subjectvariablesdata(character varying, integer, character varying, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     row_ct int4;
    begin
      row_ct := 0;
       --UPDATE LOCAL ROW
      FOR current_row IN SELECT xnat_subjectVariablesData.*, meta.meta_data_id, meta.status AS meta_status FROM xnat_subjectVariablesData LEFT JOIN xnat_subjectVariablesData_meta_data meta ON xnat_subjectVariablesData.subjectVariablesData_info=meta.meta_data_id WHERE  id=$1
      LOOP
           row_ct := row_ct+1;
           IF (current_row.meta_status!=$3) THEN
         UPDATE xnat_subjectVariablesData_meta_data SET status=$3,activation_date=NOW(),activation_user_xdat_user_id=$2 WHERE meta_data_id=current_row.meta_data_id;
           END IF;
          
        IF ((current_row.id IS NOT NULL)) THEN
          PERFORM  ae_xnat_subjectAssessorData(current_row.id, $2,$3,false);
        END IF;
        DECLARE 
        parent_row RECORD; 
        BEGIN 
        FOR parent_row IN SELECT * FROM xnat_subjectVariablesData_variable WHERE variables_variable_xnat_subject_id=current_row.id
        LOOP
          PERFORM  a_xnat_subjectVariablesData_variable( parent_row.xnat_subjectvariablesdata_variable_id, $2,$3,false);
        END LOOP;
        END;
      END LOOP;
      IF (row_ct=0) THEN 
          PERFORM  ae_xnat_subjectAssessorData( $1, $2,$3,$4);
          
      END IF;
	
	 RETURN '';
    end;
$_$;


ALTER FUNCTION public.a_xnat_subjectvariablesdata(character varying, integer, character varying, boolean) OWNER TO xnat;

--
-- Name: a_xnat_subjectvariablesdata_variable(integer, integer, character varying, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.a_xnat_subjectvariablesdata_variable(integer, integer, character varying, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     row_ct int4;
    begin
      row_ct := 0;
       --UPDATE LOCAL ROW
      FOR current_row IN SELECT xnat_subjectVariablesData_variable.*, meta.meta_data_id, meta.status AS meta_status FROM xnat_subjectVariablesData_variable LEFT JOIN xnat_subjectVariablesData_variable_meta_data meta ON xnat_subjectVariablesData_variable.subjectVariablesData_variable_info=meta.meta_data_id WHERE  xnat_subjectvariablesdata_variable_id=$1
      LOOP
           row_ct := row_ct+1;
           IF (current_row.meta_status!=$3) THEN
         UPDATE xnat_subjectVariablesData_variable_meta_data SET status=$3,activation_date=NOW(),activation_user_xdat_user_id=$2 WHERE meta_data_id=current_row.meta_data_id;
           END IF;
          
      END LOOP;
	
	 RETURN '';
    end;
$_$;


ALTER FUNCTION public.a_xnat_subjectvariablesdata_variable(integer, integer, character varying, boolean) OWNER TO xnat;

--
-- Name: a_xnat_usscandata(integer, integer, character varying, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.a_xnat_usscandata(integer, integer, character varying, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     row_ct int4;
    begin
      row_ct := 0;
       --UPDATE LOCAL ROW
      FOR current_row IN SELECT xnat_usScanData.*, meta.meta_data_id, meta.status AS meta_status FROM xnat_usScanData LEFT JOIN xnat_usScanData_meta_data meta ON xnat_usScanData.usScanData_info=meta.meta_data_id WHERE  xnat_imagescandata_id=$1
      LOOP
           row_ct := row_ct+1;
           IF (current_row.meta_status!=$3) THEN
         UPDATE xnat_usScanData_meta_data SET status=$3,activation_date=NOW(),activation_user_xdat_user_id=$2 WHERE meta_data_id=current_row.meta_data_id;
           END IF;
          
        IF ((current_row.xnat_imagescandata_id IS NOT NULL)) THEN
          PERFORM  ae_xnat_imageScanData(current_row.xnat_imagescandata_id, $2,$3,false);
        END IF;
      END LOOP;
      IF (row_ct=0) THEN 
          PERFORM  ae_xnat_imageScanData( $1, $2,$3,$4);
          
      END IF;
	
	 RETURN '';
    end;
$_$;


ALTER FUNCTION public.a_xnat_usscandata(integer, integer, character varying, boolean) OWNER TO xnat;

--
-- Name: a_xnat_ussessiondata(character varying, integer, character varying, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.a_xnat_ussessiondata(character varying, integer, character varying, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     row_ct int4;
    begin
      row_ct := 0;
       --UPDATE LOCAL ROW
      FOR current_row IN SELECT xnat_usSessionData.*, meta.meta_data_id, meta.status AS meta_status FROM xnat_usSessionData LEFT JOIN xnat_usSessionData_meta_data meta ON xnat_usSessionData.usSessionData_info=meta.meta_data_id WHERE  id=$1
      LOOP
           row_ct := row_ct+1;
           IF (current_row.meta_status!=$3) THEN
         UPDATE xnat_usSessionData_meta_data SET status=$3,activation_date=NOW(),activation_user_xdat_user_id=$2 WHERE meta_data_id=current_row.meta_data_id;
           END IF;
          
        IF ((current_row.id IS NOT NULL)) THEN
          PERFORM  ae_xnat_imageSessionData(current_row.id, $2,$3,false);
        END IF;
      END LOOP;
      IF (row_ct=0) THEN 
          PERFORM  ae_xnat_imageSessionData( $1, $2,$3,$4);
          
      END IF;
	
	 RETURN '';
    end;
$_$;


ALTER FUNCTION public.a_xnat_ussessiondata(character varying, integer, character varying, boolean) OWNER TO xnat;

--
-- Name: a_xnat_validationdata(integer, integer, character varying, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.a_xnat_validationdata(integer, integer, character varying, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     row_ct int4;
    begin
      row_ct := 0;
       --UPDATE LOCAL ROW
      FOR current_row IN SELECT xnat_validationData.*, meta.meta_data_id, meta.status AS meta_status FROM xnat_validationData LEFT JOIN xnat_validationData_meta_data meta ON xnat_validationData.validationData_info=meta.meta_data_id WHERE  xnat_validationdata_id=$1
      LOOP
           row_ct := row_ct+1;
           IF (current_row.meta_status!=$3) THEN
         UPDATE xnat_validationData_meta_data SET status=$3,activation_date=NOW(),activation_user_xdat_user_id=$2 WHERE meta_data_id=current_row.meta_data_id;
           END IF;
          
      END LOOP;
	
	 RETURN '';
    end;
$_$;


ALTER FUNCTION public.a_xnat_validationdata(integer, integer, character varying, boolean) OWNER TO xnat;

--
-- Name: a_xnat_voiceaudioscandata(integer, integer, character varying, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.a_xnat_voiceaudioscandata(integer, integer, character varying, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     row_ct int4;
    begin
      row_ct := 0;
       --UPDATE LOCAL ROW
      FOR current_row IN SELECT xnat_voiceAudioScanData.*, meta.meta_data_id, meta.status AS meta_status FROM xnat_voiceAudioScanData LEFT JOIN xnat_voiceAudioScanData_meta_data meta ON xnat_voiceAudioScanData.voiceAudioScanData_info=meta.meta_data_id WHERE  xnat_imagescandata_id=$1
      LOOP
           row_ct := row_ct+1;
           IF (current_row.meta_status!=$3) THEN
         UPDATE xnat_voiceAudioScanData_meta_data SET status=$3,activation_date=NOW(),activation_user_xdat_user_id=$2 WHERE meta_data_id=current_row.meta_data_id;
           END IF;
          
        IF ((current_row.xnat_imagescandata_id IS NOT NULL)) THEN
          PERFORM  ae_xnat_imageScanData(current_row.xnat_imagescandata_id, $2,$3,false);
        END IF;
      END LOOP;
      IF (row_ct=0) THEN 
          PERFORM  ae_xnat_imageScanData( $1, $2,$3,$4);
          
      END IF;
	
	 RETURN '';
    end;
$_$;


ALTER FUNCTION public.a_xnat_voiceaudioscandata(integer, integer, character varying, boolean) OWNER TO xnat;

--
-- Name: a_xnat_volumetricregion(integer, integer, character varying, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.a_xnat_volumetricregion(integer, integer, character varying, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     row_ct int4;
    begin
      row_ct := 0;
       --UPDATE LOCAL ROW
      FOR current_row IN SELECT xnat_volumetricRegion.*, meta.meta_data_id, meta.status AS meta_status FROM xnat_volumetricRegion LEFT JOIN xnat_volumetricRegion_meta_data meta ON xnat_volumetricRegion.volumetricRegion_info=meta.meta_data_id WHERE  xnat_volumetricregion_id=$1
      LOOP
           row_ct := row_ct+1;
           IF (current_row.meta_status!=$3) THEN
         UPDATE xnat_volumetricRegion_meta_data SET status=$3,activation_date=NOW(),activation_user_xdat_user_id=$2 WHERE meta_data_id=current_row.meta_data_id;
           END IF;
          
        DECLARE 
        parent_row RECORD; 
        BEGIN 
        FOR parent_row IN SELECT * FROM xnat_volumetricRegion_subregion WHERE subregions_subregion_xnat_volum_xnat_volumetricregion_id=current_row.xnat_volumetricregion_id
        LOOP
          PERFORM  a_xnat_volumetricRegion_subregion( parent_row.xnat_volumetricregion_subregion_id, $2,$3,false);
        END LOOP;
        END;
      END LOOP;
	
	 RETURN '';
    end;
$_$;


ALTER FUNCTION public.a_xnat_volumetricregion(integer, integer, character varying, boolean) OWNER TO xnat;

--
-- Name: a_xnat_volumetricregion_subregion(integer, integer, character varying, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.a_xnat_volumetricregion_subregion(integer, integer, character varying, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     row_ct int4;
    begin
      row_ct := 0;
       --UPDATE LOCAL ROW
      FOR current_row IN SELECT xnat_volumetricRegion_subregion.*, meta.meta_data_id, meta.status AS meta_status FROM xnat_volumetricRegion_subregion LEFT JOIN xnat_volumetricRegion_subregion_meta_data meta ON xnat_volumetricRegion_subregion.volumetricRegion_subregion_info=meta.meta_data_id WHERE  xnat_volumetricregion_subregion_id=$1
      LOOP
           row_ct := row_ct+1;
           IF (current_row.meta_status!=$3) THEN
         UPDATE xnat_volumetricRegion_subregion_meta_data SET status=$3,activation_date=NOW(),activation_user_xdat_user_id=$2 WHERE meta_data_id=current_row.meta_data_id;
           END IF;
          
      END LOOP;
	
	 RETURN '';
    end;
$_$;


ALTER FUNCTION public.a_xnat_volumetricregion_subregion(integer, integer, character varying, boolean) OWNER TO xnat;

--
-- Name: a_xnat_xa3dscandata(integer, integer, character varying, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.a_xnat_xa3dscandata(integer, integer, character varying, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     row_ct int4;
    begin
      row_ct := 0;
       --UPDATE LOCAL ROW
      FOR current_row IN SELECT xnat_xa3DScanData.*, meta.meta_data_id, meta.status AS meta_status FROM xnat_xa3DScanData LEFT JOIN xnat_xa3DScanData_meta_data meta ON xnat_xa3DScanData.xa3DScanData_info=meta.meta_data_id WHERE  xnat_imagescandata_id=$1
      LOOP
           row_ct := row_ct+1;
           IF (current_row.meta_status!=$3) THEN
         UPDATE xnat_xa3DScanData_meta_data SET status=$3,activation_date=NOW(),activation_user_xdat_user_id=$2 WHERE meta_data_id=current_row.meta_data_id;
           END IF;
          
        IF ((current_row.xnat_imagescandata_id IS NOT NULL)) THEN
          PERFORM  ae_xnat_imageScanData(current_row.xnat_imagescandata_id, $2,$3,false);
        END IF;
      END LOOP;
      IF (row_ct=0) THEN 
          PERFORM  ae_xnat_imageScanData( $1, $2,$3,$4);
          
      END IF;
	
	 RETURN '';
    end;
$_$;


ALTER FUNCTION public.a_xnat_xa3dscandata(integer, integer, character varying, boolean) OWNER TO xnat;

--
-- Name: a_xnat_xa3dsessiondata(character varying, integer, character varying, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.a_xnat_xa3dsessiondata(character varying, integer, character varying, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     row_ct int4;
    begin
      row_ct := 0;
       --UPDATE LOCAL ROW
      FOR current_row IN SELECT xnat_xa3DSessionData.*, meta.meta_data_id, meta.status AS meta_status FROM xnat_xa3DSessionData LEFT JOIN xnat_xa3DSessionData_meta_data meta ON xnat_xa3DSessionData.xa3DSessionData_info=meta.meta_data_id WHERE  id=$1
      LOOP
           row_ct := row_ct+1;
           IF (current_row.meta_status!=$3) THEN
         UPDATE xnat_xa3DSessionData_meta_data SET status=$3,activation_date=NOW(),activation_user_xdat_user_id=$2 WHERE meta_data_id=current_row.meta_data_id;
           END IF;
          
        IF ((current_row.id IS NOT NULL)) THEN
          PERFORM  ae_xnat_imageSessionData(current_row.id, $2,$3,false);
        END IF;
      END LOOP;
      IF (row_ct=0) THEN 
          PERFORM  ae_xnat_imageSessionData( $1, $2,$3,$4);
          
      END IF;
	
	 RETURN '';
    end;
$_$;


ALTER FUNCTION public.a_xnat_xa3dsessiondata(character varying, integer, character varying, boolean) OWNER TO xnat;

--
-- Name: a_xnat_xascandata(integer, integer, character varying, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.a_xnat_xascandata(integer, integer, character varying, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     row_ct int4;
    begin
      row_ct := 0;
       --UPDATE LOCAL ROW
      FOR current_row IN SELECT xnat_xaScanData.*, meta.meta_data_id, meta.status AS meta_status FROM xnat_xaScanData LEFT JOIN xnat_xaScanData_meta_data meta ON xnat_xaScanData.xaScanData_info=meta.meta_data_id WHERE  xnat_imagescandata_id=$1
      LOOP
           row_ct := row_ct+1;
           IF (current_row.meta_status!=$3) THEN
         UPDATE xnat_xaScanData_meta_data SET status=$3,activation_date=NOW(),activation_user_xdat_user_id=$2 WHERE meta_data_id=current_row.meta_data_id;
           END IF;
          
        IF ((current_row.xnat_imagescandata_id IS NOT NULL)) THEN
          PERFORM  ae_xnat_imageScanData(current_row.xnat_imagescandata_id, $2,$3,false);
        END IF;
        IF ((current_row.parameters_contrastbolus_xnat_contrastbolus_id IS NOT NULL)) THEN
          PERFORM  a_xnat_contrastBolus(current_row.parameters_contrastbolus_xnat_contrastbolus_id, $2,$3,false);
        END IF;
      END LOOP;
      IF (row_ct=0) THEN 
          PERFORM  ae_xnat_imageScanData( $1, $2,$3,$4);
          
      END IF;
	
	 RETURN '';
    end;
$_$;


ALTER FUNCTION public.a_xnat_xascandata(integer, integer, character varying, boolean) OWNER TO xnat;

--
-- Name: a_xnat_xasessiondata(character varying, integer, character varying, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.a_xnat_xasessiondata(character varying, integer, character varying, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     row_ct int4;
    begin
      row_ct := 0;
       --UPDATE LOCAL ROW
      FOR current_row IN SELECT xnat_xaSessionData.*, meta.meta_data_id, meta.status AS meta_status FROM xnat_xaSessionData LEFT JOIN xnat_xaSessionData_meta_data meta ON xnat_xaSessionData.xaSessionData_info=meta.meta_data_id WHERE  id=$1
      LOOP
           row_ct := row_ct+1;
           IF (current_row.meta_status!=$3) THEN
         UPDATE xnat_xaSessionData_meta_data SET status=$3,activation_date=NOW(),activation_user_xdat_user_id=$2 WHERE meta_data_id=current_row.meta_data_id;
           END IF;
          
        IF ((current_row.id IS NOT NULL)) THEN
          PERFORM  ae_xnat_imageSessionData(current_row.id, $2,$3,false);
        END IF;
      END LOOP;
      IF (row_ct=0) THEN 
          PERFORM  ae_xnat_imageSessionData( $1, $2,$3,$4);
          
      END IF;
	
	 RETURN '';
    end;
$_$;


ALTER FUNCTION public.a_xnat_xasessiondata(character varying, integer, character varying, boolean) OWNER TO xnat;

--
-- Name: a_xnat_xcscandata(integer, integer, character varying, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.a_xnat_xcscandata(integer, integer, character varying, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     row_ct int4;
    begin
      row_ct := 0;
       --UPDATE LOCAL ROW
      FOR current_row IN SELECT xnat_xcScanData.*, meta.meta_data_id, meta.status AS meta_status FROM xnat_xcScanData LEFT JOIN xnat_xcScanData_meta_data meta ON xnat_xcScanData.xcScanData_info=meta.meta_data_id WHERE  xnat_imagescandata_id=$1
      LOOP
           row_ct := row_ct+1;
           IF (current_row.meta_status!=$3) THEN
         UPDATE xnat_xcScanData_meta_data SET status=$3,activation_date=NOW(),activation_user_xdat_user_id=$2 WHERE meta_data_id=current_row.meta_data_id;
           END IF;
          
        IF ((current_row.xnat_imagescandata_id IS NOT NULL)) THEN
          PERFORM  ae_xnat_imageScanData(current_row.xnat_imagescandata_id, $2,$3,false);
        END IF;
      END LOOP;
      IF (row_ct=0) THEN 
          PERFORM  ae_xnat_imageScanData( $1, $2,$3,$4);
          
      END IF;
	
	 RETURN '';
    end;
$_$;


ALTER FUNCTION public.a_xnat_xcscandata(integer, integer, character varying, boolean) OWNER TO xnat;

--
-- Name: a_xnat_xcsessiondata(character varying, integer, character varying, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.a_xnat_xcsessiondata(character varying, integer, character varying, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     row_ct int4;
    begin
      row_ct := 0;
       --UPDATE LOCAL ROW
      FOR current_row IN SELECT xnat_xcSessionData.*, meta.meta_data_id, meta.status AS meta_status FROM xnat_xcSessionData LEFT JOIN xnat_xcSessionData_meta_data meta ON xnat_xcSessionData.xcSessionData_info=meta.meta_data_id WHERE  id=$1
      LOOP
           row_ct := row_ct+1;
           IF (current_row.meta_status!=$3) THEN
         UPDATE xnat_xcSessionData_meta_data SET status=$3,activation_date=NOW(),activation_user_xdat_user_id=$2 WHERE meta_data_id=current_row.meta_data_id;
           END IF;
          
        IF ((current_row.id IS NOT NULL)) THEN
          PERFORM  ae_xnat_imageSessionData(current_row.id, $2,$3,false);
        END IF;
      END LOOP;
      IF (row_ct=0) THEN 
          PERFORM  ae_xnat_imageSessionData( $1, $2,$3,$4);
          
      END IF;
	
	 RETURN '';
    end;
$_$;


ALTER FUNCTION public.a_xnat_xcsessiondata(character varying, integer, character varying, boolean) OWNER TO xnat;

--
-- Name: a_xnat_xcvscandata(integer, integer, character varying, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.a_xnat_xcvscandata(integer, integer, character varying, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     row_ct int4;
    begin
      row_ct := 0;
       --UPDATE LOCAL ROW
      FOR current_row IN SELECT xnat_xcvScanData.*, meta.meta_data_id, meta.status AS meta_status FROM xnat_xcvScanData LEFT JOIN xnat_xcvScanData_meta_data meta ON xnat_xcvScanData.xcvScanData_info=meta.meta_data_id WHERE  xnat_imagescandata_id=$1
      LOOP
           row_ct := row_ct+1;
           IF (current_row.meta_status!=$3) THEN
         UPDATE xnat_xcvScanData_meta_data SET status=$3,activation_date=NOW(),activation_user_xdat_user_id=$2 WHERE meta_data_id=current_row.meta_data_id;
           END IF;
          
        IF ((current_row.xnat_imagescandata_id IS NOT NULL)) THEN
          PERFORM  ae_xnat_imageScanData(current_row.xnat_imagescandata_id, $2,$3,false);
        END IF;
      END LOOP;
      IF (row_ct=0) THEN 
          PERFORM  ae_xnat_imageScanData( $1, $2,$3,$4);
          
      END IF;
	
	 RETURN '';
    end;
$_$;


ALTER FUNCTION public.a_xnat_xcvscandata(integer, integer, character varying, boolean) OWNER TO xnat;

--
-- Name: a_xnat_xcvsessiondata(character varying, integer, character varying, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.a_xnat_xcvsessiondata(character varying, integer, character varying, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     row_ct int4;
    begin
      row_ct := 0;
       --UPDATE LOCAL ROW
      FOR current_row IN SELECT xnat_xcvSessionData.*, meta.meta_data_id, meta.status AS meta_status FROM xnat_xcvSessionData LEFT JOIN xnat_xcvSessionData_meta_data meta ON xnat_xcvSessionData.xcvSessionData_info=meta.meta_data_id WHERE  id=$1
      LOOP
           row_ct := row_ct+1;
           IF (current_row.meta_status!=$3) THEN
         UPDATE xnat_xcvSessionData_meta_data SET status=$3,activation_date=NOW(),activation_user_xdat_user_id=$2 WHERE meta_data_id=current_row.meta_data_id;
           END IF;
          
        IF ((current_row.id IS NOT NULL)) THEN
          PERFORM  ae_xnat_imageSessionData(current_row.id, $2,$3,false);
        END IF;
      END LOOP;
      IF (row_ct=0) THEN 
          PERFORM  ae_xnat_imageSessionData( $1, $2,$3,$4);
          
      END IF;
	
	 RETURN '';
    end;
$_$;


ALTER FUNCTION public.a_xnat_xcvsessiondata(character varying, integer, character varying, boolean) OWNER TO xnat;

--
-- Name: ae_arc_pipelinedata(integer, integer, character varying, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.ae_arc_pipelinedata(integer, integer, character varying, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     row_ct int4;
    begin
      row_ct := 0;
       --UPDATE LOCAL ROW
      FOR current_row IN SELECT arc_pipelineData.*, meta.meta_data_id, meta.status AS meta_status FROM arc_pipelineData LEFT JOIN arc_pipelineData_meta_data meta ON arc_pipelineData.pipelineData_info=meta.meta_data_id WHERE  arc_pipelinedata_id=$1
      LOOP
           row_ct := row_ct+1;
           IF (current_row.meta_status!=$3) THEN
         UPDATE arc_pipelineData_meta_data SET status=$3,activation_date=NOW(),activation_user_xdat_user_id=$2 WHERE meta_data_id=current_row.meta_data_id;
           END IF;
          
        DECLARE 
        parent_row RECORD; 
        BEGIN 
        FOR parent_row IN SELECT * FROM arc_pipelineParameterData WHERE parameters_parameter_arc_pipeli_arc_pipelinedata_id=current_row.arc_pipelinedata_id
        LOOP
          PERFORM  a_arc_pipelineParameterData( parent_row.arc_pipelineparameterdata_id, $2,$3,false);
        END LOOP;
        END;
      END LOOP;
	
	 RETURN '';
    end;
$_$;


ALTER FUNCTION public.ae_arc_pipelinedata(integer, integer, character varying, boolean) OWNER TO xnat;

--
-- Name: ae_cat_catalog(integer, integer, character varying, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.ae_cat_catalog(integer, integer, character varying, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     row_ct int4;
    begin
      row_ct := 0;
       --UPDATE LOCAL ROW
      FOR current_row IN SELECT cat_catalog.*, meta.meta_data_id, meta.status AS meta_status FROM cat_catalog LEFT JOIN cat_catalog_meta_data meta ON cat_catalog.catalog_info=meta.meta_data_id WHERE  cat_catalog_id=$1
      LOOP
           row_ct := row_ct+1;
           IF (current_row.meta_status!=$3) THEN
         UPDATE cat_catalog_meta_data SET status=$3,activation_date=NOW(),activation_user_xdat_user_id=$2 WHERE meta_data_id=current_row.meta_data_id;
           END IF;
          
        DECLARE 
        parent_row RECORD; 
        BEGIN 
        FOR parent_row IN SELECT * FROM cat_catalog_metaField WHERE metafields_metafield_cat_catalo_cat_catalog_id=current_row.cat_catalog_id
        LOOP
          PERFORM  a_cat_catalog_metaField( parent_row.cat_catalog_metafield_id, $2,$3,false);
        END LOOP;
        END;
        DECLARE 
        parent_row RECORD; 
        BEGIN 
        FOR parent_row IN SELECT * FROM cat_catalog_tag WHERE tags_tag_cat_catalog_cat_catalog_id=current_row.cat_catalog_id
        LOOP
          PERFORM  a_cat_catalog_tag( parent_row.cat_catalog_tag_id, $2,$3,false);
        END LOOP;
        END;
        DECLARE 
        parent_row RECORD; 
        BEGIN 
        FOR parent_row IN SELECT * FROM cat_catalog WHERE sets_entryset_cat_catalog_id=current_row.cat_catalog_id
        LOOP
          PERFORM  a_cat_catalog( parent_row.cat_catalog_id, $2,$3,false);
        END LOOP;
        END;
        DECLARE 
        parent_row RECORD; 
        BEGIN 
        FOR parent_row IN SELECT * FROM cat_entry WHERE entries_entry_cat_catalog_cat_catalog_id=current_row.cat_catalog_id
        LOOP
          PERFORM  a_cat_entry( parent_row.cat_entry_id, $2,$3,false);
        END LOOP;
        END;
      END LOOP;
	
	 RETURN '';
    end;
$_$;


ALTER FUNCTION public.ae_cat_catalog(integer, integer, character varying, boolean) OWNER TO xnat;

--
-- Name: ae_cat_entry(integer, integer, character varying, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.ae_cat_entry(integer, integer, character varying, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     row_ct int4;
    begin
      row_ct := 0;
       --UPDATE LOCAL ROW
      FOR current_row IN SELECT cat_entry.*, meta.meta_data_id, meta.status AS meta_status FROM cat_entry LEFT JOIN cat_entry_meta_data meta ON cat_entry.entry_info=meta.meta_data_id WHERE  cat_entry_id=$1
      LOOP
           row_ct := row_ct+1;
           IF (current_row.meta_status!=$3) THEN
         UPDATE cat_entry_meta_data SET status=$3,activation_date=NOW(),activation_user_xdat_user_id=$2 WHERE meta_data_id=current_row.meta_data_id;
           END IF;
          
        DECLARE 
        parent_row RECORD; 
        BEGIN 
        FOR parent_row IN SELECT * FROM cat_entry_metaField WHERE metafields_metafield_cat_entry_cat_entry_id=current_row.cat_entry_id
        LOOP
          PERFORM  a_cat_entry_metaField( parent_row.cat_entry_metafield_id, $2,$3,false);
        END LOOP;
        END;
        DECLARE 
        parent_row RECORD; 
        BEGIN 
        FOR parent_row IN SELECT * FROM cat_entry_tag WHERE tags_tag_cat_entry_cat_entry_id=current_row.cat_entry_id
        LOOP
          PERFORM  a_cat_entry_tag( parent_row.cat_entry_tag_id, $2,$3,false);
        END LOOP;
        END;
      END LOOP;
	
	 RETURN '';
    end;
$_$;


ALTER FUNCTION public.ae_cat_entry(integer, integer, character varying, boolean) OWNER TO xnat;

--
-- Name: ae_wrk_abstractexecutionenvironment(integer, integer, character varying, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.ae_wrk_abstractexecutionenvironment(integer, integer, character varying, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     row_ct int4;
    begin
      row_ct := 0;
       --UPDATE LOCAL ROW
      FOR current_row IN SELECT wrk_abstractExecutionEnvironment.*, meta.meta_data_id, meta.status AS meta_status FROM wrk_abstractExecutionEnvironment LEFT JOIN wrk_abstractExecutionEnvironment_meta_data meta ON wrk_abstractExecutionEnvironment.abstractExecutionEnvironment_info=meta.meta_data_id WHERE  wrk_abstractexecutionenvironment_id=$1
      LOOP
           row_ct := row_ct+1;
           IF (current_row.meta_status!=$3) THEN
         UPDATE wrk_abstractExecutionEnvironment_meta_data SET status=$3,activation_date=NOW(),activation_user_xdat_user_id=$2 WHERE meta_data_id=current_row.meta_data_id;
           END IF;
          
      END LOOP;
	
	 RETURN '';
    end;
$_$;


ALTER FUNCTION public.ae_wrk_abstractexecutionenvironment(integer, integer, character varying, boolean) OWNER TO xnat;

--
-- Name: ae_xdat_stored_search(character varying, integer, character varying, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.ae_xdat_stored_search(character varying, integer, character varying, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     row_ct int4;
    begin
      row_ct := 0;
       --UPDATE LOCAL ROW
      FOR current_row IN SELECT xdat_stored_search.*, meta.meta_data_id, meta.status AS meta_status FROM xdat_stored_search LEFT JOIN xdat_stored_search_meta_data meta ON xdat_stored_search.stored_search_info=meta.meta_data_id WHERE  id=$1
      LOOP
           row_ct := row_ct+1;
           IF (current_row.meta_status!=$3) THEN
         UPDATE xdat_stored_search_meta_data SET status=$3,activation_date=NOW(),activation_user_xdat_user_id=$2 WHERE meta_data_id=current_row.meta_data_id;
           END IF;
          
        DECLARE 
        parent_row RECORD; 
        BEGIN 
        FOR parent_row IN SELECT * FROM xdat_search_field WHERE xdat_stored_search_id=current_row.id
        LOOP
          PERFORM  a_xdat_search_field( parent_row.xdat_search_field_id, $2,$3,false);
        END LOOP;
        END;
        DECLARE 
        parent_row RECORD; 
        BEGIN 
        FOR parent_row IN SELECT * FROM xdat_criteria_set WHERE xdat_stored_search_id=current_row.id
        LOOP
          PERFORM  a_xdat_criteria_set( parent_row.xdat_criteria_set_id, $2,$3,false);
        END LOOP;
        END;
        DECLARE 
        parent_row RECORD; 
        BEGIN 
        FOR parent_row IN SELECT * FROM xdat_stored_search_allowed_user WHERE xdat_stored_search_id=current_row.id
        LOOP
          PERFORM  a_xdat_stored_search_allowed_user( parent_row.xdat_stored_search_allowed_user_id, $2,$3,false);
        END LOOP;
        END;
        DECLARE 
        parent_row RECORD; 
        BEGIN 
        FOR parent_row IN SELECT * FROM xdat_stored_search_groupID WHERE allowed_groups_groupid_xdat_sto_id=current_row.id
        LOOP
          PERFORM  a_xdat_stored_search_groupID( parent_row.xdat_stored_search_groupid_id, $2,$3,false);
        END LOOP;
        END;
      END LOOP;
	
	 RETURN '';
    end;
$_$;


ALTER FUNCTION public.ae_xdat_stored_search(character varying, integer, character varying, boolean) OWNER TO xnat;

--
-- Name: ae_xnat_abstractdemographicdata(integer, integer, character varying, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.ae_xnat_abstractdemographicdata(integer, integer, character varying, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     row_ct int4;
    begin
      row_ct := 0;
       --UPDATE LOCAL ROW
      FOR current_row IN SELECT xnat_abstractDemographicData.*, meta.meta_data_id, meta.status AS meta_status FROM xnat_abstractDemographicData LEFT JOIN xnat_abstractDemographicData_meta_data meta ON xnat_abstractDemographicData.abstractDemographicData_info=meta.meta_data_id WHERE  xnat_abstractdemographicdata_id=$1
      LOOP
           row_ct := row_ct+1;
           IF (current_row.meta_status!=$3) THEN
         UPDATE xnat_abstractDemographicData_meta_data SET status=$3,activation_date=NOW(),activation_user_xdat_user_id=$2 WHERE meta_data_id=current_row.meta_data_id;
           END IF;
          
      END LOOP;
	
	 RETURN '';
    end;
$_$;


ALTER FUNCTION public.ae_xnat_abstractdemographicdata(integer, integer, character varying, boolean) OWNER TO xnat;

--
-- Name: ae_xnat_abstractprotocol(integer, integer, character varying, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.ae_xnat_abstractprotocol(integer, integer, character varying, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     row_ct int4;
    begin
      row_ct := 0;
       --UPDATE LOCAL ROW
      FOR current_row IN SELECT xnat_abstractProtocol.*, meta.meta_data_id, meta.status AS meta_status FROM xnat_abstractProtocol LEFT JOIN xnat_abstractProtocol_meta_data meta ON xnat_abstractProtocol.abstractProtocol_info=meta.meta_data_id WHERE  xnat_abstractprotocol_id=$1
      LOOP
           row_ct := row_ct+1;
           IF (current_row.meta_status!=$3) THEN
         UPDATE xnat_abstractProtocol_meta_data SET status=$3,activation_date=NOW(),activation_user_xdat_user_id=$2 WHERE meta_data_id=current_row.meta_data_id;
           END IF;
          
      END LOOP;
	
	 RETURN '';
    end;
$_$;


ALTER FUNCTION public.ae_xnat_abstractprotocol(integer, integer, character varying, boolean) OWNER TO xnat;

--
-- Name: ae_xnat_abstractresource(integer, integer, character varying, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.ae_xnat_abstractresource(integer, integer, character varying, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     row_ct int4;
    begin
      row_ct := 0;
       --UPDATE LOCAL ROW
      FOR current_row IN SELECT xnat_abstractResource.*, meta.meta_data_id, meta.status AS meta_status FROM xnat_abstractResource LEFT JOIN xnat_abstractResource_meta_data meta ON xnat_abstractResource.abstractResource_info=meta.meta_data_id WHERE  xnat_abstractresource_id=$1
      LOOP
           row_ct := row_ct+1;
           IF (current_row.meta_status!=$3) THEN
         UPDATE xnat_abstractResource_meta_data SET status=$3,activation_date=NOW(),activation_user_xdat_user_id=$2 WHERE meta_data_id=current_row.meta_data_id;
           END IF;
          
        DECLARE 
        parent_row RECORD; 
        BEGIN 
        FOR parent_row IN SELECT * FROM xnat_abstractResource_tag WHERE tags_tag_xnat_abstractResource_xnat_abstractresource_id=current_row.xnat_abstractresource_id
        LOOP
          PERFORM  a_xnat_abstractResource_tag( parent_row.xnat_abstractresource_tag_id, $2,$3,false);
        END LOOP;
        END;
      END LOOP;
	
	 RETURN '';
    end;
$_$;


ALTER FUNCTION public.ae_xnat_abstractresource(integer, integer, character varying, boolean) OWNER TO xnat;

--
-- Name: ae_xnat_abstractstatistics(integer, integer, character varying, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.ae_xnat_abstractstatistics(integer, integer, character varying, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     row_ct int4;
    begin
      row_ct := 0;
       --UPDATE LOCAL ROW
      FOR current_row IN SELECT xnat_abstractStatistics.*, meta.meta_data_id, meta.status AS meta_status FROM xnat_abstractStatistics LEFT JOIN xnat_abstractStatistics_meta_data meta ON xnat_abstractStatistics.abstractStatistics_info=meta.meta_data_id WHERE  xnat_abstractstatistics_id=$1
      LOOP
           row_ct := row_ct+1;
           IF (current_row.meta_status!=$3) THEN
         UPDATE xnat_abstractStatistics_meta_data SET status=$3,activation_date=NOW(),activation_user_xdat_user_id=$2 WHERE meta_data_id=current_row.meta_data_id;
           END IF;
          
      END LOOP;
	
	 RETURN '';
    end;
$_$;


ALTER FUNCTION public.ae_xnat_abstractstatistics(integer, integer, character varying, boolean) OWNER TO xnat;

--
-- Name: ae_xnat_abstractsubjectmetadata(integer, integer, character varying, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.ae_xnat_abstractsubjectmetadata(integer, integer, character varying, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     row_ct int4;
    begin
      row_ct := 0;
       --UPDATE LOCAL ROW
      FOR current_row IN SELECT xnat_abstractSubjectMetadata.*, meta.meta_data_id, meta.status AS meta_status FROM xnat_abstractSubjectMetadata LEFT JOIN xnat_abstractSubjectMetadata_meta_data meta ON xnat_abstractSubjectMetadata.abstractSubjectMetadata_info=meta.meta_data_id WHERE  xnat_abstractsubjectmetadata_id=$1
      LOOP
           row_ct := row_ct+1;
           IF (current_row.meta_status!=$3) THEN
         UPDATE xnat_abstractSubjectMetadata_meta_data SET status=$3,activation_date=NOW(),activation_user_xdat_user_id=$2 WHERE meta_data_id=current_row.meta_data_id;
           END IF;
          
      END LOOP;
	
	 RETURN '';
    end;
$_$;


ALTER FUNCTION public.ae_xnat_abstractsubjectmetadata(integer, integer, character varying, boolean) OWNER TO xnat;

--
-- Name: ae_xnat_deriveddata(character varying, integer, character varying, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.ae_xnat_deriveddata(character varying, integer, character varying, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     row_ct int4;
    begin
      row_ct := 0;
       --UPDATE LOCAL ROW
      FOR current_row IN SELECT xnat_derivedData.*, meta.meta_data_id, meta.status AS meta_status FROM xnat_derivedData LEFT JOIN xnat_derivedData_meta_data meta ON xnat_derivedData.derivedData_info=meta.meta_data_id WHERE  id=$1
      LOOP
           row_ct := row_ct+1;
           IF (current_row.meta_status!=$3) THEN
         UPDATE xnat_derivedData_meta_data SET status=$3,activation_date=NOW(),activation_user_xdat_user_id=$2 WHERE meta_data_id=current_row.meta_data_id;
           END IF;
          
        IF ((current_row.id IS NOT NULL)) THEN
          PERFORM  ae_xnat_experimentData(current_row.id, $2,$3,false);
        END IF;
        IF ((current_row.provenance_prov_process_id IS NOT NULL)) THEN
          PERFORM  a_prov_process(current_row.provenance_prov_process_id, $2,$3,false);
        END IF;
      END LOOP;
      IF (row_ct=0) THEN 
          PERFORM  ae_xnat_experimentData( $1, $2,$3,$4);
          
      END IF;
	
	 RETURN '';
    end;
$_$;


ALTER FUNCTION public.ae_xnat_deriveddata(character varying, integer, character varying, boolean) OWNER TO xnat;

--
-- Name: ae_xnat_experimentdata(character varying, integer, character varying, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.ae_xnat_experimentdata(character varying, integer, character varying, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     row_ct int4;
    begin
      row_ct := 0;
       --UPDATE LOCAL ROW
      FOR current_row IN SELECT xnat_experimentData.*, meta.meta_data_id, meta.status AS meta_status FROM xnat_experimentData LEFT JOIN xnat_experimentData_meta_data meta ON xnat_experimentData.experimentData_info=meta.meta_data_id WHERE  id=$1
      LOOP
           row_ct := row_ct+1;
           IF (current_row.meta_status!=$3) THEN
         UPDATE xnat_experimentData_meta_data SET status=$3,activation_date=NOW(),activation_user_xdat_user_id=$2 WHERE meta_data_id=current_row.meta_data_id;
           END IF;
          
        DECLARE 
        parent_row RECORD; 
        BEGIN 
        FOR parent_row IN SELECT * FROM xnat_experimentData_share WHERE sharing_share_xnat_experimentDa_id=current_row.id
        LOOP
          PERFORM  a_xnat_experimentData_share( parent_row.xnat_experimentdata_share_id, $2,$3,false);
        END LOOP;
        END;
        IF ((current_row.investigator_xnat_investigatordata_id IS NOT NULL)) THEN
          PERFORM  a_xnat_investigatorData(current_row.investigator_xnat_investigatordata_id, $2,$3,false);
        END IF;
        IF ((current_row.validation_xnat_validationdata_id IS NOT NULL)) THEN
          PERFORM  a_xnat_validationData(current_row.validation_xnat_validationdata_id, $2,$3,false);
        END IF;
        DECLARE 
        mapping_row RECORD; 
        BEGIN 
        FOR mapping_row IN SELECT * FROM xnat_experimentData_resource WHERE  xnat_experimentData_id=current_row.id
        LOOP
          PERFORM  a_xnat_abstractResource( mapping_row.xnat_abstractResource_xnat_abstractresource_id, $2,$3,false);
        END LOOP;
        END; 
        DECLARE 
        parent_row RECORD; 
        BEGIN 
        FOR parent_row IN SELECT * FROM xnat_experimentData_field WHERE fields_field_xnat_experimentDat_id=current_row.id
        LOOP
          PERFORM  a_xnat_experimentData_field( parent_row.xnat_experimentdata_field_id, $2,$3,false);
        END LOOP;
        END;
      END LOOP;
	
	 RETURN '';
    end;
$_$;


ALTER FUNCTION public.ae_xnat_experimentdata(character varying, integer, character varying, boolean) OWNER TO xnat;

--
-- Name: ae_xnat_genericdata(character varying, integer, character varying, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.ae_xnat_genericdata(character varying, integer, character varying, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     row_ct int4;
    begin
      row_ct := 0;
       --UPDATE LOCAL ROW
      FOR current_row IN SELECT xnat_genericData.*, meta.meta_data_id, meta.status AS meta_status FROM xnat_genericData LEFT JOIN xnat_genericData_meta_data meta ON xnat_genericData.genericData_info=meta.meta_data_id WHERE  id=$1
      LOOP
           row_ct := row_ct+1;
           IF (current_row.meta_status!=$3) THEN
         UPDATE xnat_genericData_meta_data SET status=$3,activation_date=NOW(),activation_user_xdat_user_id=$2 WHERE meta_data_id=current_row.meta_data_id;
           END IF;
          
        IF ((current_row.id IS NOT NULL)) THEN
          PERFORM  ae_xnat_experimentData(current_row.id, $2,$3,false);
        END IF;
      END LOOP;
      IF (row_ct=0) THEN 
          PERFORM  ae_xnat_experimentData( $1, $2,$3,$4);
          
      END IF;
	
	 RETURN '';
    end;
$_$;


ALTER FUNCTION public.ae_xnat_genericdata(character varying, integer, character varying, boolean) OWNER TO xnat;

--
-- Name: ae_xnat_imageassessordata(character varying, integer, character varying, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.ae_xnat_imageassessordata(character varying, integer, character varying, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     row_ct int4;
    begin
      row_ct := 0;
       --UPDATE LOCAL ROW
      FOR current_row IN SELECT xnat_imageAssessorData.*, meta.meta_data_id, meta.status AS meta_status FROM xnat_imageAssessorData LEFT JOIN xnat_imageAssessorData_meta_data meta ON xnat_imageAssessorData.imageAssessorData_info=meta.meta_data_id WHERE  id=$1
      LOOP
           row_ct := row_ct+1;
           IF (current_row.meta_status!=$3) THEN
         UPDATE xnat_imageAssessorData_meta_data SET status=$3,activation_date=NOW(),activation_user_xdat_user_id=$2 WHERE meta_data_id=current_row.meta_data_id;
           END IF;
          
        IF ((current_row.id IS NOT NULL)) THEN
          PERFORM  ae_xnat_derivedData(current_row.id, $2,$3,false);
        END IF;
        DECLARE 
        mapping_row RECORD; 
        BEGIN 
        FOR mapping_row IN SELECT * FROM img_assessor_in_resource WHERE  xnat_imageAssessorData_id=current_row.id
        LOOP
          PERFORM  a_xnat_abstractResource( mapping_row.xnat_abstractResource_xnat_abstractresource_id, $2,$3,false);
        END LOOP;
        END; 
        DECLARE 
        mapping_row RECORD; 
        BEGIN 
        FOR mapping_row IN SELECT * FROM img_assessor_out_resource WHERE  xnat_imageAssessorData_id=current_row.id
        LOOP
          PERFORM  a_xnat_abstractResource( mapping_row.xnat_abstractResource_xnat_abstractresource_id, $2,$3,false);
        END LOOP;
        END; 
        DECLARE 
        parent_row RECORD; 
        BEGIN 
        FOR parent_row IN SELECT * FROM xnat_addField WHERE parameters_addparam_xnat_imageA_id=current_row.id
        LOOP
          PERFORM  a_xnat_addField( parent_row.xnat_addfield_id, $2,$3,false);
        END LOOP;
        END;
      END LOOP;
      IF (row_ct=0) THEN 
          PERFORM  ae_xnat_derivedData( $1, $2,$3,$4);
          
      END IF;
	
	 RETURN '';
    end;
$_$;


ALTER FUNCTION public.ae_xnat_imageassessordata(character varying, integer, character varying, boolean) OWNER TO xnat;

--
-- Name: ae_xnat_imagescandata(integer, integer, character varying, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.ae_xnat_imagescandata(integer, integer, character varying, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     row_ct int4;
    begin
      row_ct := 0;
       --UPDATE LOCAL ROW
      FOR current_row IN SELECT xnat_imageScanData.*, meta.meta_data_id, meta.status AS meta_status FROM xnat_imageScanData LEFT JOIN xnat_imageScanData_meta_data meta ON xnat_imageScanData.imageScanData_info=meta.meta_data_id WHERE  xnat_imagescandata_id=$1
      LOOP
           row_ct := row_ct+1;
           IF (current_row.meta_status!=$3) THEN
         UPDATE xnat_imageScanData_meta_data SET status=$3,activation_date=NOW(),activation_user_xdat_user_id=$2 WHERE meta_data_id=current_row.meta_data_id;
           END IF;
          
        DECLARE 
        parent_row RECORD; 
        BEGIN 
        FOR parent_row IN SELECT * FROM xnat_imageScanData_share WHERE sharing_share_xnat_imageScanDat_xnat_imagescandata_id=current_row.xnat_imagescandata_id
        LOOP
          PERFORM  a_xnat_imageScanData_share( parent_row.xnat_imagescandata_share_id, $2,$3,false);
        END LOOP;
        END;
        DECLARE 
        parent_row RECORD; 
        BEGIN 
        FOR parent_row IN SELECT * FROM xnat_abstractResource WHERE xnat_imageScanData_xnat_imagescandata_id=current_row.xnat_imagescandata_id
        LOOP
          PERFORM  a_xnat_abstractResource( parent_row.xnat_abstractresource_id, $2,$3,false);
        END LOOP;
        END;
        IF ((current_row.validation_xnat_validationdata_id IS NOT NULL)) THEN
          PERFORM  a_xnat_validationData(current_row.validation_xnat_validationdata_id, $2,$3,false);
        END IF;
      END LOOP;
	
	 RETURN '';
    end;
$_$;


ALTER FUNCTION public.ae_xnat_imagescandata(integer, integer, character varying, boolean) OWNER TO xnat;

--
-- Name: ae_xnat_imagesessiondata(character varying, integer, character varying, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.ae_xnat_imagesessiondata(character varying, integer, character varying, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     row_ct int4;
    begin
      row_ct := 0;
       --UPDATE LOCAL ROW
      FOR current_row IN SELECT xnat_imageSessionData.*, meta.meta_data_id, meta.status AS meta_status FROM xnat_imageSessionData LEFT JOIN xnat_imageSessionData_meta_data meta ON xnat_imageSessionData.imageSessionData_info=meta.meta_data_id WHERE  id=$1
      LOOP
           row_ct := row_ct+1;
           IF (current_row.meta_status!=$3) THEN
         UPDATE xnat_imageSessionData_meta_data SET status=$3,activation_date=NOW(),activation_user_xdat_user_id=$2 WHERE meta_data_id=current_row.meta_data_id;
           END IF;
          
        IF ((current_row.id IS NOT NULL)) THEN
          PERFORM  ae_xnat_subjectAssessorData(current_row.id, $2,$3,false);
        END IF;
        DECLARE 
        parent_row RECORD; 
        BEGIN 
        FOR parent_row IN SELECT * FROM xnat_regionResource WHERE session_id=current_row.id
        LOOP
          PERFORM  a_xnat_regionResource( parent_row.xnat_regionresource_id, $2,$3,false);
        END LOOP;
        END;
        DECLARE 
        parent_row RECORD; 
        BEGIN 
        FOR parent_row IN SELECT * FROM xnat_imageScanData WHERE image_session_id=current_row.id
        LOOP
          PERFORM  a_xnat_imageScanData( parent_row.xnat_imagescandata_id, $2,$3,false);
        END LOOP;
        END;
        DECLARE 
        parent_row RECORD; 
        BEGIN 
        FOR parent_row IN SELECT * FROM xnat_reconstructedImageData WHERE image_session_id=current_row.id
        LOOP
          PERFORM  a_xnat_reconstructedImageData( parent_row.xnat_reconstructedimagedata_id, $2,$3,false);
        END LOOP;
        END;
        DECLARE 
        parent_row RECORD; 
        BEGIN 
        FOR parent_row IN SELECT * FROM xnat_imageAssessorData WHERE imageSession_ID=current_row.id
        LOOP
          PERFORM  a_xnat_imageAssessorData( parent_row.id, $2,$3,false);
        END LOOP;
        END;
      END LOOP;
      IF (row_ct=0) THEN 
          PERFORM  ae_xnat_subjectAssessorData( $1, $2,$3,$4);
          
      END IF;
	
	 RETURN '';
    end;
$_$;


ALTER FUNCTION public.ae_xnat_imagesessiondata(character varying, integer, character varying, boolean) OWNER TO xnat;

--
-- Name: ae_xnat_mrassessordata(character varying, integer, character varying, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.ae_xnat_mrassessordata(character varying, integer, character varying, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     row_ct int4;
    begin
      row_ct := 0;
       --UPDATE LOCAL ROW
      FOR current_row IN SELECT xnat_mrAssessorData.*, meta.meta_data_id, meta.status AS meta_status FROM xnat_mrAssessorData LEFT JOIN xnat_mrAssessorData_meta_data meta ON xnat_mrAssessorData.mrAssessorData_info=meta.meta_data_id WHERE  id=$1
      LOOP
           row_ct := row_ct+1;
           IF (current_row.meta_status!=$3) THEN
         UPDATE xnat_mrAssessorData_meta_data SET status=$3,activation_date=NOW(),activation_user_xdat_user_id=$2 WHERE meta_data_id=current_row.meta_data_id;
           END IF;
          
        IF ((current_row.id IS NOT NULL)) THEN
          PERFORM  ae_xnat_imageAssessorData(current_row.id, $2,$3,false);
        END IF;
      END LOOP;
      IF (row_ct=0) THEN 
          PERFORM  ae_xnat_imageAssessorData( $1, $2,$3,$4);
          
      END IF;
	
	 RETURN '';
    end;
$_$;


ALTER FUNCTION public.ae_xnat_mrassessordata(character varying, integer, character varying, boolean) OWNER TO xnat;

--
-- Name: ae_xnat_qcscandata(integer, integer, character varying, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.ae_xnat_qcscandata(integer, integer, character varying, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     row_ct int4;
    begin
      row_ct := 0;
       --UPDATE LOCAL ROW
      FOR current_row IN SELECT xnat_qcScanData.*, meta.meta_data_id, meta.status AS meta_status FROM xnat_qcScanData LEFT JOIN xnat_qcScanData_meta_data meta ON xnat_qcScanData.qcScanData_info=meta.meta_data_id WHERE  xnat_qcscandata_id=$1
      LOOP
           row_ct := row_ct+1;
           IF (current_row.meta_status!=$3) THEN
         UPDATE xnat_qcScanData_meta_data SET status=$3,activation_date=NOW(),activation_user_xdat_user_id=$2 WHERE meta_data_id=current_row.meta_data_id;
           END IF;
          
        DECLARE 
        parent_row RECORD; 
        BEGIN 
        FOR parent_row IN SELECT * FROM xnat_qcScanData_field WHERE fields_field_xnat_qcScanData_xnat_qcscandata_id=current_row.xnat_qcscandata_id
        LOOP
          PERFORM  a_xnat_qcScanData_field( parent_row.xnat_qcscandata_field_id, $2,$3,false);
        END LOOP;
        END;
      END LOOP;
	
	 RETURN '';
    end;
$_$;


ALTER FUNCTION public.ae_xnat_qcscandata(integer, integer, character varying, boolean) OWNER TO xnat;

--
-- Name: ae_xnat_resource(integer, integer, character varying, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.ae_xnat_resource(integer, integer, character varying, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     row_ct int4;
    begin
      row_ct := 0;
       --UPDATE LOCAL ROW
      FOR current_row IN SELECT xnat_resource.*, meta.meta_data_id, meta.status AS meta_status FROM xnat_resource LEFT JOIN xnat_resource_meta_data meta ON xnat_resource.resource_info=meta.meta_data_id WHERE  xnat_abstractresource_id=$1
      LOOP
           row_ct := row_ct+1;
           IF (current_row.meta_status!=$3) THEN
         UPDATE xnat_resource_meta_data SET status=$3,activation_date=NOW(),activation_user_xdat_user_id=$2 WHERE meta_data_id=current_row.meta_data_id;
           END IF;
          
        IF ((current_row.xnat_abstractresource_id IS NOT NULL)) THEN
          PERFORM  ae_xnat_abstractResource(current_row.xnat_abstractresource_id, $2,$3,false);
        END IF;
        IF ((current_row.provenance_prov_process_id IS NOT NULL)) THEN
          PERFORM  a_prov_process(current_row.provenance_prov_process_id, $2,$3,false);
        END IF;
      END LOOP;
      IF (row_ct=0) THEN 
          PERFORM  ae_xnat_abstractResource( $1, $2,$3,$4);
          
      END IF;
	
	 RETURN '';
    end;
$_$;


ALTER FUNCTION public.ae_xnat_resource(integer, integer, character varying, boolean) OWNER TO xnat;

--
-- Name: ae_xnat_resourceseries(integer, integer, character varying, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.ae_xnat_resourceseries(integer, integer, character varying, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     row_ct int4;
    begin
      row_ct := 0;
       --UPDATE LOCAL ROW
      FOR current_row IN SELECT xnat_resourceSeries.*, meta.meta_data_id, meta.status AS meta_status FROM xnat_resourceSeries LEFT JOIN xnat_resourceSeries_meta_data meta ON xnat_resourceSeries.resourceSeries_info=meta.meta_data_id WHERE  xnat_abstractresource_id=$1
      LOOP
           row_ct := row_ct+1;
           IF (current_row.meta_status!=$3) THEN
         UPDATE xnat_resourceSeries_meta_data SET status=$3,activation_date=NOW(),activation_user_xdat_user_id=$2 WHERE meta_data_id=current_row.meta_data_id;
           END IF;
          
        IF ((current_row.xnat_abstractresource_id IS NOT NULL)) THEN
          PERFORM  ae_xnat_abstractResource(current_row.xnat_abstractresource_id, $2,$3,false);
        END IF;
      END LOOP;
      IF (row_ct=0) THEN 
          PERFORM  ae_xnat_abstractResource( $1, $2,$3,$4);
          
      END IF;
	
	 RETURN '';
    end;
$_$;


ALTER FUNCTION public.ae_xnat_resourceseries(integer, integer, character varying, boolean) OWNER TO xnat;

--
-- Name: ae_xnat_subjectassessordata(character varying, integer, character varying, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.ae_xnat_subjectassessordata(character varying, integer, character varying, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     row_ct int4;
    begin
      row_ct := 0;
       --UPDATE LOCAL ROW
      FOR current_row IN SELECT xnat_subjectAssessorData.*, meta.meta_data_id, meta.status AS meta_status FROM xnat_subjectAssessorData LEFT JOIN xnat_subjectAssessorData_meta_data meta ON xnat_subjectAssessorData.subjectAssessorData_info=meta.meta_data_id WHERE  id=$1
      LOOP
           row_ct := row_ct+1;
           IF (current_row.meta_status!=$3) THEN
         UPDATE xnat_subjectAssessorData_meta_data SET status=$3,activation_date=NOW(),activation_user_xdat_user_id=$2 WHERE meta_data_id=current_row.meta_data_id;
           END IF;
          
        IF ((current_row.id IS NOT NULL)) THEN
          PERFORM  ae_xnat_experimentData(current_row.id, $2,$3,false);
        END IF;
      END LOOP;
      IF (row_ct=0) THEN 
          PERFORM  ae_xnat_experimentData( $1, $2,$3,$4);
          
      END IF;
	
	 RETURN '';
    end;
$_$;


ALTER FUNCTION public.ae_xnat_subjectassessordata(character varying, integer, character varying, boolean) OWNER TO xnat;

--
-- Name: after_update_arc_archivespecification(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_arc_archivespecification() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_arc_ArchiveSpecification( OLD.arc_archivespecification_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_arc_archivespecification() OWNER TO xnat;

--
-- Name: after_update_arc_archivespecification_notification_type(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_arc_archivespecification_notification_type() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_arc_ArchiveSpecification_notification_type( OLD.arc_archivespecification_notification_type_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_arc_archivespecification_notification_type() OWNER TO xnat;

--
-- Name: after_update_arc_fieldspecification(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_arc_fieldspecification() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_arc_fieldSpecification( OLD.arc_fieldspecification_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_arc_fieldspecification() OWNER TO xnat;

--
-- Name: after_update_arc_pathinfo(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_arc_pathinfo() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_arc_pathInfo( OLD.arc_pathinfo_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_arc_pathinfo() OWNER TO xnat;

--
-- Name: after_update_arc_pipelinedata(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_arc_pipelinedata() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_arc_pipelineData( OLD.arc_pipelinedata_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_arc_pipelinedata() OWNER TO xnat;

--
-- Name: after_update_arc_pipelineparameterdata(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_arc_pipelineparameterdata() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_arc_pipelineParameterData( OLD.arc_pipelineparameterdata_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_arc_pipelineparameterdata() OWNER TO xnat;

--
-- Name: after_update_arc_project(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_arc_project() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_arc_project( OLD.arc_project_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_arc_project() OWNER TO xnat;

--
-- Name: after_update_arc_project_descendant(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_arc_project_descendant() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_arc_project_descendant( OLD.arc_project_descendant_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_arc_project_descendant() OWNER TO xnat;

--
-- Name: after_update_arc_project_descendant_pipeline(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_arc_project_descendant_pipeline() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_arc_project_descendant_pipeline( OLD.arc_pipelinedata_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_arc_project_descendant_pipeline() OWNER TO xnat;

--
-- Name: after_update_arc_project_pipeline(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_arc_project_pipeline() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_arc_project_pipeline( OLD.arc_pipelinedata_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_arc_project_pipeline() OWNER TO xnat;

--
-- Name: after_update_arc_property(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_arc_property() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_arc_property( OLD.arc_property_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_arc_property() OWNER TO xnat;

--
-- Name: after_update_cat_catalog(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_cat_catalog() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_cat_catalog( OLD.cat_catalog_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_cat_catalog() OWNER TO xnat;

--
-- Name: after_update_cat_catalog_metafield(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_cat_catalog_metafield() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_cat_catalog_metaField( OLD.cat_catalog_metafield_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_cat_catalog_metafield() OWNER TO xnat;

--
-- Name: after_update_cat_catalog_tag(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_cat_catalog_tag() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_cat_catalog_tag( OLD.cat_catalog_tag_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_cat_catalog_tag() OWNER TO xnat;

--
-- Name: after_update_cat_dcmcatalog(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_cat_dcmcatalog() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_cat_dcmCatalog( OLD.cat_catalog_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_cat_dcmcatalog() OWNER TO xnat;

--
-- Name: after_update_cat_dcmentry(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_cat_dcmentry() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_cat_dcmEntry( OLD.cat_entry_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_cat_dcmentry() OWNER TO xnat;

--
-- Name: after_update_cat_entry(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_cat_entry() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_cat_entry( OLD.cat_entry_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_cat_entry() OWNER TO xnat;

--
-- Name: after_update_cat_entry_metafield(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_cat_entry_metafield() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_cat_entry_metaField( OLD.cat_entry_metafield_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_cat_entry_metafield() OWNER TO xnat;

--
-- Name: after_update_cat_entry_tag(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_cat_entry_tag() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_cat_entry_tag( OLD.cat_entry_tag_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_cat_entry_tag() OWNER TO xnat;

--
-- Name: after_update_pipe_pipelinedetails(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_pipe_pipelinedetails() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_pipe_pipelineDetails( OLD.path, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_pipe_pipelinedetails() OWNER TO xnat;

--
-- Name: after_update_pipe_pipelinedetails_element(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_pipe_pipelinedetails_element() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_pipe_pipelineDetails_element( OLD.pipe_pipelinedetails_element_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_pipe_pipelinedetails_element() OWNER TO xnat;

--
-- Name: after_update_pipe_pipelinedetails_parameter(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_pipe_pipelinedetails_parameter() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_pipe_pipelineDetails_parameter( OLD.pipe_pipelinedetails_parameter_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_pipe_pipelinedetails_parameter() OWNER TO xnat;

--
-- Name: after_update_pipe_pipelinerepository(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_pipe_pipelinerepository() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_pipe_PipelineRepository( OLD.pipe_pipelinerepository_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_pipe_pipelinerepository() OWNER TO xnat;

--
-- Name: after_update_prov_process(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_prov_process() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_prov_process( OLD.prov_process_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_prov_process() OWNER TO xnat;

--
-- Name: after_update_prov_processstep(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_prov_processstep() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_prov_processStep( OLD.prov_processstep_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_prov_processstep() OWNER TO xnat;

--
-- Name: after_update_prov_processstep_library(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_prov_processstep_library() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_prov_processStep_library( OLD.prov_processstep_library_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_prov_processstep_library() OWNER TO xnat;

--
-- Name: after_update_scr_screeningassessment(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_scr_screeningassessment() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_scr_screeningAssessment( OLD.id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_scr_screeningassessment() OWNER TO xnat;

--
-- Name: after_update_scr_screeningscandata(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_scr_screeningscandata() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_scr_screeningScanData( OLD.scr_screeningscandata_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_scr_screeningscandata() OWNER TO xnat;

--
-- Name: after_update_val_additionalval(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_val_additionalval() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_val_additionalVal( OLD.val_additionalval_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_val_additionalval() OWNER TO xnat;

--
-- Name: after_update_val_protocoldata(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_val_protocoldata() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_val_protocolData( OLD.id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_val_protocoldata() OWNER TO xnat;

--
-- Name: after_update_val_protocoldata_comment(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_val_protocoldata_comment() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_val_protocolData_comment( OLD.val_protocoldata_comment_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_val_protocoldata_comment() OWNER TO xnat;

--
-- Name: after_update_val_protocoldata_condition(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_val_protocoldata_condition() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_val_protocolData_condition( OLD.val_protocoldata_condition_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_val_protocoldata_condition() OWNER TO xnat;

--
-- Name: after_update_val_protocoldata_scan_check(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_val_protocoldata_scan_check() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_val_protocolData_scan_check( OLD.val_protocoldata_scan_check_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_val_protocoldata_scan_check() OWNER TO xnat;

--
-- Name: after_update_val_protocoldata_scan_check_comment(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_val_protocoldata_scan_check_comment() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_val_protocolData_scan_check_comment( OLD.val_protocoldata_scan_check_comment_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_val_protocoldata_scan_check_comment() OWNER TO xnat;

--
-- Name: after_update_val_protocoldata_scan_check_condition(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_val_protocoldata_scan_check_condition() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_val_protocolData_scan_check_condition( OLD.val_protocoldata_scan_check_condition_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_val_protocoldata_scan_check_condition() OWNER TO xnat;

--
-- Name: after_update_wrk_abstractexecutionenvironment(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_wrk_abstractexecutionenvironment() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_wrk_abstractExecutionEnvironment( OLD.wrk_abstractexecutionenvironment_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_wrk_abstractexecutionenvironment() OWNER TO xnat;

--
-- Name: after_update_wrk_workflowdata(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_wrk_workflowdata() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_wrk_workflowData( OLD.wrk_workflowdata_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_wrk_workflowdata() OWNER TO xnat;

--
-- Name: after_update_wrk_xnatexecutionenvironment(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_wrk_xnatexecutionenvironment() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_wrk_xnatExecutionEnvironment( OLD.wrk_abstractexecutionenvironment_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_wrk_xnatexecutionenvironment() OWNER TO xnat;

--
-- Name: after_update_wrk_xnatexecutionenvironment_notify(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_wrk_xnatexecutionenvironment_notify() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_wrk_xnatExecutionEnvironment_notify( OLD.wrk_xnatexecutionenvironment_notify_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_wrk_xnatexecutionenvironment_notify() OWNER TO xnat;

--
-- Name: after_update_wrk_xnatexecutionenvironment_parameter(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_wrk_xnatexecutionenvironment_parameter() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_wrk_xnatExecutionEnvironment_parameter( OLD.wrk_xnatexecutionenvironment_parameter_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_wrk_xnatexecutionenvironment_parameter() OWNER TO xnat;

--
-- Name: after_update_xdat_access_log(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xdat_access_log() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xdat_access_log( OLD.xdat_access_log_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xdat_access_log() OWNER TO xnat;

--
-- Name: after_update_xdat_action_type(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xdat_action_type() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xdat_action_type( OLD.action_name, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xdat_action_type() OWNER TO xnat;

--
-- Name: after_update_xdat_change_info(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xdat_change_info() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xdat_change_info( OLD.xdat_change_info_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xdat_change_info() OWNER TO xnat;

--
-- Name: after_update_xdat_criteria(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xdat_criteria() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xdat_criteria( OLD.xdat_criteria_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xdat_criteria() OWNER TO xnat;

--
-- Name: after_update_xdat_criteria_set(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xdat_criteria_set() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xdat_criteria_set( OLD.xdat_criteria_set_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xdat_criteria_set() OWNER TO xnat;

--
-- Name: after_update_xdat_element_access(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xdat_element_access() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xdat_element_access( OLD.xdat_element_access_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xdat_element_access() OWNER TO xnat;

--
-- Name: after_update_xdat_element_access_secure_ip(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xdat_element_access_secure_ip() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xdat_element_access_secure_ip( OLD.xdat_element_access_secure_ip_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xdat_element_access_secure_ip() OWNER TO xnat;

--
-- Name: after_update_xdat_element_action_type(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xdat_element_action_type() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xdat_element_action_type( OLD.xdat_element_action_type_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xdat_element_action_type() OWNER TO xnat;

--
-- Name: after_update_xdat_element_security(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xdat_element_security() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xdat_element_security( OLD.element_name, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xdat_element_security() OWNER TO xnat;

--
-- Name: after_update_xdat_element_security_listing_action(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xdat_element_security_listing_action() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xdat_element_security_listing_action( OLD.xdat_element_security_listing_action_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xdat_element_security_listing_action() OWNER TO xnat;

--
-- Name: after_update_xdat_field_mapping(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xdat_field_mapping() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xdat_field_mapping( OLD.xdat_field_mapping_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xdat_field_mapping() OWNER TO xnat;

--
-- Name: after_update_xdat_field_mapping_set(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xdat_field_mapping_set() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xdat_field_mapping_set( OLD.xdat_field_mapping_set_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xdat_field_mapping_set() OWNER TO xnat;

--
-- Name: after_update_xdat_infoentry(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xdat_infoentry() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xdat_infoEntry( OLD.xdat_infoentry_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xdat_infoentry() OWNER TO xnat;

--
-- Name: after_update_xdat_meta_element(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xdat_meta_element() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xdat_meta_element( OLD.xdat_meta_element_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xdat_meta_element() OWNER TO xnat;

--
-- Name: after_update_xdat_newsentry(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xdat_newsentry() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xdat_newsEntry( OLD.xdat_newsentry_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xdat_newsentry() OWNER TO xnat;

--
-- Name: after_update_xdat_primary_security_field(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xdat_primary_security_field() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xdat_primary_security_field( OLD.xdat_primary_security_field_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xdat_primary_security_field() OWNER TO xnat;

--
-- Name: after_update_xdat_role_type(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xdat_role_type() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xdat_role_type( OLD.role_name, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xdat_role_type() OWNER TO xnat;

--
-- Name: after_update_xdat_search(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xdat_search() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xdat_Search( OLD.id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xdat_search() OWNER TO xnat;

--
-- Name: after_update_xdat_search_field(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xdat_search_field() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xdat_search_field( OLD.xdat_search_field_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xdat_search_field() OWNER TO xnat;

--
-- Name: after_update_xdat_security(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xdat_security() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xdat_security( OLD.xdat_security_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xdat_security() OWNER TO xnat;

--
-- Name: after_update_xdat_stored_search(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xdat_stored_search() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xdat_stored_search( OLD.id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xdat_stored_search() OWNER TO xnat;

--
-- Name: after_update_xdat_stored_search_allowed_user(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xdat_stored_search_allowed_user() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xdat_stored_search_allowed_user( OLD.xdat_stored_search_allowed_user_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xdat_stored_search_allowed_user() OWNER TO xnat;

--
-- Name: after_update_xdat_stored_search_groupid(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xdat_stored_search_groupid() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xdat_stored_search_groupID( OLD.xdat_stored_search_groupid_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xdat_stored_search_groupid() OWNER TO xnat;

--
-- Name: after_update_xdat_user(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xdat_user() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xdat_user( OLD.xdat_user_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xdat_user() OWNER TO xnat;

--
-- Name: after_update_xdat_user_groupid(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xdat_user_groupid() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xdat_user_groupID( OLD.xdat_user_groupid_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xdat_user_groupid() OWNER TO xnat;

--
-- Name: after_update_xdat_user_login(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xdat_user_login() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xdat_user_login( OLD.xdat_user_login_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xdat_user_login() OWNER TO xnat;

--
-- Name: after_update_xdat_usergroup(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xdat_usergroup() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xdat_userGroup( OLD.xdat_usergroup_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xdat_usergroup() OWNER TO xnat;

--
-- Name: after_update_xnat_a_scidresearchdata(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_a_scidresearchdata() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_a_scidResearchData( OLD.id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_a_scidresearchdata() OWNER TO xnat;

--
-- Name: after_update_xnat_a_sideeffectspittsburghdata(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_a_sideeffectspittsburghdata() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_a_sideEffectsPittsburghData( OLD.id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_a_sideeffectspittsburghdata() OWNER TO xnat;

--
-- Name: after_update_xnat_a_updrs3data(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_a_updrs3data() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_a_updrs3Data( OLD.id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_a_updrs3data() OWNER TO xnat;

--
-- Name: after_update_xnat_a_ybocsdata(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_a_ybocsdata() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_a_ybocsData( OLD.id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_a_ybocsdata() OWNER TO xnat;

--
-- Name: after_update_xnat_a_ygtssdata(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_a_ygtssdata() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_a_ygtssData( OLD.id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_a_ygtssdata() OWNER TO xnat;

--
-- Name: after_update_xnat_abstractdemographicdata(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_abstractdemographicdata() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_abstractDemographicData( OLD.xnat_abstractdemographicdata_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_abstractdemographicdata() OWNER TO xnat;

--
-- Name: after_update_xnat_abstractprotocol(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_abstractprotocol() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_abstractProtocol( OLD.xnat_abstractprotocol_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_abstractprotocol() OWNER TO xnat;

--
-- Name: after_update_xnat_abstractresource(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_abstractresource() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_abstractResource( OLD.xnat_abstractresource_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_abstractresource() OWNER TO xnat;

--
-- Name: after_update_xnat_abstractresource_tag(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_abstractresource_tag() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_abstractResource_tag( OLD.xnat_abstractresource_tag_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_abstractresource_tag() OWNER TO xnat;

--
-- Name: after_update_xnat_abstractstatistics(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_abstractstatistics() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_abstractStatistics( OLD.xnat_abstractstatistics_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_abstractstatistics() OWNER TO xnat;

--
-- Name: after_update_xnat_abstractsubjectmetadata(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_abstractsubjectmetadata() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_abstractSubjectMetadata( OLD.xnat_abstractsubjectmetadata_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_abstractsubjectmetadata() OWNER TO xnat;

--
-- Name: after_update_xnat_addfield(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_addfield() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_addField( OLD.xnat_addfield_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_addfield() OWNER TO xnat;

--
-- Name: after_update_xnat_algorithm(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_algorithm() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_algorithm( OLD.xnat_algorithm_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_algorithm() OWNER TO xnat;

--
-- Name: after_update_xnat_computationdata(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_computationdata() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_computationData( OLD.xnat_computationdata_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_computationdata() OWNER TO xnat;

--
-- Name: after_update_xnat_contrastbolus(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_contrastbolus() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_contrastBolus( OLD.xnat_contrastbolus_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_contrastbolus() OWNER TO xnat;

--
-- Name: after_update_xnat_crscandata(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_crscandata() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_crScanData( OLD.xnat_imagescandata_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_crscandata() OWNER TO xnat;

--
-- Name: after_update_xnat_crsessiondata(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_crsessiondata() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_crSessionData( OLD.id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_crsessiondata() OWNER TO xnat;

--
-- Name: after_update_xnat_ctscandata(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_ctscandata() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_ctScanData( OLD.xnat_imagescandata_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_ctscandata() OWNER TO xnat;

--
-- Name: after_update_xnat_ctscandata_focalspot(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_ctscandata_focalspot() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_ctScanData_focalSpot( OLD.xnat_ctscandata_focalspot_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_ctscandata_focalspot() OWNER TO xnat;

--
-- Name: after_update_xnat_ctsessiondata(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_ctsessiondata() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_ctSessionData( OLD.id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_ctsessiondata() OWNER TO xnat;

--
-- Name: after_update_xnat_datatypeprotocol(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_datatypeprotocol() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_datatypeProtocol( OLD.xnat_abstractprotocol_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_datatypeprotocol() OWNER TO xnat;

--
-- Name: after_update_xnat_demographicdata(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_demographicdata() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_demographicData( OLD.xnat_abstractdemographicdata_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_demographicdata() OWNER TO xnat;

--
-- Name: after_update_xnat_deriveddata(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_deriveddata() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_derivedData( OLD.id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_deriveddata() OWNER TO xnat;

--
-- Name: after_update_xnat_dicomcodedvalue(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_dicomcodedvalue() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_dicomCodedValue( OLD.xnat_dicomcodedvalue_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_dicomcodedvalue() OWNER TO xnat;

--
-- Name: after_update_xnat_dicomseries(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_dicomseries() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_dicomSeries( OLD.xnat_abstractresource_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_dicomseries() OWNER TO xnat;

--
-- Name: after_update_xnat_dicomseries_image(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_dicomseries_image() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_dicomSeries_image( OLD.xnat_dicomseries_image_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_dicomseries_image() OWNER TO xnat;

--
-- Name: after_update_xnat_dx3dcraniofacialscandata(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_dx3dcraniofacialscandata() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_dx3DCraniofacialScanData( OLD.xnat_imagescandata_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_dx3dcraniofacialscandata() OWNER TO xnat;

--
-- Name: after_update_xnat_dx3dcraniofacialsessiondata(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_dx3dcraniofacialsessiondata() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_dx3DCraniofacialSessionData( OLD.id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_dx3dcraniofacialsessiondata() OWNER TO xnat;

--
-- Name: after_update_xnat_dxscandata(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_dxscandata() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_dxScanData( OLD.xnat_imagescandata_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_dxscandata() OWNER TO xnat;

--
-- Name: after_update_xnat_dxsessiondata(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_dxsessiondata() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_dxSessionData( OLD.id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_dxsessiondata() OWNER TO xnat;

--
-- Name: after_update_xnat_ecgscandata(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_ecgscandata() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_ecgScanData( OLD.xnat_imagescandata_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_ecgscandata() OWNER TO xnat;

--
-- Name: after_update_xnat_ecgsessiondata(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_ecgsessiondata() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_ecgSessionData( OLD.id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_ecgsessiondata() OWNER TO xnat;

--
-- Name: after_update_xnat_eegscandata(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_eegscandata() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_eegScanData( OLD.xnat_imagescandata_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_eegscandata() OWNER TO xnat;

--
-- Name: after_update_xnat_eegscandata_channel(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_eegscandata_channel() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_eegScanData_channel( OLD.xnat_eegscandata_channel_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_eegscandata_channel() OWNER TO xnat;

--
-- Name: after_update_xnat_eegscandata_impedance(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_eegscandata_impedance() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_eegScanData_impedance( OLD.xnat_eegscandata_impedance_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_eegscandata_impedance() OWNER TO xnat;

--
-- Name: after_update_xnat_eegsessiondata(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_eegsessiondata() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_eegSessionData( OLD.id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_eegsessiondata() OWNER TO xnat;

--
-- Name: after_update_xnat_epsscandata(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_epsscandata() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_epsScanData( OLD.xnat_imagescandata_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_epsscandata() OWNER TO xnat;

--
-- Name: after_update_xnat_epssessiondata(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_epssessiondata() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_epsSessionData( OLD.id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_epssessiondata() OWNER TO xnat;

--
-- Name: after_update_xnat_esscandata(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_esscandata() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_esScanData( OLD.xnat_imagescandata_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_esscandata() OWNER TO xnat;

--
-- Name: after_update_xnat_essessiondata(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_essessiondata() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_esSessionData( OLD.id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_essessiondata() OWNER TO xnat;

--
-- Name: after_update_xnat_esvscandata(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_esvscandata() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_esvScanData( OLD.xnat_imagescandata_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_esvscandata() OWNER TO xnat;

--
-- Name: after_update_xnat_esvsessiondata(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_esvsessiondata() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_esvSessionData( OLD.id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_esvsessiondata() OWNER TO xnat;

--
-- Name: after_update_xnat_experimentdata(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_experimentdata() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_experimentData( OLD.id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_experimentdata() OWNER TO xnat;

--
-- Name: after_update_xnat_experimentdata_field(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_experimentdata_field() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_experimentData_field( OLD.xnat_experimentdata_field_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_experimentdata_field() OWNER TO xnat;

--
-- Name: after_update_xnat_experimentdata_share(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_experimentdata_share() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_experimentData_share( OLD.xnat_experimentdata_share_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_experimentdata_share() OWNER TO xnat;

--
-- Name: after_update_xnat_fielddefinitiongroup(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_fielddefinitiongroup() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_fieldDefinitionGroup( OLD.xnat_fielddefinitiongroup_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_fielddefinitiongroup() OWNER TO xnat;

--
-- Name: after_update_xnat_fielddefinitiongroup_field(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_fielddefinitiongroup_field() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_fieldDefinitionGroup_field( OLD.xnat_fielddefinitiongroup_field_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_fielddefinitiongroup_field() OWNER TO xnat;

--
-- Name: after_update_xnat_fielddefinitiongroup_field_possiblevalue(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_fielddefinitiongroup_field_possiblevalue() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_fieldDefinitionGroup_field_possibleValue( OLD.xnat_fielddefinitiongroup_field_possiblevalue_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_fielddefinitiongroup_field_possiblevalue() OWNER TO xnat;

--
-- Name: after_update_xnat_genericdata(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_genericdata() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_genericData( OLD.id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_genericdata() OWNER TO xnat;

--
-- Name: after_update_xnat_gmscandata(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_gmscandata() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_gmScanData( OLD.xnat_imagescandata_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_gmscandata() OWNER TO xnat;

--
-- Name: after_update_xnat_gmsessiondata(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_gmsessiondata() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_gmSessionData( OLD.id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_gmsessiondata() OWNER TO xnat;

--
-- Name: after_update_xnat_gmvscandata(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_gmvscandata() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_gmvScanData( OLD.xnat_imagescandata_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_gmvscandata() OWNER TO xnat;

--
-- Name: after_update_xnat_gmvsessiondata(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_gmvsessiondata() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_gmvSessionData( OLD.id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_gmvsessiondata() OWNER TO xnat;

--
-- Name: after_update_xnat_hdscandata(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_hdscandata() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_hdScanData( OLD.xnat_imagescandata_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_hdscandata() OWNER TO xnat;

--
-- Name: after_update_xnat_hdsessiondata(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_hdsessiondata() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_hdSessionData( OLD.id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_hdsessiondata() OWNER TO xnat;

--
-- Name: after_update_xnat_imageassessordata(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_imageassessordata() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_imageAssessorData( OLD.id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_imageassessordata() OWNER TO xnat;

--
-- Name: after_update_xnat_imageresource(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_imageresource() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_imageResource( OLD.xnat_abstractresource_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_imageresource() OWNER TO xnat;

--
-- Name: after_update_xnat_imageresourceseries(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_imageresourceseries() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_imageResourceSeries( OLD.xnat_abstractresource_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_imageresourceseries() OWNER TO xnat;

--
-- Name: after_update_xnat_imagescandata(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_imagescandata() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_imageScanData( OLD.xnat_imagescandata_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_imagescandata() OWNER TO xnat;

--
-- Name: after_update_xnat_imagescandata_share(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_imagescandata_share() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_imageScanData_share( OLD.xnat_imagescandata_share_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_imagescandata_share() OWNER TO xnat;

--
-- Name: after_update_xnat_imagesessiondata(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_imagesessiondata() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_imageSessionData( OLD.id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_imagesessiondata() OWNER TO xnat;

--
-- Name: after_update_xnat_investigatordata(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_investigatordata() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_investigatorData( OLD.xnat_investigatordata_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_investigatordata() OWNER TO xnat;

--
-- Name: after_update_xnat_ioscandata(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_ioscandata() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_ioScanData( OLD.xnat_imagescandata_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_ioscandata() OWNER TO xnat;

--
-- Name: after_update_xnat_iosessiondata(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_iosessiondata() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_ioSessionData( OLD.id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_iosessiondata() OWNER TO xnat;

--
-- Name: after_update_xnat_megscandata(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_megscandata() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_megScanData( OLD.xnat_imagescandata_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_megscandata() OWNER TO xnat;

--
-- Name: after_update_xnat_megsessiondata(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_megsessiondata() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_megSessionData( OLD.id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_megsessiondata() OWNER TO xnat;

--
-- Name: after_update_xnat_mgscandata(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_mgscandata() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_mgScanData( OLD.xnat_imagescandata_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_mgscandata() OWNER TO xnat;

--
-- Name: after_update_xnat_mgsessiondata(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_mgsessiondata() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_mgSessionData( OLD.id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_mgsessiondata() OWNER TO xnat;

--
-- Name: after_update_xnat_mrassessordata(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_mrassessordata() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_mrAssessorData( OLD.id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_mrassessordata() OWNER TO xnat;

--
-- Name: after_update_xnat_mrqcscandata(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_mrqcscandata() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_mrQcScanData( OLD.xnat_qcscandata_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_mrqcscandata() OWNER TO xnat;

--
-- Name: after_update_xnat_mrscandata(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_mrscandata() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_mrScanData( OLD.xnat_imagescandata_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_mrscandata() OWNER TO xnat;

--
-- Name: after_update_xnat_mrsessiondata(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_mrsessiondata() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_mrSessionData( OLD.id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_mrsessiondata() OWNER TO xnat;

--
-- Name: after_update_xnat_mrsscandata(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_mrsscandata() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_mrsScanData( OLD.xnat_imagescandata_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_mrsscandata() OWNER TO xnat;

--
-- Name: after_update_xnat_nmscandata(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_nmscandata() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_nmScanData( OLD.xnat_imagescandata_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_nmscandata() OWNER TO xnat;

--
-- Name: after_update_xnat_nmsessiondata(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_nmsessiondata() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_nmSessionData( OLD.id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_nmsessiondata() OWNER TO xnat;

--
-- Name: after_update_xnat_opscandata(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_opscandata() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_opScanData( OLD.xnat_imagescandata_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_opscandata() OWNER TO xnat;

--
-- Name: after_update_xnat_opsessiondata(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_opsessiondata() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_opSessionData( OLD.id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_opsessiondata() OWNER TO xnat;

--
-- Name: after_update_xnat_optscandata(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_optscandata() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_optScanData( OLD.xnat_imagescandata_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_optscandata() OWNER TO xnat;

--
-- Name: after_update_xnat_optsessiondata(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_optsessiondata() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_optSessionData( OLD.id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_optsessiondata() OWNER TO xnat;

--
-- Name: after_update_xnat_otherdicomscandata(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_otherdicomscandata() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_otherDicomScanData( OLD.xnat_imagescandata_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_otherdicomscandata() OWNER TO xnat;

--
-- Name: after_update_xnat_otherdicomsessiondata(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_otherdicomsessiondata() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_otherDicomSessionData( OLD.id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_otherdicomsessiondata() OWNER TO xnat;

--
-- Name: after_update_xnat_otherqcscandata(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_otherqcscandata() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_otherQcScanData( OLD.xnat_qcscandata_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_otherqcscandata() OWNER TO xnat;

--
-- Name: after_update_xnat_petassessordata(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_petassessordata() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_petAssessorData( OLD.id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_petassessordata() OWNER TO xnat;

--
-- Name: after_update_xnat_petmrsessiondata(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_petmrsessiondata() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_petmrSessionData( OLD.id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_petmrsessiondata() OWNER TO xnat;

--
-- Name: after_update_xnat_petqcscandata(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_petqcscandata() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_petQcScanData( OLD.xnat_qcscandata_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_petqcscandata() OWNER TO xnat;

--
-- Name: after_update_xnat_petqcscandata_processingerror(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_petqcscandata_processingerror() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_petQcScanData_processingError( OLD.xnat_petqcscandata_processingerror_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_petqcscandata_processingerror() OWNER TO xnat;

--
-- Name: after_update_xnat_petscandata(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_petscandata() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_petScanData( OLD.xnat_imagescandata_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_petscandata() OWNER TO xnat;

--
-- Name: after_update_xnat_petscandata_frame(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_petscandata_frame() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_petScanData_frame( OLD.xnat_petscandata_frame_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_petscandata_frame() OWNER TO xnat;

--
-- Name: after_update_xnat_petsessiondata(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_petsessiondata() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_petSessionData( OLD.id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_petsessiondata() OWNER TO xnat;

--
-- Name: after_update_xnat_projectdata(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_projectdata() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_projectData( OLD.id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_projectdata() OWNER TO xnat;

--
-- Name: after_update_xnat_projectdata_alias(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_projectdata_alias() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_projectData_alias( OLD.xnat_projectdata_alias_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_projectdata_alias() OWNER TO xnat;

--
-- Name: after_update_xnat_projectdata_field(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_projectdata_field() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_projectData_field( OLD.xnat_projectdata_field_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_projectdata_field() OWNER TO xnat;

--
-- Name: after_update_xnat_projectparticipant(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_projectparticipant() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_projectParticipant( OLD.xnat_projectparticipant_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_projectparticipant() OWNER TO xnat;

--
-- Name: after_update_xnat_publicationresource(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_publicationresource() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_publicationResource( OLD.xnat_abstractresource_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_publicationresource() OWNER TO xnat;

--
-- Name: after_update_xnat_pvisitdata(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_pvisitdata() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_pVisitData( OLD.id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_pvisitdata() OWNER TO xnat;

--
-- Name: after_update_xnat_qcassessmentdata(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_qcassessmentdata() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_qcAssessmentData( OLD.id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_qcassessmentdata() OWNER TO xnat;

--
-- Name: after_update_xnat_qcassessmentdata_scan(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_qcassessmentdata_scan() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_qcAssessmentData_scan( OLD.xnat_qcassessmentdata_scan_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_qcassessmentdata_scan() OWNER TO xnat;

--
-- Name: after_update_xnat_qcassessmentdata_scan_slice(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_qcassessmentdata_scan_slice() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_qcAssessmentData_scan_slice( OLD.xnat_qcassessmentdata_scan_slice_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_qcassessmentdata_scan_slice() OWNER TO xnat;

--
-- Name: after_update_xnat_qcmanualassessordata(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_qcmanualassessordata() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_qcManualAssessorData( OLD.id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_qcmanualassessordata() OWNER TO xnat;

--
-- Name: after_update_xnat_qcscandata(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_qcscandata() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_qcScanData( OLD.xnat_qcscandata_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_qcscandata() OWNER TO xnat;

--
-- Name: after_update_xnat_qcscandata_field(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_qcscandata_field() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_qcScanData_field( OLD.xnat_qcscandata_field_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_qcscandata_field() OWNER TO xnat;

--
-- Name: after_update_xnat_reconstructedimagedata(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_reconstructedimagedata() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_reconstructedImageData( OLD.xnat_reconstructedimagedata_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_reconstructedimagedata() OWNER TO xnat;

--
-- Name: after_update_xnat_reconstructedimagedata_scanid(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_reconstructedimagedata_scanid() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_reconstructedImageData_scanID( OLD.xnat_reconstructedimagedata_scanid_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_reconstructedimagedata_scanid() OWNER TO xnat;

--
-- Name: after_update_xnat_regionresource(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_regionresource() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_regionResource( OLD.xnat_regionresource_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_regionresource() OWNER TO xnat;

--
-- Name: after_update_xnat_regionresource_label(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_regionresource_label() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_regionResource_label( OLD.xnat_regionresource_label_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_regionresource_label() OWNER TO xnat;

--
-- Name: after_update_xnat_resource(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_resource() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_resource( OLD.xnat_abstractresource_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_resource() OWNER TO xnat;

--
-- Name: after_update_xnat_resourcecatalog(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_resourcecatalog() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_resourceCatalog( OLD.xnat_abstractresource_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_resourcecatalog() OWNER TO xnat;

--
-- Name: after_update_xnat_resourceseries(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_resourceseries() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_resourceSeries( OLD.xnat_abstractresource_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_resourceseries() OWNER TO xnat;

--
-- Name: after_update_xnat_rfscandata(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_rfscandata() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_rfScanData( OLD.xnat_imagescandata_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_rfscandata() OWNER TO xnat;

--
-- Name: after_update_xnat_rfsessiondata(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_rfsessiondata() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_rfSessionData( OLD.id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_rfsessiondata() OWNER TO xnat;

--
-- Name: after_update_xnat_rtimagescandata(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_rtimagescandata() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_rtImageScanData( OLD.xnat_imagescandata_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_rtimagescandata() OWNER TO xnat;

--
-- Name: after_update_xnat_rtsessiondata(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_rtsessiondata() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_rtSessionData( OLD.id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_rtsessiondata() OWNER TO xnat;

--
-- Name: after_update_xnat_scscandata(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_scscandata() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_scScanData( OLD.xnat_imagescandata_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_scscandata() OWNER TO xnat;

--
-- Name: after_update_xnat_segscandata(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_segscandata() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_segScanData( OLD.xnat_imagescandata_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_segscandata() OWNER TO xnat;

--
-- Name: after_update_xnat_smscandata(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_smscandata() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_smScanData( OLD.xnat_imagescandata_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_smscandata() OWNER TO xnat;

--
-- Name: after_update_xnat_smsessiondata(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_smsessiondata() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_smSessionData( OLD.id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_smsessiondata() OWNER TO xnat;

--
-- Name: after_update_xnat_srscandata(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_srscandata() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_srScanData( OLD.xnat_imagescandata_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_srscandata() OWNER TO xnat;

--
-- Name: after_update_xnat_srsessiondata(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_srsessiondata() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_srSessionData( OLD.id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_srsessiondata() OWNER TO xnat;

--
-- Name: after_update_xnat_statisticsdata(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_statisticsdata() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_statisticsData( OLD.xnat_abstractstatistics_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_statisticsdata() OWNER TO xnat;

--
-- Name: after_update_xnat_statisticsdata_addfield(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_statisticsdata_addfield() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_statisticsData_addField( OLD.xnat_statisticsdata_addfield_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_statisticsdata_addfield() OWNER TO xnat;

--
-- Name: after_update_xnat_statisticsdata_additionalstatistics(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_statisticsdata_additionalstatistics() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_statisticsData_additionalStatistics( OLD.xnat_statisticsdata_additionalstatistics_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_statisticsdata_additionalstatistics() OWNER TO xnat;

--
-- Name: after_update_xnat_studyprotocol(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_studyprotocol() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_studyProtocol( OLD.xnat_abstractprotocol_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_studyprotocol() OWNER TO xnat;

--
-- Name: after_update_xnat_studyprotocol_condition(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_studyprotocol_condition() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_studyProtocol_condition( OLD.xnat_studyprotocol_condition_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_studyprotocol_condition() OWNER TO xnat;

--
-- Name: after_update_xnat_studyprotocol_group(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_studyprotocol_group() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_studyProtocol_group( OLD.xnat_studyprotocol_group_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_studyprotocol_group() OWNER TO xnat;

--
-- Name: after_update_xnat_studyprotocol_session(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_studyprotocol_session() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_studyProtocol_session( OLD.xnat_studyprotocol_session_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_studyprotocol_session() OWNER TO xnat;

--
-- Name: after_update_xnat_studyprotocol_variable(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_studyprotocol_variable() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_studyProtocol_variable( OLD.xnat_studyprotocol_variable_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_studyprotocol_variable() OWNER TO xnat;

--
-- Name: after_update_xnat_subjectassessordata(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_subjectassessordata() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_subjectAssessorData( OLD.id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_subjectassessordata() OWNER TO xnat;

--
-- Name: after_update_xnat_subjectdata(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_subjectdata() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_subjectData( OLD.id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_subjectdata() OWNER TO xnat;

--
-- Name: after_update_xnat_subjectdata_addid(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_subjectdata_addid() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_subjectData_addID( OLD.xnat_subjectdata_addid_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_subjectdata_addid() OWNER TO xnat;

--
-- Name: after_update_xnat_subjectdata_field(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_subjectdata_field() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_subjectData_field( OLD.xnat_subjectdata_field_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_subjectdata_field() OWNER TO xnat;

--
-- Name: after_update_xnat_subjectmetadata(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_subjectmetadata() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_subjectMetadata( OLD.xnat_abstractsubjectmetadata_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_subjectmetadata() OWNER TO xnat;

--
-- Name: after_update_xnat_subjectvariablesdata(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_subjectvariablesdata() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_subjectVariablesData( OLD.id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_subjectvariablesdata() OWNER TO xnat;

--
-- Name: after_update_xnat_subjectvariablesdata_variable(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_subjectvariablesdata_variable() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_subjectVariablesData_variable( OLD.xnat_subjectvariablesdata_variable_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_subjectvariablesdata_variable() OWNER TO xnat;

--
-- Name: after_update_xnat_usscandata(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_usscandata() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_usScanData( OLD.xnat_imagescandata_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_usscandata() OWNER TO xnat;

--
-- Name: after_update_xnat_ussessiondata(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_ussessiondata() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_usSessionData( OLD.id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_ussessiondata() OWNER TO xnat;

--
-- Name: after_update_xnat_validationdata(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_validationdata() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_validationData( OLD.xnat_validationdata_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_validationdata() OWNER TO xnat;

--
-- Name: after_update_xnat_voiceaudioscandata(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_voiceaudioscandata() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_voiceAudioScanData( OLD.xnat_imagescandata_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_voiceaudioscandata() OWNER TO xnat;

--
-- Name: after_update_xnat_volumetricregion(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_volumetricregion() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_volumetricRegion( OLD.xnat_volumetricregion_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_volumetricregion() OWNER TO xnat;

--
-- Name: after_update_xnat_volumetricregion_subregion(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_volumetricregion_subregion() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_volumetricRegion_subregion( OLD.xnat_volumetricregion_subregion_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_volumetricregion_subregion() OWNER TO xnat;

--
-- Name: after_update_xnat_xa3dscandata(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_xa3dscandata() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_xa3DScanData( OLD.xnat_imagescandata_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_xa3dscandata() OWNER TO xnat;

--
-- Name: after_update_xnat_xa3dsessiondata(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_xa3dsessiondata() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_xa3DSessionData( OLD.id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_xa3dsessiondata() OWNER TO xnat;

--
-- Name: after_update_xnat_xascandata(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_xascandata() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_xaScanData( OLD.xnat_imagescandata_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_xascandata() OWNER TO xnat;

--
-- Name: after_update_xnat_xasessiondata(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_xasessiondata() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_xaSessionData( OLD.id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_xasessiondata() OWNER TO xnat;

--
-- Name: after_update_xnat_xcscandata(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_xcscandata() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_xcScanData( OLD.xnat_imagescandata_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_xcscandata() OWNER TO xnat;

--
-- Name: after_update_xnat_xcsessiondata(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_xcsessiondata() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_xcSessionData( OLD.id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_xcsessiondata() OWNER TO xnat;

--
-- Name: after_update_xnat_xcvscandata(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_xcvscandata() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_xcvScanData( OLD.xnat_imagescandata_id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_xcvscandata() OWNER TO xnat;

--
-- Name: after_update_xnat_xcvsessiondata(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.after_update_xnat_xcvsessiondata() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    begin
--       PERFORM update_ls_xnat_xcvSessionData( OLD.id, NULL);
	
	    RETURN NULL;
    end;
$$;


ALTER FUNCTION public.after_update_xnat_xcvsessiondata() OWNER TO xnat;

--
-- Name: class_exists(character varying); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.class_exists(character varying) RETURNS boolean
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
    begin
      FOR current_row IN SELECT * FROM pg_catalog.pg_class WHERE  relname=LOWER($1)
     LOOP
          RETURN TRUE;
      END LOOP;

	 RETURN FALSE;
    end;
$_$;


ALTER FUNCTION public.class_exists(character varying) OWNER TO xnat;

--
-- Name: create_class2(character varying, character varying); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.create_class2(character varying, character varying) RETURNS void
    LANGUAGE plpgsql
    AS $_$
    begin
	IF(NOT CLASS_EXISTS($1)) THEN
		EXECUTE $2;
		RETURN;
	END IF;
	RETURN;
    end;
$_$;


ALTER FUNCTION public.create_class2(character varying, character varying) OWNER TO xnat;

--
-- Name: create_function2(character varying, character varying); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.create_function2(character varying, character varying) RETURNS void
    LANGUAGE plpgsql
    AS $_$
    begin
	IF(NOT FUNCTION_EXISTS($1)) THEN
		EXECUTE $2;
		RETURN ;
	END IF;

	RETURN ;
    end;
$_$;


ALTER FUNCTION public.create_function2(character varying, character varying) OWNER TO xnat;

--
-- Name: create_new_data_type_permissions(character varying); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.create_new_data_type_permissions(elementname character varying) RETURNS boolean
    LANGUAGE plpgsql
    AS $$
DECLARE
  has_public_projects BOOLEAN;
BEGIN
  INSERT INTO xdat_element_access (element_name, xdat_usergroup_xdat_usergroup_id)
  SELECT elementName AS element_name, xdat_usergroup_id
  FROM
    xdat_usergroup g
    LEFT JOIN xdat_element_access a ON g.xdat_usergroup_id = a.xdat_usergroup_xdat_usergroup_id AND a.element_name = elementName
  WHERE
    a.element_name IS NULL AND
    (g.tag IS NOT NULL OR id = 'ALL_DATA_ADMIN' OR id = 'ALL_DATA_ACCESS');

  INSERT INTO xdat_field_mapping_set (method, permissions_allow_set_xdat_elem_xdat_element_access_id)
  SELECT 'OR' AS method, xdat_element_access_id
  FROM
    xdat_element_access a
    LEFT JOIN xdat_field_mapping_set s ON a.xdat_element_access_id = s.permissions_allow_set_xdat_elem_xdat_element_access_id
  WHERE
    a.element_name = elementName AND
    s.method IS NULL;

  INSERT INTO xdat_field_mapping (field_value, field, create_element, read_element, edit_element, delete_element, active_element, comparison_type, xdat_field_mapping_set_xdat_field_mapping_set_id)
  SELECT field_value, field, CASE WHEN is_shared THEN create_shared ELSE create_element END AS create_element, CASE WHEN is_shared THEN read_shared ELSE read_element END AS read_element, CASE WHEN is_shared THEN edit_shared ELSE edit_element END AS edit_element, CASE WHEN is_shared THEN delete_shared ELSE delete_element END AS delete_element, CASE WHEN is_shared THEN active_shared ELSE active_element END AS active_element, comparison_type, xdat_field_mapping_set_id
  FROM
    (WITH
        group_permissions AS (SELECT groupNameOrId, create_element, read_element, edit_element, delete_element, active_element, create_shared, read_shared, edit_shared, delete_shared, active_shared
                              FROM
                                (VALUES
                                   ('Owners', 1, 1, 1, 1, 1, 0, 1, 0, 0, 1),
                                   ('Members', 1, 1, 1, 0, 0, 0, 1, 0, 0, 0),
                                   ('Collaborators', 0, 1, 0, 0, 0, 0, 1, 0, 0, 0),
                                   ('ALL_DATA_ADMIN', 1, 1, 1, 1, 1, 1, 1, 1, 1, 1),
                                   ('ALL_DATA_ACCESS', 0, 1, 0, 0, 1, 0, 1, 0, 0, 1)) AS groupNames (groupNameOrId, create_element, read_element, edit_element, delete_element, active_element, create_shared, read_shared, edit_shared, delete_shared, active_shared))
    SELECT f.primary_security_field AS field, f.primary_security_field LIKE '%/sharing/share/project' AS is_shared, coalesce(g.tag, '*') AS field_value, p.create_element AS create_element, p.read_element AS read_element, p.edit_element AS edit_element, p.delete_element AS delete_element, p.active_element AS active_element, p.create_shared AS create_shared, p.read_shared AS read_shared, p.edit_shared AS edit_shared, p.delete_shared AS delete_shared, p.active_shared AS active_shared, 'equals' AS comparison_type, s.xdat_field_mapping_set_id AS xdat_field_mapping_set_id
    FROM
      group_permissions p,
      xdat_usergroup g
      LEFT JOIN xdat_element_access a ON g.xdat_usergroup_id = a.xdat_usergroup_xdat_usergroup_id AND a.element_name = elementName
      LEFT JOIN xdat_field_mapping_set s ON a.xdat_element_access_id = s.permissions_allow_set_xdat_elem_xdat_element_access_id
      LEFT JOIN xdat_field_mapping m ON s.xdat_field_mapping_set_id = m.xdat_field_mapping_set_xdat_field_mapping_set_id
      LEFT JOIN xdat_primary_security_field f ON a.element_name = f.primary_security_fields_primary_element_name
    WHERE
      groupNameOrId IN (g.displayname, g.id) AND
      m.field IS NULL AND
      (g.tag IS NOT NULL OR g.id IN ('ALL_DATA_ADMIN', 'ALL_DATA_ACCESS'))) m;

  SELECT count(*) > 0 INTO has_public_projects
  FROM
    project_access
  WHERE
    accessibility = 'public';

  IF has_public_projects
  THEN
    PERFORM create_public_element_access_for_data_type(elementName);
  END IF;
  RETURN TRUE;
END
$$;


ALTER FUNCTION public.create_new_data_type_permissions(elementname character varying) OWNER TO xnat;

--
-- Name: create_new_data_type_security(character varying, character varying, character varying, character varying); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.create_new_data_type_security(elementname character varying, singulardesc character varying, pluraldesc character varying, codedesc character varying) RETURNS character varying
    LANGUAGE plpgsql
    AS $$
BEGIN
  INSERT INTO xdat_element_security (element_name, singular, plural, code, secondary_password, secure_ip, secure, browse, sequence, quarantine, pre_load, searchable, secure_read, secure_edit, secure_create, secure_delete, accessible, usage, category, element_security_set_element_se_xdat_security_id)
  SELECT elementName, singularDesc, pluralDesc, codeDesc, secondary_password, secure_ip, secure, browse, sequence, quarantine, pre_load, searchable, secure_read, secure_edit, secure_create, secure_delete, accessible, usage, category, element_security_set_element_se_xdat_security_id
  FROM
    xdat_element_security
  WHERE
    element_name = 'xnat:mrSessionData';
  INSERT INTO xdat_primary_security_field (primary_security_field, primary_security_fields_primary_element_name)
  VALUES
    (elementName || '/project', elementName);
  INSERT INTO xdat_primary_security_field (primary_security_field, primary_security_fields_primary_element_name)
  VALUES
    (elementName || '/sharing/share/project', elementName);
  RETURN elementName;
END
$$;


ALTER FUNCTION public.create_new_data_type_security(elementname character varying, singulardesc character varying, pluraldesc character varying, codedesc character varying) OWNER TO xnat;

--
-- Name: create_public_element_access_for_data_type(character varying); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.create_public_element_access_for_data_type(elementname character varying) RETURNS boolean
    LANGUAGE plpgsql
    AS $$
BEGIN
  -- Creates new element access entry for the element associated with the guest user.
  INSERT INTO xdat_element_access (element_name, xdat_user_xdat_user_id)
  SELECT elementName AS element_name, u.xdat_user_id
  FROM
    xdat_user u
    LEFT JOIN xdat_element_access a ON u.xdat_user_id = a.xdat_user_xdat_user_id AND a.element_name = elementName
  WHERE
    a.element_name IS NULL AND
    u.login = 'guest';

  -- Creates a new field mapping set associated with the element access entry created above.
  -- The SELECT query finds the element access entry ID by searching for the entry with the
  -- correct element name but no associated field mapping set.
  INSERT INTO xdat_field_mapping_set (method, permissions_allow_set_xdat_elem_xdat_element_access_id)
  SELECT 'OR' AS method, a.xdat_element_access_id
  FROM
    xdat_element_access a
    LEFT JOIN xdat_field_mapping_set s ON a.xdat_element_access_id = s.permissions_allow_set_xdat_elem_xdat_element_access_id
  WHERE
    a.element_name = elementName AND
    s.method IS NULL;

  -- Create the field mapping entries associated with the field mapping set created above. The WITH query
  -- returns the project ID of all public projects on the system. The SELECT query finds the field mapping
  -- set associated with the element access entry by data type and association with the guest user. It then
  -- generates an entry for each public project and primary security field for the data type.
  INSERT INTO xdat_field_mapping (field, field_value, create_element, read_element, edit_element, delete_element, active_element, comparison_type, xdat_field_mapping_set_xdat_field_mapping_set_id)
  WITH
    public_projects AS (SELECT id AS project
                        FROM
                          project_access
                        WHERE
                          accessibility = 'public')
  SELECT f.primary_security_field, p.project, 0, 1, 0, 0, 1, 'equals', s.xdat_field_mapping_set_id
  FROM
    public_projects p,
    xdat_element_access a
    LEFT JOIN xdat_field_mapping_set s ON a.xdat_element_access_id = s.permissions_allow_set_xdat_elem_xdat_element_access_id
    LEFT JOIN xdat_user u ON a.xdat_user_xdat_user_id = u.xdat_user_id
    LEFT JOIN xdat_primary_security_field f ON a.element_name = f.primary_security_fields_primary_element_name
  WHERE
    a.element_name = elementName AND
    u.login = 'guest';

  RETURN TRUE;
END
$$;


ALTER FUNCTION public.create_public_element_access_for_data_type(elementname character varying) OWNER TO xnat;

--
-- Name: create_schema2(character varying, character varying); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.create_schema2(character varying, character varying) RETURNS void
    LANGUAGE plpgsql
    AS $_$
    begin
	IF(NOT SCHEMA_EXISTS($1)) THEN
		EXECUTE $2;
		RETURN ;
	END IF;
	RETURN ;
    end;
$_$;


ALTER FUNCTION public.create_schema2(character varying, character varying) OWNER TO xnat;

--
-- Name: create_trigger2(character varying, character varying); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.create_trigger2(character varying, character varying) RETURNS void
    LANGUAGE plpgsql
    AS $_$
    begin
	IF(NOT TRIGGER_EXISTS($1)) THEN
		EXECUTE $2;
		RETURN;
	END IF;
	RETURN;
    end;
$_$;


ALTER FUNCTION public.create_trigger2(character varying, character varying) OWNER TO xnat;

--
-- Name: fix_mismatched_data_type_permissions(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.fix_mismatched_data_type_permissions() RETURNS boolean
    LANGUAGE plpgsql
    AS $$
DECLARE
  has_mismatches BOOLEAN;
  has_missing    BOOLEAN;
  data_type      VARCHAR(255);
BEGIN
    SELECT count(*) > 0 INTO has_mismatches FROM data_type_views_mismatched_mapping_elements;
    SELECT count(*) > 0 INTO has_missing FROM data_type_views_missing_mapping_elements;
    IF has_mismatches OR has_missing THEN
      DELETE FROM xdat_field_mapping WHERE xdat_field_mapping_id IN (SELECT id FROM data_type_views_mismatched_mapping_elements);
      DELETE FROM xdat_field_mapping_set WHERE xdat_field_mapping_set_id IN (SELECT id FROM data_type_views_orphaned_field_sets);
      FOR data_type IN SELECT DISTINCT primary_security_fields_primary_element_name AS data_type FROM xdat_primary_security_field WHERE primary_security_fields_primary_element_name NOT IN (SELECT DISTINCT element_name FROM xdat_element_access)
    LOOP
      PERFORM create_new_data_type_permissions(data_type);
    END LOOP;
  END IF;
    RETURN has_mismatches OR has_missing;
END
$$;


ALTER FUNCTION public.fix_mismatched_data_type_permissions() OWNER TO xnat;

--
-- Name: fix_missing_public_element_access_mappings(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.fix_missing_public_element_access_mappings() RETURNS boolean
    LANGUAGE plpgsql
    AS $$
DECLARE
  has_missing_mappings BOOLEAN;
BEGIN
  SELECT count(*) > 0 INTO has_missing_mappings
  FROM
    data_type_views_missing_mapping_elements;
  IF has_missing_mappings
  THEN
    INSERT INTO xdat_field_mapping (field, field_value, create_element, read_element, edit_element, delete_element, active_element, comparison_type, xdat_field_mapping_set_xdat_field_mapping_set_id)
    SELECT e.field, e.field_value, 0, 1, 0, 0, 1, 'equals', e.xdat_field_mapping_set_id
    FROM
      data_type_views_missing_mapping_elements e
    WHERE
      e.field_value IS NOT NULL
    UNION
    SELECT e.field, a.id, 0, 1, 0, 0, 1, 'equals', e.xdat_field_mapping_set_id
    FROM
      data_type_views_missing_mapping_elements e,
      project_access a
    WHERE
      e.field_value IS NULL AND
      a.accessibility = 'public';
  END IF;
  RETURN has_missing_mappings;
END
$$;


ALTER FUNCTION public.fix_missing_public_element_access_mappings() OWNER TO xnat;

--
-- Name: function_exists(character varying); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.function_exists(character varying) RETURNS boolean
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
    begin
      FOR current_row IN SELECT * FROM pg_proc WHERE  proname=LOWER($1)
     LOOP
          RETURN TRUE;
      END LOOP;

	 RETURN FALSE;
    end;
$_$;


ALTER FUNCTION public.function_exists(character varying) OWNER TO xnat;

--
-- Name: getnextview(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.getnextview() RETURNS name
    LANGUAGE plpgsql
    AS $$ DECLARE   my_record RECORD;  viewName name; 
BEGIN  FOR my_record IN SELECT c.relname FROM pg_catalog.pg_class AS c LEFT JOIN pg_catalog.pg_namespace AS n ON n.oid = c.relnamespace
WHERE     c.relkind IN ('v') AND n.nspname NOT IN ('pg_catalog', 'pg_toast') AND pg_catalog.pg_table_is_visible(c.oid) LIMIT 1
LOOP   viewName := my_record.relname;  END LOOP;  RETURN (viewName); END; $$;


ALTER FUNCTION public.getnextview() OWNER TO xnat;

--
-- Name: getsortedstring(character varying, integer); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.getsortedstring(character varying, integer) RETURNS public.sortedstrings
    LANGUAGE plpgsql
    AS $_$DECLARE  sorted_strings sortedStrings%ROWTYPE; 
BEGIN  sorted_strings.strings:=$1;  sorted_strings.sort_order:=$2;  return sorted_strings; END;$_$;


ALTER FUNCTION public.getsortedstring(character varying, integer) OWNER TO xnat;

--
-- Name: i_arc_archivespecification(integer, integer, boolean, boolean, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.i_arc_archivespecification(integer, integer, boolean, boolean, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     tempText TEXT;
     fullText TEXT;
     row_ct int4;
     local_count int4;
     child_count int4;
    begin
  --    72
      local_count := $2;
      child_count := $2;
      row_ct := 0;
      fullText := 'Item:(' || local_count || '(arc:ArchiveSpecification)(';
      FOR current_row IN SELECT * FROM arc_ArchiveSpecification WHERE  arc_archivespecification_id=$1
      LOOP
           row_ct := row_ct+1;
          
        IF ((current_row.globalpaths_arc_pathinfo_id IS NOT NULL)) THEN
            fullText := fullText || '(globalpaths_arc_pathinfo_id:integer)=(' || current_row.globalpaths_arc_pathinfo_id || ')';
 -- 693
           child_count := child_count+1;
           tempText := NULL;
           tempText := i_arc_pathInfo(current_row.globalpaths_arc_pathinfo_id, child_count,$3,false,false);
              fullText := fullText || '(globalpaths_pathinfo:XFTItem)=(' || tempText || ')';
        END IF;
        IF($3) THEN 
        DECLARE 
  --    198
        parent_row RECORD; 
        loop_count int4:=0; 
        BEGIN 
        FOR parent_row IN SELECT * FROM arc_fieldSpecification WHERE fieldspecifications_fieldspecif_arc_archivespecification_id=current_row.arc_archivespecification_id ORDER BY arc_fieldspecification_id
        LOOP
           child_count := child_count+1;
           tempText := NULL;
           tempText := i_arc_fieldSpecification( parent_row.arc_fieldspecification_id, child_count,$3,false,false);
              fullText := fullText || '(fieldspecifications_fieldspecification_fieldspecification' || loop_count || ':XFTItem)=';
              fullText := fullText || '(' || tempText || ')';
              loop_count := loop_count+1;
        END LOOP;
        END;
        END IF; 
        IF($3) THEN 
        DECLARE 
  --    198
        parent_row RECORD; 
        loop_count int4:=0; 
        BEGIN 
        FOR parent_row IN SELECT * FROM arc_project WHERE projects_project_arc_ArchiveSpe_arc_archivespecification_id=current_row.arc_archivespecification_id ORDER BY arc_project_id
        LOOP
           child_count := child_count+1;
           tempText := NULL;
           tempText := i_arc_project( parent_row.arc_project_id, child_count,$3,false,false);
              fullText := fullText || '(projects_project_project' || loop_count || ':XFTItem)=';
              fullText := fullText || '(' || tempText || ')';
              loop_count := loop_count+1;
        END LOOP;
        END;
        END IF; 
          IF (current_row.emailspecifications_new_user_registration IS NOT NULL) THEN 
              fullText := fullText || '(emailspecifications_new_user_registration:integer)=(' || current_row.emailspecifications_new_user_registration || ')';
          END IF;
          IF (current_row.emailspecifications_pipeline IS NOT NULL) THEN 
              fullText := fullText || '(emailspecifications_pipeline:integer)=(' || current_row.emailspecifications_pipeline || ')';
          END IF;
          IF (current_row.emailspecifications_project_access IS NOT NULL) THEN 
              fullText := fullText || '(emailspecifications_project_access:integer)=(' || current_row.emailspecifications_project_access || ')';
          END IF;
          IF (current_row.emailspecifications_transfer IS NOT NULL) THEN 
              fullText := fullText || '(emailspecifications_transfer:integer)=(' || current_row.emailspecifications_transfer || ')';
          END IF;
          IF (current_row.emailspecifications_page_email IS NOT NULL) THEN 
              fullText := fullText || '(emailspecifications_page_email:integer)=(' || current_row.emailspecifications_page_email || ')';
          END IF;
        IF($3) THEN 
        DECLARE 
  --    198
        parent_row RECORD; 
        loop_count int4:=0; 
        BEGIN 
        FOR parent_row IN SELECT * FROM arc_ArchiveSpecification_notification_type WHERE notification_types_notification_arc_archivespecification_id=current_row.arc_archivespecification_id ORDER BY arc_archivespecification_notification_type_id
        LOOP
           child_count := child_count+1;
           tempText := NULL;
           tempText := i_arc_ArchiveSpecification_notification_type( parent_row.arc_archivespecification_notification_type_id, child_count,$3,false,false);
              fullText := fullText || '(notification_types_notification_type_archivespecification_notification_type' || loop_count || ':XFTItem)=';
              fullText := fullText || '(' || tempText || ')';
              loop_count := loop_count+1;
        END LOOP;
        END;
        END IF; 
          IF (current_row.dcm_dcm_host IS NOT NULL) THEN 
              fullText := fullText || '(dcm_dcm_host:string)=(' || REPLACE(REPLACE(current_row.dcm_dcm_host,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.dcm_dcm_port IS NOT NULL) THEN 
              fullText := fullText || '(dcm_dcm_port:string)=(' || REPLACE(REPLACE(current_row.dcm_dcm_port,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.dcm_dcm_ae IS NOT NULL) THEN 
              fullText := fullText || '(dcm_dcm_ae:string)=(' || REPLACE(REPLACE(current_row.dcm_dcm_ae,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.dcm_http_url IS NOT NULL) THEN 
              fullText := fullText || '(dcm_http_url:string)=(' || REPLACE(REPLACE(current_row.dcm_http_url,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.dcm_applet_link IS NOT NULL) THEN 
              fullText := fullText || '(dcm_applet_link:integer)=(' || current_row.dcm_applet_link || ')';
          END IF;
          IF (current_row.site_id IS NOT NULL) THEN 
              fullText := fullText || '(site_id:string)=(' || REPLACE(REPLACE(current_row.site_id,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.site_admin_email IS NOT NULL) THEN 
              fullText := fullText || '(site_admin_email:string)=(' || REPLACE(REPLACE(current_row.site_admin_email,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.site_url IS NOT NULL) THEN 
              fullText := fullText || '(site_url:string)=(' || REPLACE(REPLACE(current_row.site_url,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.smtp_host IS NOT NULL) THEN 
              fullText := fullText || '(smtp_host:string)=(' || REPLACE(REPLACE(current_row.smtp_host,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.require_login IS NOT NULL) THEN 
              fullText := fullText || '(require_login:integer)=(' || current_row.require_login || ')';
          END IF;
          IF (current_row.enable_new_registrations IS NOT NULL) THEN 
              fullText := fullText || '(enable_new_registrations:integer)=(' || current_row.enable_new_registrations || ')';
          END IF;
          IF (current_row.enable_csrf_token IS NOT NULL) THEN 
              fullText := fullText || '(enable_csrf_token:integer)=(' || current_row.enable_csrf_token || ')';
          END IF;
          IF (current_row.quarantine_code IS NOT NULL) THEN 
              fullText := fullText || '(quarantine_code:integer)=(' || current_row.quarantine_code || ')';
          END IF;
          IF (current_row.prearchive_code IS NOT NULL) THEN 
              fullText := fullText || '(prearchive_code:integer)=(' || current_row.prearchive_code || ')';
          END IF;
        IF ((current_row.ArchiveSpecification_info IS NOT NULL)) THEN
            fullText := fullText || '(archivespecification_info:integer)=(' || current_row.archivespecification_info || ')';
 -- 693
           child_count := child_count+1;
           tempText := NULL;
           tempText := i_arc_ArchiveSpecification_meta_data(current_row.ArchiveSpecification_info, child_count,$3,false,false);
              fullText := fullText || '(archivespecification_info_archivespecification_meta_data:XFTItem)=(' || tempText || ')';
        END IF;
          IF (current_row.arc_archivespecification_id IS NOT NULL) THEN 
              fullText := fullText || '(arc_archivespecification_id:integer)=(' || current_row.arc_archivespecification_id || ')';
          END IF;
      END LOOP;
	   fullText := fullText || ')*END_ITEM*' || local_count || ')';
	
	 RETURN fullText;
    end;
$_$;


ALTER FUNCTION public.i_arc_archivespecification(integer, integer, boolean, boolean, boolean) OWNER TO xnat;

--
-- Name: i_arc_archivespecification_history(integer, integer, boolean, boolean, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.i_arc_archivespecification_history(integer, integer, boolean, boolean, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     tempText TEXT;
     fullText TEXT;
     row_ct int4;
     local_count int4;
     child_count int4;
    begin
  --    72
      local_count := $2;
      child_count := $2;
      row_ct := 0;
      fullText := 'Item:(' || local_count || '(arc:ArchiveSpecification_history)(';
      FOR current_row IN SELECT * FROM arc_ArchiveSpecification_history WHERE  history_id=$1
      LOOP
           row_ct := row_ct+1;
          
        IF ((current_row.globalpaths_arc_pathinfo_id IS NOT NULL)) THEN
            fullText := fullText || '(globalpaths_arc_pathinfo_id:integer)=(' || current_row.globalpaths_arc_pathinfo_id || ')';
 -- 661
           DECLARE
           mapping_row RECORD; 
           loop_count int4:=0; 
           BEGIN 
           	FOR mapping_row IN SELECT * FROM arc_pathInfo_history WHERE  arc_pathinfo_id=current_row.globalpaths_arc_pathinfo_id AND xft_version=current_row.xft_version LIMIT 1
           	LOOP
           child_count := child_count+1;
           tempText := NULL;
           tempText := i_arc_pathInfo_history(mapping_row.history_id, child_count,$3,false,false);
              fullText := fullText || '(globalpaths_pathinfo:XFTItem)=(' || tempText || ')';
           	END LOOP;
           END; 
        END IF;
        IF($3) THEN 
        DECLARE 
  --    198
        parent_row RECORD; 
        loop_count int4:=0; 
        BEGIN 
        FOR parent_row IN SELECT * FROM arc_fieldSpecification_history WHERE fieldspecifications_fieldspecif_arc_archivespecification_id=current_row.arc_archivespecification_id AND xft_version=current_row.xft_version ORDER BY arc_fieldspecification_id
        LOOP
           child_count := child_count+1;
           tempText := NULL;
           tempText := i_arc_fieldSpecification_history( parent_row.arc_fieldspecification_id, child_count,$3,false,false);
              fullText := fullText || '(fieldspecifications_fieldspecification_fieldspecification' || loop_count || ':XFTItem)=';
              fullText := fullText || '(' || tempText || ')';
              loop_count := loop_count+1;
        END LOOP;
        END;
        END IF; 
        IF($3) THEN 
        DECLARE 
  --    198
        parent_row RECORD; 
        loop_count int4:=0; 
        BEGIN 
        FOR parent_row IN SELECT * FROM arc_project_history WHERE projects_project_arc_ArchiveSpe_arc_archivespecification_id=current_row.arc_archivespecification_id AND xft_version=current_row.xft_version ORDER BY arc_project_id
        LOOP
           child_count := child_count+1;
           tempText := NULL;
           tempText := i_arc_project_history( parent_row.arc_project_id, child_count,$3,false,false);
              fullText := fullText || '(projects_project_project' || loop_count || ':XFTItem)=';
              fullText := fullText || '(' || tempText || ')';
              loop_count := loop_count+1;
        END LOOP;
        END;
        END IF; 
          IF (current_row.emailspecifications_new_user_registration IS NOT NULL) THEN 
              fullText := fullText || '(emailspecifications_new_user_registration:integer)=(' || current_row.emailspecifications_new_user_registration || ')';
          END IF;
          IF (current_row.emailspecifications_pipeline IS NOT NULL) THEN 
              fullText := fullText || '(emailspecifications_pipeline:integer)=(' || current_row.emailspecifications_pipeline || ')';
          END IF;
          IF (current_row.emailspecifications_project_access IS NOT NULL) THEN 
              fullText := fullText || '(emailspecifications_project_access:integer)=(' || current_row.emailspecifications_project_access || ')';
          END IF;
          IF (current_row.emailspecifications_transfer IS NOT NULL) THEN 
              fullText := fullText || '(emailspecifications_transfer:integer)=(' || current_row.emailspecifications_transfer || ')';
          END IF;
          IF (current_row.emailspecifications_page_email IS NOT NULL) THEN 
              fullText := fullText || '(emailspecifications_page_email:integer)=(' || current_row.emailspecifications_page_email || ')';
          END IF;
        IF($3) THEN 
        DECLARE 
  --    198
        parent_row RECORD; 
        loop_count int4:=0; 
        BEGIN 
        FOR parent_row IN SELECT * FROM arc_ArchiveSpecification_notification_type_history WHERE notification_types_notification_arc_archivespecification_id=current_row.arc_archivespecification_id AND xft_version=current_row.xft_version ORDER BY arc_archivespecification_notification_type_id
        LOOP
           child_count := child_count+1;
           tempText := NULL;
           tempText := i_arc_ArchiveSpecification_notification_type_history( parent_row.arc_archivespecification_notification_type_id, child_count,$3,false,false);
              fullText := fullText || '(notification_types_notification_type_archivespecification_notification_type' || loop_count || ':XFTItem)=';
              fullText := fullText || '(' || tempText || ')';
              loop_count := loop_count+1;
        END LOOP;
        END;
        END IF; 
          IF (current_row.dcm_dcm_host IS NOT NULL) THEN 
              fullText := fullText || '(dcm_dcm_host:string)=(' || REPLACE(REPLACE(current_row.dcm_dcm_host,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.dcm_dcm_port IS NOT NULL) THEN 
              fullText := fullText || '(dcm_dcm_port:string)=(' || REPLACE(REPLACE(current_row.dcm_dcm_port,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.dcm_dcm_ae IS NOT NULL) THEN 
              fullText := fullText || '(dcm_dcm_ae:string)=(' || REPLACE(REPLACE(current_row.dcm_dcm_ae,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.dcm_http_url IS NOT NULL) THEN 
              fullText := fullText || '(dcm_http_url:string)=(' || REPLACE(REPLACE(current_row.dcm_http_url,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.dcm_applet_link IS NOT NULL) THEN 
              fullText := fullText || '(dcm_applet_link:integer)=(' || current_row.dcm_applet_link || ')';
          END IF;
          IF (current_row.site_id IS NOT NULL) THEN 
              fullText := fullText || '(site_id:string)=(' || REPLACE(REPLACE(current_row.site_id,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.site_admin_email IS NOT NULL) THEN 
              fullText := fullText || '(site_admin_email:string)=(' || REPLACE(REPLACE(current_row.site_admin_email,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.site_url IS NOT NULL) THEN 
              fullText := fullText || '(site_url:string)=(' || REPLACE(REPLACE(current_row.site_url,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.smtp_host IS NOT NULL) THEN 
              fullText := fullText || '(smtp_host:string)=(' || REPLACE(REPLACE(current_row.smtp_host,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.require_login IS NOT NULL) THEN 
              fullText := fullText || '(require_login:integer)=(' || current_row.require_login || ')';
          END IF;
          IF (current_row.enable_new_registrations IS NOT NULL) THEN 
              fullText := fullText || '(enable_new_registrations:integer)=(' || current_row.enable_new_registrations || ')';
          END IF;
          IF (current_row.enable_csrf_token IS NOT NULL) THEN 
              fullText := fullText || '(enable_csrf_token:integer)=(' || current_row.enable_csrf_token || ')';
          END IF;
          IF (current_row.quarantine_code IS NOT NULL) THEN 
              fullText := fullText || '(quarantine_code:integer)=(' || current_row.quarantine_code || ')';
          END IF;
          IF (current_row.prearchive_code IS NOT NULL) THEN 
              fullText := fullText || '(prearchive_code:integer)=(' || current_row.prearchive_code || ')';
          END IF;
        IF ((current_row.ArchiveSpecification_info IS NOT NULL)) THEN
            fullText := fullText || '(archivespecification_info:integer)=(' || current_row.archivespecification_info || ')';
 -- 693
           child_count := child_count+1;
           tempText := NULL;
           tempText := i_arc_ArchiveSpecification_meta_data(current_row.ArchiveSpecification_info, child_count,$3,false,false);
              fullText := fullText || '(archivespecification_info_archivespecification_meta_data:XFTItem)=(' || tempText || ')';
        END IF;
          IF (current_row.arc_archivespecification_id IS NOT NULL) THEN 
              fullText := fullText || '(arc_archivespecification_id:integer)=(' || current_row.arc_archivespecification_id || ')';
          END IF;
          IF (current_row.xft_version IS NOT NULL) THEN 
              fullText := fullText || '(xft_version:integer)=(' || current_row.xft_version || ')';
          END IF;
          IF (current_row.history_id IS NOT NULL) THEN 
              fullText := fullText || '(history_id:integer)=(' || current_row.history_id || ')';
          END IF;
          IF (current_row.change_user IS NOT NULL) THEN 
              fullText := fullText || '(change_user:integer)=(' || current_row.change_user || ')';
          END IF;
          IF (current_row.change_date IS NOT NULL) THEN 
              fullText := fullText || '(change_date:dateTime)=(' || current_row.change_date || ')';
          END IF;
          IF (current_row.previous_change_date IS NOT NULL) THEN 
              fullText := fullText || '(previous_change_date:dateTime)=(' || current_row.previous_change_date || ')';
          END IF;
      END LOOP;
	   fullText := fullText || ')*END_ITEM*' || local_count || ')';
	
	 RETURN fullText;
    end;
$_$;


ALTER FUNCTION public.i_arc_archivespecification_history(integer, integer, boolean, boolean, boolean) OWNER TO xnat;

--
-- Name: i_arc_archivespecification_meta_data(integer, integer, boolean, boolean, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.i_arc_archivespecification_meta_data(integer, integer, boolean, boolean, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     tempText TEXT;
     fullText TEXT;
     row_ct int4;
     local_count int4;
     child_count int4;
    begin
  --    72
      local_count := $2;
      child_count := $2;
      row_ct := 0;
      fullText := 'Item:(' || local_count || '(arc:ArchiveSpecification_meta_data)(';
      FOR current_row IN SELECT * FROM arc_ArchiveSpecification_meta_data WHERE  meta_data_id=$1
      LOOP
           row_ct := row_ct+1;
          
          IF (current_row.xft_version IS NOT NULL) THEN 
              fullText := fullText || '(xft_version:string)=(' || REPLACE(REPLACE(current_row.xft_version,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.last_modified IS NOT NULL) THEN 
              fullText := fullText || '(last_modified:dateTime)=(' || current_row.last_modified || ')';
          END IF;
          IF (current_row.status IS NOT NULL) THEN 
              fullText := fullText || '(status:string)=(' || REPLACE(REPLACE(current_row.status,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.activation_date IS NOT NULL) THEN 
              fullText := fullText || '(activation_date:dateTime)=(' || current_row.activation_date || ')';
          END IF;
          IF (current_row.row_last_modified IS NOT NULL) THEN 
              fullText := fullText || '(row_last_modified:dateTime)=(' || current_row.row_last_modified || ')';
          END IF;
          IF (current_row.insert_date IS NOT NULL) THEN 
              fullText := fullText || '(insert_date:dateTime)=(' || current_row.insert_date || ')';
          END IF;
        IF ((current_row.activation_user_xdat_user_id IS NOT NULL)) THEN
            fullText := fullText || '(activation_user_xdat_user_id:integer)=(' || current_row.activation_user_xdat_user_id || ')';
        END IF;
        IF ((current_row.insert_user_xdat_user_id IS NOT NULL)) THEN
            fullText := fullText || '(insert_user_xdat_user_id:integer)=(' || current_row.insert_user_xdat_user_id || ')';
        END IF;
          IF (current_row.origin IS NOT NULL) THEN 
              fullText := fullText || '(origin:string)=(' || REPLACE(REPLACE(current_row.origin,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.modified IS NOT NULL) THEN 
              fullText := fullText || '(modified:integer)=(' || current_row.modified || ')';
          END IF;
          IF (current_row.shareable IS NOT NULL) THEN 
              fullText := fullText || '(shareable:integer)=(' || current_row.shareable || ')';
          END IF;
          IF (current_row.meta_data_id IS NOT NULL) THEN 
              fullText := fullText || '(meta_data_id:integer)=(' || current_row.meta_data_id || ')';
          END IF;
      END LOOP;
	   fullText := fullText || ')*END_ITEM*' || local_count || ')';
	
	 RETURN fullText;
    end;
$_$;


ALTER FUNCTION public.i_arc_archivespecification_meta_data(integer, integer, boolean, boolean, boolean) OWNER TO xnat;

--
-- Name: i_arc_archivespecification_notification_type(integer, integer, boolean, boolean, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.i_arc_archivespecification_notification_type(integer, integer, boolean, boolean, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     tempText TEXT;
     fullText TEXT;
     row_ct int4;
     local_count int4;
     child_count int4;
    begin
  --    72
      local_count := $2;
      child_count := $2;
      row_ct := 0;
      fullText := 'Item:(' || local_count || '(arc:ArchiveSpecification_notification_type)(';
      FOR current_row IN SELECT * FROM arc_ArchiveSpecification_notification_type WHERE  arc_archivespecification_notification_type_id=$1
      LOOP
           row_ct := row_ct+1;
          
          IF (current_row.notification_type IS NOT NULL) THEN 
              fullText := fullText || '(notification_type:string)=(' || REPLACE(REPLACE(current_row.notification_type,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.email_addresses IS NOT NULL) THEN 
              fullText := fullText || '(email_addresses:string)=(' || REPLACE(REPLACE(current_row.email_addresses,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
        IF ((current_row.ArchiveSpecification_notification_type_info IS NOT NULL)) THEN
            fullText := fullText || '(archivespecification_notification_type_info:integer)=(' || current_row.archivespecification_notification_type_info || ')';
 -- 693
           child_count := child_count+1;
           tempText := NULL;
           tempText := i_arc_ArchiveSpecification_notification_type_meta_data(current_row.ArchiveSpecification_notification_type_info, child_count,$3,false,false);
              fullText := fullText || '(archivespecification_notification_type_info_archivespecification_notification_type_meta_data:XFTItem)=(' || tempText || ')';
        END IF;
  -- 475
        IF ((current_row.notification_types_notification_arc_archivespecification_id IS NOT NULL)) THEN
            fullText := fullText || '(notification_types_notification_arc_archivespecification_id:integer)=(' || current_row.notification_types_notification_arc_archivespecification_id || ')';
        END IF;
          IF (current_row.arc_archivespecification_notification_type_id IS NOT NULL) THEN 
              fullText := fullText || '(arc_archivespecification_notification_type_id:integer)=(' || current_row.arc_archivespecification_notification_type_id || ')';
          END IF;
      END LOOP;
	   fullText := fullText || ')*END_ITEM*' || local_count || ')';
	
	 RETURN fullText;
    end;
$_$;


ALTER FUNCTION public.i_arc_archivespecification_notification_type(integer, integer, boolean, boolean, boolean) OWNER TO xnat;

--
-- Name: i_arc_archivespecification_notification_type_history(integer, integer, boolean, boolean, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.i_arc_archivespecification_notification_type_history(integer, integer, boolean, boolean, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     tempText TEXT;
     fullText TEXT;
     row_ct int4;
     local_count int4;
     child_count int4;
    begin
  --    72
      local_count := $2;
      child_count := $2;
      row_ct := 0;
      fullText := 'Item:(' || local_count || '(arc:ArchiveSpecification_notification_type_history)(';
      FOR current_row IN SELECT * FROM arc_ArchiveSpecification_notification_type_history WHERE  history_id=$1
      LOOP
           row_ct := row_ct+1;
          
          IF (current_row.notification_type IS NOT NULL) THEN 
              fullText := fullText || '(notification_type:string)=(' || REPLACE(REPLACE(current_row.notification_type,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.email_addresses IS NOT NULL) THEN 
              fullText := fullText || '(email_addresses:string)=(' || REPLACE(REPLACE(current_row.email_addresses,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
        IF ((current_row.ArchiveSpecification_notification_type_info IS NOT NULL)) THEN
            fullText := fullText || '(archivespecification_notification_type_info:integer)=(' || current_row.archivespecification_notification_type_info || ')';
 -- 693
           child_count := child_count+1;
           tempText := NULL;
           tempText := i_arc_ArchiveSpecification_notification_type_meta_data(current_row.ArchiveSpecification_notification_type_info, child_count,$3,false,false);
              fullText := fullText || '(archivespecification_notification_type_info_archivespecification_notification_type_meta_data:XFTItem)=(' || tempText || ')';
        END IF;
  -- 475
        IF ((current_row.notification_types_notification_arc_archivespecification_id IS NOT NULL)) THEN
            fullText := fullText || '(notification_types_notification_arc_archivespecification_id:integer)=(' || current_row.notification_types_notification_arc_archivespecification_id || ')';
        END IF;
          IF (current_row.arc_archivespecification_notification_type_id IS NOT NULL) THEN 
              fullText := fullText || '(arc_archivespecification_notification_type_id:integer)=(' || current_row.arc_archivespecification_notification_type_id || ')';
          END IF;
          IF (current_row.xft_version IS NOT NULL) THEN 
              fullText := fullText || '(xft_version:integer)=(' || current_row.xft_version || ')';
          END IF;
          IF (current_row.history_id IS NOT NULL) THEN 
              fullText := fullText || '(history_id:integer)=(' || current_row.history_id || ')';
          END IF;
          IF (current_row.change_user IS NOT NULL) THEN 
              fullText := fullText || '(change_user:integer)=(' || current_row.change_user || ')';
          END IF;
          IF (current_row.change_date IS NOT NULL) THEN 
              fullText := fullText || '(change_date:dateTime)=(' || current_row.change_date || ')';
          END IF;
          IF (current_row.previous_change_date IS NOT NULL) THEN 
              fullText := fullText || '(previous_change_date:dateTime)=(' || current_row.previous_change_date || ')';
          END IF;
      END LOOP;
	   fullText := fullText || ')*END_ITEM*' || local_count || ')';
	
	 RETURN fullText;
    end;
$_$;


ALTER FUNCTION public.i_arc_archivespecification_notification_type_history(integer, integer, boolean, boolean, boolean) OWNER TO xnat;

--
-- Name: i_arc_archivespecification_notification_type_meta_data(integer, integer, boolean, boolean, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.i_arc_archivespecification_notification_type_meta_data(integer, integer, boolean, boolean, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     tempText TEXT;
     fullText TEXT;
     row_ct int4;
     local_count int4;
     child_count int4;
    begin
  --    72
      local_count := $2;
      child_count := $2;
      row_ct := 0;
      fullText := 'Item:(' || local_count || '(arc:ArchiveSpecification_notification_type_meta_data)(';
      FOR current_row IN SELECT * FROM arc_ArchiveSpecification_notification_type_meta_data WHERE  meta_data_id=$1
      LOOP
           row_ct := row_ct+1;
          
          IF (current_row.xft_version IS NOT NULL) THEN 
              fullText := fullText || '(xft_version:string)=(' || REPLACE(REPLACE(current_row.xft_version,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.last_modified IS NOT NULL) THEN 
              fullText := fullText || '(last_modified:dateTime)=(' || current_row.last_modified || ')';
          END IF;
          IF (current_row.status IS NOT NULL) THEN 
              fullText := fullText || '(status:string)=(' || REPLACE(REPLACE(current_row.status,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.activation_date IS NOT NULL) THEN 
              fullText := fullText || '(activation_date:dateTime)=(' || current_row.activation_date || ')';
          END IF;
          IF (current_row.row_last_modified IS NOT NULL) THEN 
              fullText := fullText || '(row_last_modified:dateTime)=(' || current_row.row_last_modified || ')';
          END IF;
          IF (current_row.insert_date IS NOT NULL) THEN 
              fullText := fullText || '(insert_date:dateTime)=(' || current_row.insert_date || ')';
          END IF;
        IF ((current_row.activation_user_xdat_user_id IS NOT NULL)) THEN
            fullText := fullText || '(activation_user_xdat_user_id:integer)=(' || current_row.activation_user_xdat_user_id || ')';
        END IF;
        IF ((current_row.insert_user_xdat_user_id IS NOT NULL)) THEN
            fullText := fullText || '(insert_user_xdat_user_id:integer)=(' || current_row.insert_user_xdat_user_id || ')';
        END IF;
          IF (current_row.origin IS NOT NULL) THEN 
              fullText := fullText || '(origin:string)=(' || REPLACE(REPLACE(current_row.origin,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.modified IS NOT NULL) THEN 
              fullText := fullText || '(modified:integer)=(' || current_row.modified || ')';
          END IF;
          IF (current_row.shareable IS NOT NULL) THEN 
              fullText := fullText || '(shareable:integer)=(' || current_row.shareable || ')';
          END IF;
          IF (current_row.meta_data_id IS NOT NULL) THEN 
              fullText := fullText || '(meta_data_id:integer)=(' || current_row.meta_data_id || ')';
          END IF;
      END LOOP;
	   fullText := fullText || ')*END_ITEM*' || local_count || ')';
	
	 RETURN fullText;
    end;
$_$;


ALTER FUNCTION public.i_arc_archivespecification_notification_type_meta_data(integer, integer, boolean, boolean, boolean) OWNER TO xnat;

--
-- Name: i_arc_fieldspecification(integer, integer, boolean, boolean, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.i_arc_fieldspecification(integer, integer, boolean, boolean, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     tempText TEXT;
     fullText TEXT;
     row_ct int4;
     local_count int4;
     child_count int4;
    begin
  --    72
      local_count := $2;
      child_count := $2;
      row_ct := 0;
      fullText := 'Item:(' || local_count || '(arc:fieldSpecification)(';
      FOR current_row IN SELECT * FROM arc_fieldSpecification WHERE  arc_fieldspecification_id=$1
      LOOP
           row_ct := row_ct+1;
          
          IF (current_row.fieldspecification IS NOT NULL) THEN 
              fullText := fullText || '(fieldspecification:string)=(' || REPLACE(REPLACE(current_row.fieldspecification,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.name IS NOT NULL) THEN 
              fullText := fullText || '(name:string)=(' || REPLACE(REPLACE(current_row.name,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
        IF ((current_row.fieldSpecification_info IS NOT NULL)) THEN
            fullText := fullText || '(fieldspecification_info:integer)=(' || current_row.fieldspecification_info || ')';
 -- 693
           child_count := child_count+1;
           tempText := NULL;
           tempText := i_arc_fieldSpecification_meta_data(current_row.fieldSpecification_info, child_count,$3,false,false);
              fullText := fullText || '(fieldspecification_info_fieldspecification_meta_data:XFTItem)=(' || tempText || ')';
        END IF;
  -- 475
        IF ((current_row.fieldspecifications_fieldspecif_arc_archivespecification_id IS NOT NULL)) THEN
            fullText := fullText || '(fieldspecifications_fieldspecif_arc_archivespecification_id:integer)=(' || current_row.fieldspecifications_fieldspecif_arc_archivespecification_id || ')';
        END IF;
  -- 475
        IF ((current_row.fieldspecifications_fieldspecif_arc_project_id IS NOT NULL)) THEN
            fullText := fullText || '(fieldspecifications_fieldspecif_arc_project_id:integer)=(' || current_row.fieldspecifications_fieldspecif_arc_project_id || ')';
        END IF;
          IF (current_row.arc_fieldspecification_id IS NOT NULL) THEN 
              fullText := fullText || '(arc_fieldspecification_id:integer)=(' || current_row.arc_fieldspecification_id || ')';
          END IF;
      END LOOP;
	   fullText := fullText || ')*END_ITEM*' || local_count || ')';
	
	 RETURN fullText;
    end;
$_$;


ALTER FUNCTION public.i_arc_fieldspecification(integer, integer, boolean, boolean, boolean) OWNER TO xnat;

--
-- Name: i_arc_fieldspecification_history(integer, integer, boolean, boolean, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.i_arc_fieldspecification_history(integer, integer, boolean, boolean, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     tempText TEXT;
     fullText TEXT;
     row_ct int4;
     local_count int4;
     child_count int4;
    begin
  --    72
      local_count := $2;
      child_count := $2;
      row_ct := 0;
      fullText := 'Item:(' || local_count || '(arc:fieldSpecification_history)(';
      FOR current_row IN SELECT * FROM arc_fieldSpecification_history WHERE  history_id=$1
      LOOP
           row_ct := row_ct+1;
          
          IF (current_row.fieldspecification IS NOT NULL) THEN 
              fullText := fullText || '(fieldspecification:string)=(' || REPLACE(REPLACE(current_row.fieldspecification,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.name IS NOT NULL) THEN 
              fullText := fullText || '(name:string)=(' || REPLACE(REPLACE(current_row.name,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
        IF ((current_row.fieldSpecification_info IS NOT NULL)) THEN
            fullText := fullText || '(fieldspecification_info:integer)=(' || current_row.fieldspecification_info || ')';
 -- 693
           child_count := child_count+1;
           tempText := NULL;
           tempText := i_arc_fieldSpecification_meta_data(current_row.fieldSpecification_info, child_count,$3,false,false);
              fullText := fullText || '(fieldspecification_info_fieldspecification_meta_data:XFTItem)=(' || tempText || ')';
        END IF;
  -- 475
        IF ((current_row.fieldspecifications_fieldspecif_arc_archivespecification_id IS NOT NULL)) THEN
            fullText := fullText || '(fieldspecifications_fieldspecif_arc_archivespecification_id:integer)=(' || current_row.fieldspecifications_fieldspecif_arc_archivespecification_id || ')';
        END IF;
  -- 475
        IF ((current_row.fieldspecifications_fieldspecif_arc_project_id IS NOT NULL)) THEN
            fullText := fullText || '(fieldspecifications_fieldspecif_arc_project_id:integer)=(' || current_row.fieldspecifications_fieldspecif_arc_project_id || ')';
        END IF;
          IF (current_row.arc_fieldspecification_id IS NOT NULL) THEN 
              fullText := fullText || '(arc_fieldspecification_id:integer)=(' || current_row.arc_fieldspecification_id || ')';
          END IF;
          IF (current_row.xft_version IS NOT NULL) THEN 
              fullText := fullText || '(xft_version:integer)=(' || current_row.xft_version || ')';
          END IF;
          IF (current_row.history_id IS NOT NULL) THEN 
              fullText := fullText || '(history_id:integer)=(' || current_row.history_id || ')';
          END IF;
          IF (current_row.change_user IS NOT NULL) THEN 
              fullText := fullText || '(change_user:integer)=(' || current_row.change_user || ')';
          END IF;
          IF (current_row.change_date IS NOT NULL) THEN 
              fullText := fullText || '(change_date:dateTime)=(' || current_row.change_date || ')';
          END IF;
          IF (current_row.previous_change_date IS NOT NULL) THEN 
              fullText := fullText || '(previous_change_date:dateTime)=(' || current_row.previous_change_date || ')';
          END IF;
      END LOOP;
	   fullText := fullText || ')*END_ITEM*' || local_count || ')';
	
	 RETURN fullText;
    end;
$_$;


ALTER FUNCTION public.i_arc_fieldspecification_history(integer, integer, boolean, boolean, boolean) OWNER TO xnat;

--
-- Name: i_arc_fieldspecification_meta_data(integer, integer, boolean, boolean, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.i_arc_fieldspecification_meta_data(integer, integer, boolean, boolean, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     tempText TEXT;
     fullText TEXT;
     row_ct int4;
     local_count int4;
     child_count int4;
    begin
  --    72
      local_count := $2;
      child_count := $2;
      row_ct := 0;
      fullText := 'Item:(' || local_count || '(arc:fieldSpecification_meta_data)(';
      FOR current_row IN SELECT * FROM arc_fieldSpecification_meta_data WHERE  meta_data_id=$1
      LOOP
           row_ct := row_ct+1;
          
          IF (current_row.xft_version IS NOT NULL) THEN 
              fullText := fullText || '(xft_version:string)=(' || REPLACE(REPLACE(current_row.xft_version,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.last_modified IS NOT NULL) THEN 
              fullText := fullText || '(last_modified:dateTime)=(' || current_row.last_modified || ')';
          END IF;
          IF (current_row.status IS NOT NULL) THEN 
              fullText := fullText || '(status:string)=(' || REPLACE(REPLACE(current_row.status,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.activation_date IS NOT NULL) THEN 
              fullText := fullText || '(activation_date:dateTime)=(' || current_row.activation_date || ')';
          END IF;
          IF (current_row.row_last_modified IS NOT NULL) THEN 
              fullText := fullText || '(row_last_modified:dateTime)=(' || current_row.row_last_modified || ')';
          END IF;
          IF (current_row.insert_date IS NOT NULL) THEN 
              fullText := fullText || '(insert_date:dateTime)=(' || current_row.insert_date || ')';
          END IF;
        IF ((current_row.activation_user_xdat_user_id IS NOT NULL)) THEN
            fullText := fullText || '(activation_user_xdat_user_id:integer)=(' || current_row.activation_user_xdat_user_id || ')';
        END IF;
        IF ((current_row.insert_user_xdat_user_id IS NOT NULL)) THEN
            fullText := fullText || '(insert_user_xdat_user_id:integer)=(' || current_row.insert_user_xdat_user_id || ')';
        END IF;
          IF (current_row.origin IS NOT NULL) THEN 
              fullText := fullText || '(origin:string)=(' || REPLACE(REPLACE(current_row.origin,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.modified IS NOT NULL) THEN 
              fullText := fullText || '(modified:integer)=(' || current_row.modified || ')';
          END IF;
          IF (current_row.shareable IS NOT NULL) THEN 
              fullText := fullText || '(shareable:integer)=(' || current_row.shareable || ')';
          END IF;
          IF (current_row.meta_data_id IS NOT NULL) THEN 
              fullText := fullText || '(meta_data_id:integer)=(' || current_row.meta_data_id || ')';
          END IF;
      END LOOP;
	   fullText := fullText || ')*END_ITEM*' || local_count || ')';
	
	 RETURN fullText;
    end;
$_$;


ALTER FUNCTION public.i_arc_fieldspecification_meta_data(integer, integer, boolean, boolean, boolean) OWNER TO xnat;

--
-- Name: i_arc_pathinfo(integer, integer, boolean, boolean, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.i_arc_pathinfo(integer, integer, boolean, boolean, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     tempText TEXT;
     fullText TEXT;
     row_ct int4;
     local_count int4;
     child_count int4;
    begin
  --    72
      local_count := $2;
      child_count := $2;
      row_ct := 0;
      fullText := 'Item:(' || local_count || '(arc:pathInfo)(';
      FOR current_row IN SELECT * FROM arc_pathInfo WHERE  arc_pathinfo_id=$1
      LOOP
           row_ct := row_ct+1;
          
          IF (current_row.archivepath IS NOT NULL) THEN 
              fullText := fullText || '(archivepath:string)=(' || REPLACE(REPLACE(current_row.archivepath,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.prearchivepath IS NOT NULL) THEN 
              fullText := fullText || '(prearchivepath:string)=(' || REPLACE(REPLACE(current_row.prearchivepath,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.cachepath IS NOT NULL) THEN 
              fullText := fullText || '(cachepath:string)=(' || REPLACE(REPLACE(current_row.cachepath,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.buildpath IS NOT NULL) THEN 
              fullText := fullText || '(buildpath:string)=(' || REPLACE(REPLACE(current_row.buildpath,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.ftppath IS NOT NULL) THEN 
              fullText := fullText || '(ftppath:string)=(' || REPLACE(REPLACE(current_row.ftppath,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.pipelinepath IS NOT NULL) THEN 
              fullText := fullText || '(pipelinepath:string)=(' || REPLACE(REPLACE(current_row.pipelinepath,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
        IF ((current_row.pathInfo_info IS NOT NULL)) THEN
            fullText := fullText || '(pathinfo_info:integer)=(' || current_row.pathinfo_info || ')';
 -- 693
           child_count := child_count+1;
           tempText := NULL;
           tempText := i_arc_pathInfo_meta_data(current_row.pathInfo_info, child_count,$3,false,false);
              fullText := fullText || '(pathinfo_info_pathinfo_meta_data:XFTItem)=(' || tempText || ')';
        END IF;
          IF (current_row.arc_pathinfo_id IS NOT NULL) THEN 
              fullText := fullText || '(arc_pathinfo_id:integer)=(' || current_row.arc_pathinfo_id || ')';
          END IF;
      END LOOP;
	   fullText := fullText || ')*END_ITEM*' || local_count || ')';
	
	 RETURN fullText;
    end;
$_$;


ALTER FUNCTION public.i_arc_pathinfo(integer, integer, boolean, boolean, boolean) OWNER TO xnat;

--
-- Name: i_arc_pathinfo_history(integer, integer, boolean, boolean, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.i_arc_pathinfo_history(integer, integer, boolean, boolean, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     tempText TEXT;
     fullText TEXT;
     row_ct int4;
     local_count int4;
     child_count int4;
    begin
  --    72
      local_count := $2;
      child_count := $2;
      row_ct := 0;
      fullText := 'Item:(' || local_count || '(arc:pathInfo_history)(';
      FOR current_row IN SELECT * FROM arc_pathInfo_history WHERE  history_id=$1
      LOOP
           row_ct := row_ct+1;
          
          IF (current_row.archivepath IS NOT NULL) THEN 
              fullText := fullText || '(archivepath:string)=(' || REPLACE(REPLACE(current_row.archivepath,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.prearchivepath IS NOT NULL) THEN 
              fullText := fullText || '(prearchivepath:string)=(' || REPLACE(REPLACE(current_row.prearchivepath,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.cachepath IS NOT NULL) THEN 
              fullText := fullText || '(cachepath:string)=(' || REPLACE(REPLACE(current_row.cachepath,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.buildpath IS NOT NULL) THEN 
              fullText := fullText || '(buildpath:string)=(' || REPLACE(REPLACE(current_row.buildpath,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.ftppath IS NOT NULL) THEN 
              fullText := fullText || '(ftppath:string)=(' || REPLACE(REPLACE(current_row.ftppath,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.pipelinepath IS NOT NULL) THEN 
              fullText := fullText || '(pipelinepath:string)=(' || REPLACE(REPLACE(current_row.pipelinepath,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
        IF ((current_row.pathInfo_info IS NOT NULL)) THEN
            fullText := fullText || '(pathinfo_info:integer)=(' || current_row.pathinfo_info || ')';
 -- 693
           child_count := child_count+1;
           tempText := NULL;
           tempText := i_arc_pathInfo_meta_data(current_row.pathInfo_info, child_count,$3,false,false);
              fullText := fullText || '(pathinfo_info_pathinfo_meta_data:XFTItem)=(' || tempText || ')';
        END IF;
          IF (current_row.arc_pathinfo_id IS NOT NULL) THEN 
              fullText := fullText || '(arc_pathinfo_id:integer)=(' || current_row.arc_pathinfo_id || ')';
          END IF;
          IF (current_row.xft_version IS NOT NULL) THEN 
              fullText := fullText || '(xft_version:integer)=(' || current_row.xft_version || ')';
          END IF;
          IF (current_row.history_id IS NOT NULL) THEN 
              fullText := fullText || '(history_id:integer)=(' || current_row.history_id || ')';
          END IF;
          IF (current_row.change_user IS NOT NULL) THEN 
              fullText := fullText || '(change_user:integer)=(' || current_row.change_user || ')';
          END IF;
          IF (current_row.change_date IS NOT NULL) THEN 
              fullText := fullText || '(change_date:dateTime)=(' || current_row.change_date || ')';
          END IF;
          IF (current_row.previous_change_date IS NOT NULL) THEN 
              fullText := fullText || '(previous_change_date:dateTime)=(' || current_row.previous_change_date || ')';
          END IF;
      END LOOP;
	   fullText := fullText || ')*END_ITEM*' || local_count || ')';
	
	 RETURN fullText;
    end;
$_$;


ALTER FUNCTION public.i_arc_pathinfo_history(integer, integer, boolean, boolean, boolean) OWNER TO xnat;

--
-- Name: i_arc_pathinfo_meta_data(integer, integer, boolean, boolean, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.i_arc_pathinfo_meta_data(integer, integer, boolean, boolean, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     tempText TEXT;
     fullText TEXT;
     row_ct int4;
     local_count int4;
     child_count int4;
    begin
  --    72
      local_count := $2;
      child_count := $2;
      row_ct := 0;
      fullText := 'Item:(' || local_count || '(arc:pathInfo_meta_data)(';
      FOR current_row IN SELECT * FROM arc_pathInfo_meta_data WHERE  meta_data_id=$1
      LOOP
           row_ct := row_ct+1;
          
          IF (current_row.xft_version IS NOT NULL) THEN 
              fullText := fullText || '(xft_version:string)=(' || REPLACE(REPLACE(current_row.xft_version,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.last_modified IS NOT NULL) THEN 
              fullText := fullText || '(last_modified:dateTime)=(' || current_row.last_modified || ')';
          END IF;
          IF (current_row.status IS NOT NULL) THEN 
              fullText := fullText || '(status:string)=(' || REPLACE(REPLACE(current_row.status,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.activation_date IS NOT NULL) THEN 
              fullText := fullText || '(activation_date:dateTime)=(' || current_row.activation_date || ')';
          END IF;
          IF (current_row.row_last_modified IS NOT NULL) THEN 
              fullText := fullText || '(row_last_modified:dateTime)=(' || current_row.row_last_modified || ')';
          END IF;
          IF (current_row.insert_date IS NOT NULL) THEN 
              fullText := fullText || '(insert_date:dateTime)=(' || current_row.insert_date || ')';
          END IF;
        IF ((current_row.activation_user_xdat_user_id IS NOT NULL)) THEN
            fullText := fullText || '(activation_user_xdat_user_id:integer)=(' || current_row.activation_user_xdat_user_id || ')';
        END IF;
        IF ((current_row.insert_user_xdat_user_id IS NOT NULL)) THEN
            fullText := fullText || '(insert_user_xdat_user_id:integer)=(' || current_row.insert_user_xdat_user_id || ')';
        END IF;
          IF (current_row.origin IS NOT NULL) THEN 
              fullText := fullText || '(origin:string)=(' || REPLACE(REPLACE(current_row.origin,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.modified IS NOT NULL) THEN 
              fullText := fullText || '(modified:integer)=(' || current_row.modified || ')';
          END IF;
          IF (current_row.shareable IS NOT NULL) THEN 
              fullText := fullText || '(shareable:integer)=(' || current_row.shareable || ')';
          END IF;
          IF (current_row.meta_data_id IS NOT NULL) THEN 
              fullText := fullText || '(meta_data_id:integer)=(' || current_row.meta_data_id || ')';
          END IF;
      END LOOP;
	   fullText := fullText || ')*END_ITEM*' || local_count || ')';
	
	 RETURN fullText;
    end;
$_$;


ALTER FUNCTION public.i_arc_pathinfo_meta_data(integer, integer, boolean, boolean, boolean) OWNER TO xnat;

--
-- Name: i_arc_pipelinedata(integer, integer, boolean, boolean, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.i_arc_pipelinedata(integer, integer, boolean, boolean, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     fullText TEXT;
    begin
      FOR current_row IN SELECT * FROM (SELECT arc_pipelineData.arc_pipelinedata_id AS arc_pipelineData7, table1.element_name AS xdat_meta_element31, table2.insert_date AS arc_pipelineData_meta_data38 FROM arc_pipelineData arc_pipelineData   LEFT JOIN xdat_meta_element table1 ON arc_pipelineData.extension=table1.xdat_meta_element_id   LEFT JOIN arc_pipelineData_meta_data table2 ON arc_pipelineData.pipelineData_info=table2.meta_data_id) SEARCH  WHERE 
 ( (arc_pipelineData7=$1))
      LOOP
         IF (current_row.xdat_meta_element31 IS NULL) THEN 
             fullText:= ie_arc_pipelineData( $1, $2,$3,$4,$5);
         ELSE
            --CALL EXTENDER 
            declare
               matches int4:=0;
            begin
            IF (current_row.xdat_meta_element31='arc:project_descendant_pipeline') THEN
                fullText:= i_arc_project_descendant_pipeline( $1, $2,$3,$4,$5);
                matches:=1;
            END IF;
            IF (current_row.xdat_meta_element31='arc:project_pipeline') THEN
                fullText:= i_arc_project_pipeline( $1, $2,$3,$4,$5);
                matches:=1;
            END IF;
                IF (matches=0) THEN
                    fullText:= ie_arc_pipelineData( $1, $2,$3,$4,$5);
                END IF;
            end;
         end IF;
      END LOOP;
	
	RETURN fullText;
    end;
$_$;


ALTER FUNCTION public.i_arc_pipelinedata(integer, integer, boolean, boolean, boolean) OWNER TO xnat;

--
-- Name: i_arc_pipelinedata_history(integer, integer, boolean, boolean, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.i_arc_pipelinedata_history(integer, integer, boolean, boolean, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     fullText TEXT;
    begin
      FOR current_row IN SELECT * FROM (SELECT arc_pipelineData_history.history_id AS arc_pipelineData_history6, table1.element_name AS xdat_meta_element14, arc_pipelineData_history.xft_version AS arc_pipelineData_history_xft_version, arc_pipelineData_history.arc_pipelinedata_id AS arc_pipelineData_history7 FROM arc_pipelineData_history arc_pipelineData_history   LEFT JOIN xdat_meta_element table1 ON arc_pipelineData_history.extension=table1.xdat_meta_element_id) SEARCH  WHERE 
 ( (arc_pipelineData_history6=$1))
      LOOP
         IF (current_row.xdat_meta_element14 IS NULL) THEN 
             fullText:= ie_arc_pipelineData( $1, $2,$3,$4,$5);
         ELSE
            --CALL EXTENDER 
            declare
               matches int4:=0;
            begin
            IF (current_row.xdat_meta_element14='arc:project_descendant_pipeline') THEN
            --907 
            DECLARE
            	ext_row RECORD;
            BEGIN 
            	FOR ext_row IN SELECT * FROM arc_project_descendant_pipeline_history WHERE arc_pipelinedata_id=current_row.arc_pipelineData_history7 AND xft_version=current_row.arc_pipelineData_history_xft_version
           	LOOP
                fullText:= i_arc_project_descendant_pipeline_history(ext_row.history_id, $2,$3,$4,$5);
                matches:=1;
            	END LOOP;
            END;
            END IF;
            IF (current_row.xdat_meta_element14='arc:project_pipeline') THEN
            --907 
            DECLARE
            	ext_row RECORD;
            BEGIN 
            	FOR ext_row IN SELECT * FROM arc_project_pipeline_history WHERE arc_pipelinedata_id=current_row.arc_pipelineData_history7 AND xft_version=current_row.arc_pipelineData_history_xft_version
           	LOOP
                fullText:= i_arc_project_pipeline_history(ext_row.history_id, $2,$3,$4,$5);
                matches:=1;
            	END LOOP;
            END;
            END IF;
                IF (matches=0) THEN
                    fullText:= ie_arc_pipelineData_history( $1, $2,$3,$4,$5);
                END IF;
            end;
         end IF;
      END LOOP;
	
	RETURN fullText;
    end;
$_$;


ALTER FUNCTION public.i_arc_pipelinedata_history(integer, integer, boolean, boolean, boolean) OWNER TO xnat;

--
