type supplied in RETURN NEXT error in PostgreSQL

50 Views Asked by At

I have written function like this in PostgreSQL. But I'm getting error like wrong record type supplied in RETURN NEXT error please help me to solve this problem.

public.pkg_utility_services_fn_get_txn_category();

CREATE OR REPLACE FUNCTION public.pkg_utility_services_fn_get_txn_category(
    )
    RETURNS SETOF categorydtl_obj 
    LANGUAGE 'plpgsql'
    COST 100
    VOLATILE SECURITY DEFINER PARALLEL UNSAFE
    ROWS 1000

AS $BODY$
DECLARE

    TMP_RECORD categorydtl;

  IDZ RECORD;

BEGIN
    FOR IDZ IN (SELECT *
                  FROM CATEGORY
                 WHERE CATEGORY_STATUS = '1'
                 ORDER BY CATEGORY_CODE) LOOP

      TMP_RECORD.CATEGORY_CODE := IDZ.CATEGORY_CODE;
      TMP_RECORD.CATEGORY_DESC := IDZ.CATEGORY_DESC;
      RETURN NEXT TMP_RECORD;
    END LOOP;
    RETURN;
  EXCEPTION
    WHEN OTHERS THEN
      RAISE NOTICE '%', SQLERRM;
  END;

$BODY$;
0

There are 0 best solutions below