1

I'm migrated a schema from oracle to postgreSQL using AWS-SCT, packages are converted to functions in postgreSQL. I need to convert this function to procedure to compact with the code in the application middleware.

I've tried to convert to procedure, everytime i'm getting error like SQL state: 42601 and inout parameter are permitted

Kindly help to convert the function to procedure.

CREATE OR REPLACE Function "pk_audfreq$sp_audfreq"(
    OUT out_a double precision,
    OUT out_b double precision,
    OUT out_c double precision)
    RETURNS record
    LANGUAGE 'plpgsql'
    COST 100
    VOLATILE 
AS $BODY$
DECLARE
BEGIN    
    SELECT
        MIN(audresponsetime), AVG(audresponsetime), MAX(audresponsetime)
        INTO STRICT out_a, out_b, out_c
        FROM public.audio_freq;        
    END;
$BODY$;
7
  • If you want to return something, use a (set returning) function. Procedures aren't meant to return result sets. Commented Mar 31, 2020 at 5:37
  • tried, still giving syntax error SQL state: 42601, Help required to correct the function to procedures in PostgreSQL without syntax error Commented Mar 31, 2020 at 5:42
  • dbfiddle.uk/… Commented Mar 31, 2020 at 5:45
  • 1
    Sure you can use INOUT, but then you have to supply arguments. Why the insistence on using a procedure for something that naturally is a function? Commented Mar 31, 2020 at 6:10
  • 1
    And why the insistence on a function or procedure for a simple statement that would better be encapsulated in a VIEW Commented Mar 31, 2020 at 6:12

1 Answer 1

3

You cannot have OUT parameters with procedures (yet). As the documentation states:

OUT arguments are currently not supported for procedures. Use INOUT instead.

Sign up to request clarification or add additional context in comments.

2 Comments

Cool, I've created a procedure with INOUT, giving an error message inout arguments are permitted
Unless you show the relevant code and the complete error message, it is hard to help.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.