PL/pgSQL doesn't support variables in queries?

From: "J(dot)A(dot)" <postgresql(at)world-domination(dot)com(dot)au>
To: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: PL/pgSQL doesn't support variables in queries?
Date: 2023-05-03 12:25:55
Message-ID: CALT+_gvfHtF5jqQg+J2suw3hOEh3ZWjZQDB8jJ945o4b1ekyyQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Heya folks :)

ms-sql person here migrating over to pgsql. One of the first thing's I
noticed with pgsql (or more specifically, PL/pgSQL) is that it doesn't
support "variables" in a query?

for example, here's some T-SQL:

DECLARE @fkId INTEGER

SELECT @fkId = fkId FROM SomeTable WHERE id = 1

-- and then do something with that value..

SELECT * FROM AnotherTable WHERE Id = @fkId
SELECT * FROM YetAnotherTable WHERE FKId = @fkId
-- etc..

If I have this information correct, has this concept ever been
discussed before or considered to be included in PL/pgSQL ?

Thank you kindly for any help/conversations on this topic.

Sincere apologies if this is not the correct forum/list to ask this
question.

Regards,

JA.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message hubert depesz lubaczewski 2023-05-03 12:31:16 Re: PL/pgSQL doesn't support variables in queries?
Previous Message Michael J. Baars 2023-05-03 11:11:36 Re: libpq and multi-threading