Tuesday 11 August 2020

How To Create A Stored Procedure With Parameter Modes IN INOUT OUT Modes...



How To Create A Stored Procedure With Parameter Modes IN INOUT OUT Modes In Postgresql || PL/pgSQL

Only 3.9% of viewers are subscribing to my channel 😓.
I request you to please give click on Subscribe button.
It really helps me grow 😢.



-- purpose is to create a stored procedure with parameter mode (IN, INOUT) and call it



-- IN Only Input and it is default



-- OUT Only Output, only OUT is not allowed in Stored Procedure in PostgreSQL



-- INOUT Input + Output



CREATE OR REPLACE PROCEDURE public.testing_procedure(p_num1 IN numeric,p_num2 IN numeric, p_sum INOUT numeric)

LANGUAGE 'plpgsql'

AS $BODY$

DECLARE

BEGIN

p_sum := p_num1 + p_num2;

END;

$BODY$;



CALL public.testing_procedure(13,10,-1);









CREATE OR REPLACE PROCEDURE public.testing_procedure(p_num1 IN numeric,p_num2 IN numeric, p_sum INOUT numeric,p_mult INOUT numeric)

LANGUAGE 'plpgsql'

AS $BODY$

DECLARE

BEGIN

p_sum := p_num1 + p_num2;

p_mult := p_num1 * p_num2;

END;

$BODY$;



CALL public.testing_procedure(3,0,-1,-1);

No comments:

Post a Comment