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
  • 9,095
  • 2
  • 37
  • 40

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
  • 307,061
  • 76
  • 688
  • 778