How do I declare a variable for use in a PostgreSQL 8.3 query?
In MS SQL Server I can do this:
DECLARE @myvar INT SET @myvar = 5 SELECT * FROM somew
Here is an example using PREPARE statements. You still can't use ?, but you can use $n notation:
?
$n
PREPARE foo(integer) AS SELECT * FROM somewhere WHERE something = $1; EXECUTE foo(5); DEALLOCATE foo;