79526318

Date: 2025-03-21 18:25:30
Score: 1
Natty:
Report link

The declaration of an anonymous block is wrong, you should use DO $$ and END $$. In sql use INTEGER, plpgsql only accepts the integer keyword. This is how you should write.

 DO $$ 
DECLARE 
    c INTEGER;
BEGIN
    EXECUTE 'SELECT count(1) FROM my_dwh.accounts' INTO c;
    RAISE NOTICE 'Count: %', c;
END $$;

I hope this is the answer you are looking for.

Reasons:
  • Has code block (-0.5):
  • Unregistered user (0.5):
  • Low reputation (1):
Posted by: Andy