Home > Enterprise >  Why is RAISE NOTICE not working in Redshift?
Why is RAISE NOTICE not working in Redshift?

Time:09-28

I tried running the following command in the Redshift Query Editor within the console:

RAISE NOTICE 'hello world';

It gives an error:

ERROR: syntax error at or near "RAISE" Position: 1

I've tried the command in both upper and lower case, and have also tried running it from DBeaver in case it was an issue with the console itself. I've also tried it as RAISE INFO. None of these were successful. I have admin permissions on the cluster and am able to run other commands successfully. What might be causing this?

CodePudding user response:

It's a part of PL/pgSQL procedural language used in AWS Redshift stored procedures too. So, you can use it only within stored procedures

You can follow the basic example

CREATE PROCEDURE update_value() AS $$
DECLARE
  value integer := 20;
BEGIN
  RAISE NOTICE 'Value here is %', value;  -- Value here is 20
  value := 50;
  --
  -- Create a subblock
  --
  DECLARE
    value integer := 80;
  BEGIN
    RAISE NOTICE 'Value here is %', value;  -- Value here is 80
  END;

  RAISE NOTICE 'Value here is %', value;  -- Value here is 50
END;
$$ LANGUAGE plpgsql;  

and run it with

call update_value();
  • Related