I have a stored procedure written in a sql file which I want to execute through spring boot code using jdbc template. The stored procedure is like :
CREATE OR REPLACE FUNCTION DELETE_REDUNDANT_RECORDS()
RETURNS void AS
$func$
DECLARE
interval_time BIGINT DEFAULT 0;
min_time BIGINT DEFAULT 0;
max_time BIGINT DEFAULT 0;
rec_old RECORD;
rec_new RECORD;
rec_start RECORD;
v_filename VARCHAR(250);
v_systemuid VARCHAR(50);
is_continous_record BOOLEAN default false;
cursor_file CURSOR FOR
select distinct filename,systemuid from ASP.MONITORING_BOOKMARK_ORIGINAL;
cursor_data CURSOR FOR
select * from ASP.MONITORING_BOOKMARK_ORIGINAL where filename = v_filename and systemuid=v_systemuid order by mindatetime, maxdatetime;
BEGIN
--open the file cursor to fetch the filename and systemuid
OPEN cursor_file;
-- logic for procedure
CLOSE cursor_file;
END;
$func$
LANGUAGE plpgsql;
I have added this in a sql file in my spring boot project. I want to create a scheduler to create and execute this stored procedure using spring jdbc. The database used is Postgres. Is there a way available to do this. I have got references for calling a procedure but what I need is to create and execute the procedure.
Statement.execute(String)