POSTGRES setting variables. Works in PGAdmin. Error in Heidi

enkodellc's profile image enkodellc posted 1 day ago in General Permalink

I wanted to do this in Postgres:

DECLARE @maxdate timestampz SET @maxdate = (SELECT MAX("Date") FROM transactions) SELECT maxdate

To do it in HeidiSQL I ended up having to do the following:

CREATE TEMP TABLE IF NOT EXISTS temp_results (num integer, test_text text);

DO ' DECLARE num integer; test_text text; BEGIN num := 1; test_text := ''Testing''; INSERT INTO temp_results VALUES (num, test_text); END ' LANGUAGE plpgsql;

SELECT * FROM temp_results;

Frustrating not being able to create variables in the editor.

Please login to leave a reply, or register at first.