I have a mysql query shown below. I need to change it to Postgres.  While doing so, I am getting error at FOUND_ROW(), there is no such function in Postgres. Could anyone let me know how to handle the function equivalent for the code below?
BEGIN
    /*declare temps varchar(2000);*/
    declare tableJoin varchar(2000) default '';
    declare filter varchar(2000) default '';
    declare whereFilters varchar(2000) default '';
    /*set temps = '3';*/
    set @q = '';
    set @join = INSTR(SUBSTRING(filters, 1, INSTR(filters, "=") - 1), ".");
    if @join > 0 then
        /*number of filters*/
        set @count = countCharsInSentence(filters, ',');
        if (@count = 0) then set @count = 1; end if;
        REPEAT
            /*return the filter with a table name*/
            set filter = SPLIT_STR(filters, ',', @count);
            set whereFilters = concat(whereFilters, ',', CONCAT(UCASE(LEFT(filter, 1)), substring(filter, 2)));
            /*return the table name*/
            set @filterTable = SPLIT_STR(filter, '.', 1);
            if (@filterTable != '') then
                set @filterTable = CONCAT(UCASE(LEFT(@filterTable, 1)), substring(@filterTable, 2));
                set tableJoin = concat(tableJoin, " ", tableName, " join ", @filterTable, " on(", tableName, ".id = ",
                                       @filterTable, ".idRef) ");
            end if;
            /*if(tableJoin!='') then set temps = tableJoin; end if;*/
            set @count = @count - 1;
        UNTIL @count <= 0
            END REPEAT;
        set filters = substring(whereFilters, 2);
        if fields is not null and fields != "" then
            set @q = concat("select id, ", fields, " from ", tableJoin, " where ");
        else
            set @q = concat("select ", tableName, ".* from ", tableJoin, " where ");
        end if;
    else
        /*Define the list of column to be retrieved and set the table name*/
        if fields is not null and fields != "" then
            set @q = concat("select id, ", fields, " from ", tableName, " where ");
        else
            set @q = concat("select * from ", tableName, " where ");
        end if;
    end if;
    set @in = INSTR(filters, " IN (");
    /*Define the where condition to filter the results*/
    if @in > 0 then
        set @where = filters;
    elseif filters is not null and filters != "" then
        set @where = concat(replace(filters, "=", "='"), "'");
        /*set @where = replace(@where, ".", "`.`");*/
        set @where = concat(replace(@where, ",", "' and "));
    else
        set @where = '1=1';
    end if;
    /*set @t = temps;*/
    /*Prepare the query*/
    set @q = concat(@q, @where);
    /*Avoid SQL Injection*/
    set @q = replace(@q, ";", ";");
    /*Execute the query*/
    PREPARE stmt FROM @q;
    execute stmt;
    deallocate prepare stmt;
END ;;
I am getting error in Postgres in FOUND_ROW as there is no equivalent in pgSQL for it. Can anyone let me know the best alternative that I can put in place of FOUND_ROW in my stored procedure?
 
     
     
    