I would like to use variable for table name in my sql script below. Is possible to do that in different way than i show you below ? I mean without EXECUTE
command? My script select data from one table and move to the another one. I want to avoid escaping quotes in my scripts.
DO $proc$
DECLARE
v_table_name VARCHAR(100) := 'selected_customers';
BEGIN
EXECUTE 'INSERT INTO ' || v_table_name || '(name, surname, address)
SELECT name, surname, address FROM customers
WHERE name ILIKE ''mon%''';
END;
$proc$;