0

I am getting a strange error on SQL console (Postgres)

DECLARE v_haha varchar(20); // This is where it's happening
v_haha := "haha"; 
SELECT v_haha;

I'm not a Postgres expert as I am trying to convert my MSSQL scripts to Postgres for some project. But I am slightly confused by this error as the Postgres docs don't seem to mention anything specific about having any cursors.

ha9u63a7
  • 6,233
  • 16
  • 73
  • 108
  • 1
    Is this PL/pgSQL or what are you actually doing? This is not SQL. The error you are getting is from misusing `cursor` declaration --- https://www.postgresql.org/docs/current/sql-declare.html – user3427419 Aug 23 '19 at 17:29
  • Do not confuse SQL, T-SQL and PL/pgSQL. What you trying to do is something like T-SQL which PostgreSQL does not supports. – Abelisto Aug 23 '19 at 17:32
  • What is the real problem are your trying to solve here? The code you have shown does not make any sense. You should show us the complete function, not just a part of it –  Aug 23 '19 at 17:33
  • Probably related: https://stackoverflow.com/questions/1490942/how-to-declare-a-variable-in-a-postgresql-query –  Aug 23 '19 at 17:37
  • I think i've already mentioned that I am trying to convert a MS SQL script to PostGreSQL for migration. But yes, I understood the point regarding PSQL's support for declaring variables. I will look for alternatives such as importing data using CSV. – ha9u63a7 Aug 24 '19 at 14:33

0 Answers0