Wednesday 16 November 2022

How To Call A Stored Procedure From Another Stored Procedure In PostgreS...


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 😢.




/*In this video we will see how to call a stored procedure 
from another stored procedure in PostgreSQL PLpgSQL*/

-- Please watch till the end, and leave a like-comment.
-- Don't forget to subscribe the channel

CREATE OR REPLACE PROCEDURE public.proc1()
LANGUAGE 'plpgsql'
AS $BODY$
DECLARE
BEGIN
 RAISE NOTICE 'This is proc 1, it will be called from proc2';
END;
$BODY$;

-- This is proc1 I have created
-- This will display the output
-- so, lets create it


CREATE OR REPLACE PROCEDURE public.proc2()
LANGUAGE 'plpgsql'
AS $BODY$
DECLARE
BEGIN
RAISE NOTICE 'This is proc 2';
-- Calling another procedure proc1()
call proc1(); -- here it is
END;
$BODY$;

-- This is proc2
-- I am calling proc1 inside proc2
-- When it gets executed, it should give output like this

-- 'This is proc 2'
-- 'This is proc 1, it will be called from proc2'

-- Now, lets call the procedure

-- In the next video, I will show how to call a parameterized procedure or function with
-- OUT parameter
-- Please subscribe the channel to get updates for such videos

call proc2();

-- As shown, the procedure is getting called from another procedure
-- Thanks for watching
-- Please leave your comment for the video

-- Source codes you will find from video description

No comments:

Post a Comment