In mysql REPL it's possible to do something like this:
set @x = 1;
set @d = (select now());
select @x, @d;
+------+---------------------+
| @x | @d |
+------+---------------------+
| 1 | 2018-11-22 16:38:11 |
+------+---------------------+
Now I try to do same in postgresql REPL. I've found this:
set var.x = 1;
select current_setting('var.x');
And it works, but I can't find the way how to store query result into variable. I've tried this:
set var.d = (select now());
ERROR: syntax error at or near "("
LINE 1: set var.d = (select now());
^
select now() into var.d;
ERROR: schema "var" does not exist
select now() into d;
-- creates new table, which is wrong
d := select now();
ERROR: syntax error at or near "d"
LINE 1: d := select now();
Could you please help find the solution? I'm ussing psql (PostgreSQL) 10.5.