Sara Harris <sarah(at)ips(dot)gov(dot)il> writes:
> 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?
You don't. You need to use plpgsql if you need declared variables.
In practice, if you're coding in a style that would require local
variables, you're almost certainly going to need plpgsql anyway,
since plain SQL hasn't got any control structures either.
regards, tom lane
In response to
pgsql-novice by date
|Next:||From: Tom Lane||Date: 2012-01-01 18:08:06|
|Subject: Re: ERROR: invalid input syntax for integer: SQL state: 22P02 |
|Previous:||From: Jean-Yves F. Barbier||Date: 2012-01-01 17:40:59|
|Subject: Re: is it normal behavior of index?|