Click here to Skip to main content
15,867,686 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am just moving to some PostgreSQL from MS-SQL and have checked numerous pages on how to use variables in a script but am getting nowhere

Within pg-admin I have my database and have a new script. I have stripped the SQL right back to a single line as follows:

DECLARE v_syncId integer;


Running this script gives me:
ERROR:  syntax error at or near "integer"
LINE 1: DECLARE v_syncId integer;
                         ^
SQL state: 42601
Character: 18


I am obviously doing something wrong here but can't see what

What I have tried:

I have tried setting default values but no luck (same error)

DECLARE v_syncId integer DEFAULT 50;

DECLARE v_syncId integer = 50;


Both give the same error

I have tried other data types:

DECLARE v_syncId VARCHAR;


and also same result.

Any references here would be appreciated.
Posted
Updated 23-Nov-21 21:10pm

Start with Postgres documentation: PostgreSQL: Documentation: 14: 43.3. Declarations[^] or with tutorial: Introduction to variables in PL/pgSQL[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900