I'm trying to do an
INSERT INTO a table whose name is in the variable
In MySQL, I'd do it like this:
SET @SQL = CONCAT('INSERT INTO ',myschema'.'mytable,' SELECT action_name, user, ...'); PREPARE stmt FROM @SQL; EXECUTE stmt; DEALLOCATE PREPARE stmt;
I checked into postgreSQL documentation for prepared statements, and I couldn't find any similar examples.
I can assemble query into a string:
sql_query := 'INSERT INTO ' || mySchema || '.' || myTable || ' SELECT action_name, user, ';
But how do I execute it?