I am trying to run a query in a PostgreSQL client (Postico) and an experiencing nothing but frustration for what I assumed would be a fairly straightforward task, as it is in T-SQL.
My declarations are as follows:
DECLARE vYOU varchar := 'LD',
vSOME_ID int := '9999',
vSOME_THING varchar := 'ABCD.0.1.2',
vSOME_THING2 varchar := 'ABCD.0.0.2',
vSTART_DATE date := '2016-08-23',
vEND_DATE date := '2016-08-24';
The variables are prepended with 'v' and are of course referenced at various points throughout the remainder of my query.
However, this gives me the following error:
Query failed
PostgreSQL said: syntax error at or near "varchar"
I have Googled in vain, checking my datatypes and the general syntax and tried multiple iterations of this, though admittedly I'm not sure about whether I have listed the declared variables correctly. In any case I see various different answers about whether this can or can't be done in PostgreSQL.
Would love a definitive answer as to where I'm going wrong or whether this is even possible.
Thanks in advance.