I want to use a variable within the function so i can grab systemstate from several clients and put them into a local table. It looks like this but now i am stuck with making a part variable
CREATE OR REPLACE FUNCTION schema_test.sync_systemstate(table_name TEXT, dbname TEXT, port int, hostname TEXT, username TEXT, wachtwoord TEXT) returns integer as $$
DECLARE
sql varchar;
BEGIN
sql :='truncate schema_test.' || table_name || '' ;
execute sql;
INSERT INTO schema_test.[variable table name]
SELECT timestamp, component_name, component_type, status, message ...;
RETURN port;
END;
$$ LANGUAGE plpgsql;
The INSERT INTO schema_test.[variable] is not working, well at least i cant make it working. Any suggestions on how to achieve that behind the schem_test comes the variable table name??
truncatestatement. (note that usingformat()is a better way of creating dynamic SQL strings)