I'd like to generate queries dynamically in Postgres 9.5.
This is my table :
| id | ObjectType | content |
-----+-------------+--------------------------------
| 1 | test | {"test_name": "test object"} |
----------------------------------------------------
This is my query
DO $$
DECLARE name text;
DECLARE label text;
BEGIN
select 'test' into name;
select 'test object' into label;
insert into "Constantes" (objecttype,content) values ('test','{"test_name":"test object"}')
END $$;
I'l like, in the insert query, to replace 'test' by the var 'name' and replace 'test_name' by
name+ '_name
And finally replace 'test object' by the label variable.
I didn't manage to, I tried to use + operator, || operator but nothing works.
My goal is only to change 'name' and 'label' variables because I need to execute this query a lot of times with different values.