How to declare a variable in a postgresql query in sql language ? - Mailing list pgsql-novice

From Sara Harris
Subject How to declare a variable in a postgresql query in sql language ?
Date
Msg-id 5FB88A6E864A254D8E81C2CB9707E8E88E355A54@RMLMB2.ips.gov.il
Whole thread Raw
Responses Re: How to declare a variable in a postgresql query in sql language ?  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-novice

In MS SQL Server I can do this:

DECLARE @myvar INT 
SET @myvar = 5 
 
SELECT * 
FROM somewhere 
WHERE something = @myvar 

How do I do the same in PostgreSQL in sql language? According to the documentation are declared simply as "name type;", but this gives me a syntax error:

myvar INTEGER; 

 

pgsql-novice by date:

Previous
From: "Jean-Yves F. Barbier"
Date:
Subject: is it normal behavior of index?
Next
From: Andreas Kretschmer
Date:
Subject: Re: is it normal behavior of index?