Thanks to @John Rotenstein, now I could run Stored Procedure as expected.
Just simple example for someone who has the same issue.
-- Revised Procedure
CREATE OR REPLACE PROCEDURE sp_del_test(tbl_name varchar(50), col_name varchar(50), start_dt date, end_dt date)
AS $PROC$
DECLARE
sql VARCHAR(MAX) := '';
BEGIN
sql := 'DELETE FROM ' || tbl_name || ' WHERE ' || col_name || ' BETWEEN ''' || start_dt || ''' AND ''' || end_dt || '''';
RAISE INFO '%', sql;
EXECUTE sql;
END;
$PROC$ language plpgsql;
-- Executed Commands
Begin;
Call sp_del_test('test_table_b', 'opsdt', '2021-01-23', '2021-01-24');
Commit;
-- Return Message
BEGIN executed successfully
Execution time: 0.05s
Statement 1 of 3 finished
**Warnings:
DELETE FROM test_table_b WHERE opsdt BETWEEN '2021-01-23' AND '2021-01-24'**
0 rows affected
Call executed successfully
Execution time: 0.2s
Statement 2 of 3 finished
COMMIT executed successfully
Execution time: 0.12s
Statement 3 of 3 finished
Script execution finished
Total script execution time: 0.38s
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…