I have several queries in a query window in pgAdmin, many using the same value(s). Is there a way to declare a variable, myVar
to use in query statements?
SELECT * FROM table WHERE user = myVar;
INSERT INTO table(user) VALUES (myVar);
asked Apr 20, 2017 at 23:48
1 Answer 1
A simple example:
DO $$
DECLARE
myVar VARCHAR := myValue;
BEGIN
INSERT INTO table(user) VALUES (myVar);
END $$;
answered Apr 21, 2017 at 1:17
Sign up to request clarification or add additional context in comments.
Comments
lang-sql