v bhosale
v bhosale

Reputation: 73

Postgres multiple statements excution in block

I am using the below function to drop a table and create it. After I execute the function, the table is not created. Can someone please help me?

CREATE OR REPLACE FUNCTION dropAggTables111(tablename TEXT) RETURNS INTEGER AS $total$
DECLARE
total integer;   

BEGIN
 execute 'DROP TABLE IF EXISTS CURR_ACT_IN_EXP_TMP ' into total;     
 execute 'CREATE TABLE IF NOT EXISTS CURR_ACT_IN_EXP_TMP (ACTIVITY VARCHAR(32)) ' into total;

RETURN total;
END;
 $total$ LANGUAGE plpgsql;

Upvotes: 0

Views: 421

Answers (1)

Laurenz Albe
Laurenz Albe

Reputation: 247270

Remove the INTO total. These statements don't return a result set.

Upvotes: 1

Related Questions