How to declare a variable in a postgresql query in sql language ?

Поиск
Список
Период
Сортировка
От Sara Harris
Тема How to declare a variable in a postgresql query in sql language ?
Дата
Msg-id 5FB88A6E864A254D8E81C2CB9707E8E88E355A54@RMLMB2.ips.gov.il
обсуждение исходный текст
Ответы Re: How to declare a variable in a postgresql query in sql language ?
Список 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 по дате отправления:

Предыдущее
От: "Jean-Yves F. Barbier"
Дата:
Сообщение: is it normal behavior of index?
Следующее
От: Andreas Kretschmer
Дата:
Сообщение: Re: is it normal behavior of index?