Showing posts with label stored procedure. Show all posts
Showing posts with label stored procedure. Show all posts

Sunday, 24 March 2024

How To Call A PostgreSQL Stored Procedure From pgAgent Schedule In pgAge...



🔍 𝐋𝐞𝐚𝐫𝐧 𝐡𝐨𝐰 𝐭𝐨 𝐚𝐮𝐭𝐨𝐦𝐚𝐭𝐞 𝐲𝐨𝐮𝐫 𝐃𝐁 𝐭𝐚𝐬𝐤𝐬 𝐰𝐢𝐭𝐡 𝐩𝐠𝐀𝐠𝐞𝐧𝐭 𝐚𝐧𝐝 𝐏𝐨𝐬𝐭𝐠𝐫𝐞𝐒𝐐𝐋! 🔍

In this comprehensive tutorial, I will guide you through the process of calling a PostgreSQL stored procedure from the pgAgent scheduler using the pgAdmin tool. Automating database tasks can significantly enhance your productivity and ensure your database operations run smoothly without manual intervention.

In this video, you’ll learn:

Introduction to pgAgent and pgAdmin: Understand what pgAgent is, why it’s used, and how it integrates with pgAdmin for automating PostgreSQL tasks.

Setting Up pgAgent: Step-by-step instructions on how to install and configure pgAgent in your PostgreSQL environment.

Creating Stored Procedures in PostgreSQL: Learn how to write and create stored procedures in PostgreSQL that can be called by pgAgent jobs.

Scheduling Jobs with pgAgent: Detailed guidance on setting up pgAgent jobs to call your PostgreSQL stored procedures. This includes configuring job schedules, defining job steps, and managing job execution.

Executing and Managing Jobs in pgAdmin: Practical examples and walkthroughs on how to monitor, manage, and troubleshoot pgAgent jobs within the pgAdmin interface.

Best Practices and Tips: Gain insights into best practices for scheduling jobs, ensuring reliability, and optimizing performance in PostgreSQL using pgAgent.

By the end of this tutorial, you’ll have a solid understanding of how to automate your PostgreSQL database tasks using pgAgent, enhancing your workflow and database management capabilities.

🎥 Watch the full video [here]

If you find this tutorial helpful, please like the video, share it with others who might benefit, and subscribe to my channel for more tech tutorials and database management tips!

🔔 Stay updated with the latest content by clicking the notification bell so you never miss an upload!

Feel free to leave any questions or feedback in the comments section below—I’d love to hear from you and help you with any challenges you’re facing.

PostgreSQL, pgAgent, stored procedure, pgAgent scheduler, pgAdmin, database automation, call stored procedure, PostgreSQL tutorial, job scheduling, database management, automate PostgreSQL, pgAgent jobs, database tasks

PostgreSQL, pgAgent, stored procedure, pgAdmin, database automation, job scheduling, PostgreSQL tutorial, call stored procedure, automate database tasks, database management, pgAgent jobs, pgAgent setup, PostgreSQL stored procedure, database scheduler

Thank you for watching and supporting the channel!


Select * from jobs order by 1 desc;

delete from jobs;

CREATE OR REPLACE PROCEDURE public.job_proc()
LANGUAGE 'plpgsql'
AS $BODY$
DECLARE
BEGIN
Insert into jobs (entry_job) values (now());
END;
$BODY$;

Sunday, 20 August 2023

How To Call A Stored Procedure/Function From A Trigger Function In Postg...


In this tutorial, you will learn how to call a stored procedure or function from a trigger function in PostgreSQL. This video is designed for developers and database administrators who want to automate tasks or enforce business rules by leveraging the power of triggers in PostgreSQL. We'll begin by explaining what triggers are and how they work within a PostgreSQL database. Next, we'll walk you through the process of creating a trigger function that can invoke a stored procedure or function whenever a specific event occurs in your database, such as an insert, update, or delete operation. You'll see practical examples and gain insights into how this powerful feature can enhance your database applications. By the end of this tutorial, you'll be confident in your ability to implement triggers that call stored procedures or functions, adding a new level of automation and functionality to your PostgreSQL projects.

PostgreSQL triggers, stored procedure PostgreSQL, function PostgreSQL, call stored procedure from trigger, PostgreSQL tutorial, trigger function PostgreSQL, PostgreSQL automation, database triggers, SQL tutorial, PostgreSQL functions, PostgreSQL stored procedures, PostgreSQL 16, SQL triggers, PostgreSQL trigger examples, database management, PostgreSQL development, SQL server, trigger stored procedure, PostgreSQL database, PostgreSQL trigger function tutorial

Please Like, Comment, and Subscribe to my channel. ❤

Working with triggers is fun and learning. There are endless possibilities that can be achieved through Triggers.

This time, I have explained the usage of Triggers to call other stored procedures or functions in PostgreSQL Trigger Functions.


#trigger #procedure #function #postgresql #database


CREATE TABLE students
(
    roll numeric(10,0),
    name character varying(30),
    course character varying(30)
);


CREATE OR REPLACE PROCEDURE 
trigger_proc(in_value1 IN numeric, in_value2 IN numeric, out_result OUT numeric)
LANGUAGE 'plpgsql'
AS $BODY$
Declare
lv_msg CHARACTER varying(100);
Begin
  out_result := in_value1 + in_value2;
exception
when others then
lv_msg := 'Error : '||sqlerrm;
raise notice '%',lv_msg;
end;
$BODY$;


CREATE OR REPLACE FUNCTION 
trigger_func(in_value1 IN numeric, in_value2 IN numeric) returns numeric
LANGUAGE 'plpgsql'
AS $BODY$
Declare
lv_msg CHARACTER varying(100);
out_result numeric (10);
Begin
  out_result := in_value1 + in_value2;
return out_result;
exception
when others then
lv_msg := 'Error :'||sqlerrm;
raise notice '%',lv_msg;
end;
$BODY$;


CREATE OR REPLACE FUNCTION student_logs_trg_func()
    RETURNS TRIGGER
    LANGUAGE 'plpgsql'
AS $BODY$
declare
lv_out_proc numeric(10);
lv_out_func numeric(10);
begin
call trigger_proc(50, 50, lv_out_proc);
lv_out_func := trigger_func(100, 100);
raise notice 'Proc Output: %',lv_out_proc;
raise notice 'Func Output: %',lv_out_func;
return new;
end;
$BODY$;


CREATE TRIGGER student_trg
    BEFORE INSERT OR DELETE OR UPDATE 
    ON students
    FOR EACH ROW
    EXECUTE FUNCTION student_logs_trg_func();

Insert into students values (1, 'Akram', 'MCA');


How To Call A Stored Procedure/Function From A Trigger Function In PostgreSQL
How To Call A Stored Procedure From A Trigger Function
Trigger Function In PostgreSQL
How To Call Stored Function From Trigger Function
Trigger In PostgreSQL
Call Procedure From Trigger
Call Function From Trigger
Procedure Call From Trigger In PostgreSQL
Function Call From Trigger In PostgreSQL
PostgreSQL Triggers
Triggers
Trigger Example PostgreSQL
How To Triggers PostgreSQL

Thursday, 18 August 2022

How To Create Sequence In PostgreSQL And Usage Of Sequence || Table Prim...


Sequences in PostgreSQL are a powerful tool for managing auto-incrementing values, often used for primary keys in tables or as a part of stored procedures to maintain data consistency and integrity. In this comprehensive tutorial, we walk you through the process of creating and using sequences in PostgreSQL, ensuring you have the skills to implement them effectively in your database projects.

The video starts with an introduction to sequences, explaining what they are and why they are essential in PostgreSQL. We then provide step-by-step instructions on how to create a sequence, from the basic SQL commands to more advanced options that allow you to customize how your sequence behaves.

Next, we explore the practical applications of sequences, particularly how they can be linked to table columns as primary keys, ensuring that each new entry automatically receives a unique value. This is a crucial aspect of database management, as it helps maintain data integrity and avoid conflicts in primary key values.

We also dive into how sequences can be utilized within stored procedures, allowing for dynamic data operations that can adapt to changing conditions within your database. Whether you’re automating tasks or managing large datasets, understanding how to integrate sequences into your stored procedures will make your database operations more efficient and robust.

This tutorial is essential for anyone looking to deepen their PostgreSQL knowledge, particularly in areas related to database management and stored procedures. By the end of the video, you'll be equipped with the skills to create, manage, and utilize sequences effectively in your PostgreSQL databases.

PostgreSQL sequence, create sequence PostgreSQL, sequence usage PostgreSQL, PostgreSQL primary key, auto-increment PostgreSQL, PostgreSQL stored procedure, database management, SQL sequence, PostgreSQL tutorial, pgAdmin sequence


How To Create Sequence In PostgreSQL And Usage Of Sequence || Table Primary Key || Stored Procedure

CREATE SEQUENCE tbl_emp_seq
START WITH 1 -- VALUE WILL START WITH 1
INCREMENT BY 1 -- IT WILL GET INCREMENT BY 1
MINVALUE 1 -- MINIMUM VALUE CAN BE 1
MAXVALUE 10 -- MAXIMUM VALUE CAN BE 10
CYCLE; -- CYCLE MEANS, AFTER REACHING MAXVALUE, WHICH IS 10 HERE, THE SEQUENCE WILL START AGAIN FROM 1
-- NOW LET'S SEE THE SEQUENCE VALUE
-- USE THE BELOW STATEMENT FOR SEQUENCE VALUE

SELECT NEXTVAL('tbl_emp_seq');

-- THE VALUE REACHED MAXVALUE, NOW IT WILL AGAIN START FROM 1

-- NOW LET'S SEE THE CASE OF NO CYCLE
-- IN CASE OF NO CYCLE, THE SEQUENCE WON'T START AGAIN FROM 1
-- IT WILL THROW AN ERROR AFTER REACHING THE MAX VALUE

DROP SEQUENCE tbl_emp_seq;


CREATE SEQUENCE tbl_emp_seq
START WITH 1 -- VALUE WILL START WITH 1
INCREMENT BY 1 -- IT WILL GET INCREMENT BY 1
MINVALUE 1 -- MINIMUM VALUE CAN BE 1
MAXVALUE 10 -- MAXIMUM VALUE CAN BE 10
NO CYCLE; 


SELECT NEXTVAL('tbl_emp_seq');

-- HERE THE MAX VALUE IS REACHED, SO IF WE TRY TO GET THE VALUE AFTER THAT, WE WILL GET AN ERROR

ERROR:  nextval: reached maximum value of sequence "tbl_emp_seq" (10)
SQL state: 2200H

-- THIS IS WHY WE USUALLY KEEP THE MAXVALUE VERY HIGH AS MUCH POSSIBLE

-- NOW LET'S CREATE AN ACTUAL SEQUENCE AND USE IN A TABLE TO GENERATE VALUES AUTOMATICALLY

CREATE SEQUENCE tbl_emp_seq
START WITH 1 -- VALUE WILL START WITH 1
INCREMENT BY 1 -- IT WILL GET INCREMENT BY 1
MINVALUE 1 -- MINIMUM VALUE CAN BE 1
MAXVALUE 10000000000 -- MAXIMUM VALUE CAN BE 10
NO CYCLE; 


CREATE TABLE EMP
(
EMP_ID INTEGER DEFAULT NEXTVAL('tbl_emp_seq'),
EMP_NAME VARCHAR(50),
SALARY NUMERIC(5,2)
);

INSERT INTO EMP(EMP_NAME,SALARY) VALUES ('AKRAM',100.56);
INSERT INTO EMP(EMP_NAME,SALARY) VALUES ('SOHAIL',670.56);
INSERT INTO EMP(EMP_NAME,SALARY) VALUES ('KNOWLEDGE 360',757.87);

SELECT * FROM EMP;

-- WE CAN SEE, THE EMP_ID VALUES ARE GENERATED FROM SEQUENCE

-- NOW LET'S USE THE SEQUENCE IN A STORED PROCEDURE

CREATE OR REPLACE PROCEDURE public.EMP_PROC()
LANGUAGE 'plpgsql'
AS $BODY$
DECLARE
V_EMP_SEQ_VAL INTEGER;
BEGIN
SELECT NEXTVAL('tbl_emp_seq') into V_EMP_SEQ_VAL;
insert into emp(emp_id,emp_name,salary) values (V_EMP_SEQ_VAL,'New Emp',455.24);
END;
$BODY$;

call public.EMP_PROC();

select * from emp;

SELECT NEXTVAL('tbl_emp_seq');

SELECT CURRVAL('tbl_emp_seq');

-- also we can see the current value of a sequence

-- If you have any doubt, please ask me in the comments.
-- Subscribe the channel to get the videos updates.

Sunday, 17 July 2022

How To Call A Stored Procedure From A Schedule Job Using pgAgent Jobs In...


In this tutorial, we dive into the world of automating PostgreSQL tasks by calling a stored procedure from a scheduled job using pgAgent in PostgreSQL. PgAgent is a powerful job scheduling tool that integrates seamlessly with PostgreSQL, allowing you to automate repetitive tasks such as running stored procedures, backups, and more.

We begin by guiding you through the setup of pgAgent in pgAdmin, ensuring that you have the necessary environment to start automating your database operations. Then, we move on to creating a stored procedure that performs a specific task within your database. This stored procedure will later be triggered automatically by a scheduled job.

The tutorial provides a step-by-step demonstration of how to create and configure pgAgent Jobs. You’ll learn how to set up schedules, define the tasks that need to be performed, and link these tasks to your stored procedures. We also discuss the various options available within pgAgent, such as setting execution frequency, handling job success or failure, and logging the job outcomes.

Additionally, we explore practical use cases where automating stored procedure execution can significantly enhance your database management strategy. Whether it’s for regular maintenance tasks, complex data manipulations, or timed reports, pgAgent Jobs provide a reliable and efficient solution.

By the end of this video, you'll have a solid understanding of how to use pgAgent to automate stored procedure calls in PostgreSQL, helping you streamline your database operations and save time.

PostgreSQL pgAgent jobs, call stored procedure pgAgent, PostgreSQL automation, pgAdmin scheduled jobs, PostgreSQL job scheduler, automate PostgreSQL tasks, PostgreSQL tutorial, pgAgent setup, stored procedures, SQL automation


In this video, we will see how to schedule a stored procedure
to call in pgAgent Jobs

In the last video, we have seen how to schedule a job.
In this video, we will call a stored procedure.

So, let's start.

How To Call A Stored Procedure From A Schedule Job Using pgAgent Jobs In PostgreSQL Database pgAdmin || PostgreSQL pgAgent 



-- Creating a table

CREATE TABLE public.emp
(
    id numeric,
    name character(30),
    salary numeric,
insert_date timestamp without time zone DEFAULT CURRENT_TIMESTAMP
);



-- Now we will create a stored procedure

CREATE OR REPLACE PROCEDURE public.testing_procedure()
LANGUAGE 'plpgsql'
AS $BODY$
DECLARE
BEGIN
Insert into emp(id,name,salary) values(1,'Akram Sohail',100);
Insert into emp(id,name,salary) values(2,'Knowledge 360',200);
END;
$BODY$;

CALL public.testing_procedure();

-- When this procedure will be called, two entries will be there in the Emp table.

-- Let's do it through a scheduled job using pgAgent Jobs

-- We have scheduled the procedure to be called every minute, every hour, every day, and all.

-- the First scheduler will be executed at 11:30 PM IST.
-- So, let's forward the video and wait.

Select * from emp;

-- There is no record as of now because the scheduler is not executed by now.
-- waiting...

-- We get two records at 11:30 PM as we can see from a timestamp.
-- Now, again new entries will come at 11:31 PM

-- So, our schedule job is working.
-- All the source codes and notes are in the description.
-- Please subscribe to my channel...Thank you :)




DO $$
DECLARE
    jid integer;
    scid integer;
BEGIN
-- Creating a new job
INSERT INTO pgagent.pga_job(
    jobjclid, jobname, jobdesc, jobhostagent, jobenabled
) VALUES (
    1::integer, 'New_Job'::text, 'This job will be used to call a stored procedure.'::text, ''::text, true
) RETURNING jobid INTO jid;

-- Steps
-- Inserting a step (jobid: NULL)
INSERT INTO pgagent.pga_jobstep (
    jstjobid, jstname, jstenabled, jstkind,
    jstconnstr, jstdbname, jstonerror,
    jstcode, jstdesc
) VALUES (
    jid, 'Step1'::text, true, 's'::character(1),
    ''::text, 'postgres'::name, 'f'::character(1),
    'CALL public.testing_procedure(); -- Calling the stored procedure'::text, 'This is Step1'::text
) ;

-- Schedules
-- Inserting a schedule
INSERT INTO pgagent.pga_schedule(
    jscjobid, jscname, jscdesc, jscenabled,
    jscstart, jscend,    jscminutes, jschours, jscweekdays, jscmonthdays, jscmonths
) VALUES (
    jid, 'Scheduler1'::text, 'The Scheduler'::text, true,
    '2022-07-17 23:30:00+05:30'::timestamp with time zone, '2022-07-31 23:31:00+05:30'::timestamp with time zone,
    -- Minutes
    ARRAY[true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true]::boolean[],
    -- Hours
    ARRAY[true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true]::boolean[],
    -- Week days
    ARRAY[true,true,true,true,true,true,true]::boolean[],
    -- Month days
    ARRAY[true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true]::boolean[],
    -- Months
    ARRAY[true,true,true,true,true,true,true,true,true,true,true,true]::boolean[]
) RETURNING jscid INTO scid;
END
$$;




How To Call A Stored Procedure From A Schedule Job Using pgAgent Jobs,
How To Call A Stored Procedure From A Schedule Job Using pgAgent Jobs In PostgreSQL Database pgAdmin,
PostgreSQL Database pgAdmin,
PostgreSQL,
pgAgent,
Call A Stored Procedure,
Call A Stored Procedure From A Schedule Job,
Stored Procedure From A Schedule Job,
Schedule Job Using pgAgent Jobs,
Call A Stored Procedure,
Call A Stored Procedure From A pgAgent Jobs,
How To Call A Stored Procedure,
PostgreSQL Database,
Knowledge 360,
Akram Sohail,
Postgres,
database,
stored procedure,
procedure

Tuesday, 11 August 2020

How To Create A Stored Procedure And Return Multiple Values From The Sto...



-- purpose is to return multiple values (more than one value) from a stored procedure

-- in PostgreSQL


How To Create A Stored Procedure And Return Multiple Values From The Stored Procedure In PostgreSQL

In this comprehensive tutorial, we’ll show you how to create a stored procedure in PostgreSQL that returns multiple values. Stored procedures are an essential tool in database management, allowing you to encapsulate complex logic and reuse it throughout your applications.

We begin by explaining the basics of stored procedures in PostgreSQL, including the syntax and the different ways to return values. You’ll learn how to declare variables, use the OUT parameters, and return multiple results from a single procedure. We’ll also cover how to call the stored procedure from pgAdmin and SQL Shell (psql), making sure you’re comfortable executing these procedures in different environments.

This video is ideal for developers, database administrators, and anyone looking to deepen their understanding of PostgreSQL. By the end of the tutorial, you’ll have the skills to create your own stored procedures that can return multiple values, enhancing the efficiency and flexibility of your database operations.

PostgreSQL, stored procedure, multiple values, PostgreSQL tutorial, PLpgSQL, pgAdmin, database development, SQL commands, database management, returning multiple values


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

LANGUAGE 'plpgsql'

AS $BODY$

DECLARE

BEGIN

p_sum := p_num1 + p_num2;

p_mult := p_num1 * p_num2;

BEGIN

p_div := p_num1/p_num2;

EXCEPTION WHEN OTHERS THEN

p_div := 0;

END;

END;

$BODY$;



CALL public.testing_procedure(10,0,null,null,0);







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

LANGUAGE 'plpgsql'

AS $BODY$

DECLARE

BEGIN

p_sum := p_num1 + p_num2;

p_mult := p_num1 * p_num2;

BEGIN

p_div := p_num1/p_num2;

EXCEPTION WHEN OTHERS THEN

p_div := 'You cannot divide a value by zero';

END;

END;

$BODY$;



CALL public.testing_procedure(10,0,null,null,'0');


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

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

In this video tutorial, you’ll learn how to create stored procedures in PostgreSQL using different parameter modes: IN, INOUT, and OUT. These parameter modes are crucial for controlling the flow of data within your stored procedures and can greatly enhance the flexibility and power of your database functions.

We start by explaining the purpose of each parameter mode:

  • IN: This mode allows you to pass data into the procedure.
  • OUT: This mode is used to return data from the procedure.
  • INOUT: This mode allows a parameter to be passed in and modified within the procedure, then returned.

After covering the basics, we dive into practical examples where you’ll see how to implement these modes in a stored procedure using PL/pgSQL. You’ll also learn how to call these procedures from pgAdmin and SQL Shell (psql), ensuring you can apply these techniques in real-world scenarios.

This tutorial is designed for database administrators, developers, and anyone interested in advancing their PostgreSQL knowledge. By the end of this video, you’ll have a solid understanding of how to use parameter modes effectively within your stored procedures, allowing for more dynamic and reusable database functions.

PostgreSQL, stored procedure, parameter modes, IN parameter, OUT parameter, INOUT parameter, PLpgSQL, PostgreSQL tutorial, database management, SQL commands, pgAdmin


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);

How To Create A Stored Procedure And Insert Data Into A Table By Calling...




How To Create A Stored Procedure And Insert Data Into A Table By Calling/Using The Stored Procedure

In this tutorial, you’ll master the process of creating a stored procedure in PostgreSQL and learn how to insert data into a table by calling this procedure. Stored procedures are essential for encapsulating complex SQL operations, and this video will guide you through each step of the process.

We begin by introducing the concept of stored procedures and their benefits, particularly in terms of code reuse and simplifying database management. You'll see a detailed explanation of how to define a stored procedure in PL/pgSQL, the procedural language of PostgreSQL.

Next, we focus on a practical example: creating a stored procedure that inserts data into a specific table. This part of the video will show you:

  • How to declare the procedure.
  • How to define the input parameters that will pass the data to be inserted.
  • How to write the SQL commands within the procedure to perform the data insertion.

Finally, you’ll learn how to call this stored procedure from both pgAdmin and SQL Shell (psql), ensuring that you can apply this knowledge in your daily database management tasks.

This tutorial is perfect for database administrators, developers, and anyone looking to improve their PostgreSQL skills. By the end of the video, you’ll have the knowledge to efficiently create and utilize stored procedures for data manipulation in PostgreSQL.

PostgreSQL, stored procedure, insert data, SQL, table insertion, PLpgSQL, PostgreSQL tutorial, database management, pgAdmin, SQL Shell, data manipulation

-- the purpose is to create a simple stored procedure in PostgreSQL

-- and Insert Data in the table by calling it using pgAdmin
CREATE TABLE public.testing_table (dummy_column text);
CREATE OR REPLACE PROCEDURE public.testing_procedure(p_msg text)
LANGUAGE 'plpgsql'
AS $BODY$
DECLARE
BEGIN
INSERT INTO public.testing_table(dummy_column) VALUES('Before Inserting Parameter Value');
INSERT INTO public.testing_table(dummy_column) VALUES (p_msg);
INSERT INTO public.testing_table(dummy_column) VALUES('After Inserting Parameter Value');
END;
$BODY$;
SELECT * FROM public.testing_table;
DELETE from public.testing_table;

CALL public.testing_procedure('Hello Akram, How are you?');
Before Inserting
the message I pass as a parameter
After Inserting...