0

this is my exam

DO $$DECLARE
 oldName varchar :='old';
 newName varchar := 'new';

BEGIN
....
END$$;

If I run this script get this:

ERROR:  syntax error at or near "DO"
LINE 1: DO $$ DECLARE 

        ^

What I did wrong?

waTeim
  • 8,830
  • 2
  • 35
  • 39

1 Answers1

2

I'd say you are using PostgreSQL 8.4 or older, which does not support DO blocks. You will need to either upgrade, or use CREATE OR REPLACE FUNCTION to create a PL/PgSQL function, then SELECT function_name() to call it.

Always specify your PostgreSQL version in questions.

Craig Ringer
  • 283,586
  • 65
  • 635
  • 730