2 Answers
- Newest
- Most votes
- Most comments
0
Hi Jonny,
RAISE is a procedural command. It cannot be used in a SELECT statement. You can use it in a stored procedure, like this :
CREATE OR REPLACE PROCEDURE test_sp(f1 int, f2 int)
AS $$
BEGIN
IF f1>f2 THEN
RAISE INFO '% is greater than %', f1, f2;
ELSE
RAISE EXCEPTION 'Error : % is smaller than %', f1, f2;
END IF;
END;
$$ LANGUAGE plpgsql;
You can call a stored procedure with a CALL command, like this :
call test_sp(2,1);
I hope this helps.
Ethan
answered 5 years ago
0
Hi Jonny,
You may use "RAISE" in Procedure , like below:
CREATE OR REPLACE PROCEDURE return_example(a int)
AS $$
BEGIN
FOR b in 1..10 LOOP
IF b < a THEN
RAISE INFO 'b = %', b;
ELSE
RETURN;
END IF;
END LOOP;
END;
$$ LANGUAGE plpgsql;
[] Supported PL/pgSQL statements - RAISE - https://docs.aws.amazon.com/redshift/latest/dg/c_PLpgSQL-statements.html#r_PLpgSQL-messages-errors
answered 5 years ago
Relevant content
- asked a year ago
- asked 6 years ago
- asked 10 months ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated a year ago
- How do I raise the priority of agent to agent or agent to queue transferred calls in Amazon Connect?AWS OFFICIALUpdated 3 years ago
- AWS OFFICIALUpdated 6 months ago