> On Jan 13, 2024, at 13:08, Thomas Morgan <
thomasmorg...@gmail.com> wrote:
>
> We are in the process of evaluating our system for migration from Oracle to Postgresql and one of the differences is how TOO_MANY_ROWS behaves. According to a post I found, it claimed that it would work exactly as Oracle if I added the word STRICT before the INTO clause, so I created following scenario which does not see to work:
The STRICT keyword follows the INTO. Why you didn't get a syntax error otherwise is an excellent question, though.
xof=# CREATE TABLE ZTM_1(A VARCHAR(1));
CREATE TABLE
xof=# CREATE OR REPLACE PROCEDURE Get_Too_Many_Rows() AS $$
DECLARE
v_into VARCHAR(4000);
BEGIN
DELETE FROM ZTM_1;
INSERT INTO ZTM_1(A) VALUES('A');
INSERT INTO ZTM_1(A) VALUES('B');
--
SELECT A INTO STRICT v_into FROM ZTM_1;
--
RAISE NOTICE '%', v_into;
EXCEPTION
WHEN TOO_MANY_ROWS THEN
RAISE EXCEPTION 'Too Many';
END;
$$ LANGUAGE plpgsql;
CREATE PROCEDURE
xof=# CALL Get_Too_Many_Rows();
ERROR: Too Many
CONTEXT: PL/pgSQL function get_too_many_rows() line 14 at RAISE