Raise_Application_Error

51 views
Skip to first unread message

Thomas Morgan

unread,
Jan 13, 2024, 5:51:43 PM1/13/24
to Better Oracle functions support
It would seem to me that following could be a close suitable replacement for Oracle's equivalent:

    CREATE OR REPLACE PROCEDURE Raise_Application_Error
    (
       SqlState_In NUMBER,
       Error_Message_In VARCHAR2
)
LANGUAGE plpgsql AS $$
BEGIN
  RAISE '%', Error_Message_In USING ERRCODE = SqlState_In;
END;
$$;

But then, since I don't see it in Orafce, it makes me wonder.

Am I totally off?  Any ideas?

Thanks

Thomas Morgan

unread,
Jan 13, 2024, 6:37:54 PM1/13/24
to Better Oracle functions support
A small modification because looks to me that Postgresql does not support negative sqlstate values:

    CREATE OR REPLACE PROCEDURE Raise_Application_Error2(SqlState_In NUMBER, Error_Message_In VARCHAR2) LANGUAGE plpgsql AS $$
    BEGIN
        RAISE EXCEPTION '%', Error_Message_In USING ERRCODE = ABS(SqlState_In);
    END;
    $$;

Pavel Stehule

unread,
Jan 14, 2024, 2:41:49 AM1/14/24
to orafce-...@googlegroups.com
Hi

ne 14. 1. 2024 v 0:37 odesílatel Thomas Morgan <thomasmorg...@gmail.com> napsal:
A small modification because looks to me that Postgresql does not support negative sqlstate values:

    CREATE OR REPLACE PROCEDURE Raise_Application_Error2(SqlState_In NUMBER, Error_Message_In VARCHAR2) LANGUAGE plpgsql AS $$
    BEGIN
        RAISE EXCEPTION '%', Error_Message_In USING ERRCODE = ABS(SqlState_In);
    END;
    $$;

The PLpgSQL statement RAISE has a lot of parameters, so can be unclear what parameters should be passed. Moreover this can be easily wrapped (anybody can write their own function) without performance impacts.

Regards

Pavel
 

On Saturday, January 13, 2024 at 2:51:43 PM UTC-8 Thomas Morgan wrote:
It would seem to me that following could be a close suitable replacement for Oracle's equivalent:

    CREATE OR REPLACE PROCEDURE Raise_Application_Error
    (
       SqlState_In NUMBER,
       Error_Message_In VARCHAR2
)
LANGUAGE plpgsql AS $$
BEGIN
  RAISE '%', Error_Message_In USING ERRCODE = SqlState_In;
END;
$$;

But then, since I don't see it in Orafce, it makes me wonder.

Am I totally off?  Any ideas?

Thanks

--
You received this message because you are subscribed to the Google Groups "Better Oracle functions support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to orafce-genera...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/orafce-general/eaf1bf98-4118-4b52-8e2a-92fb37a4f630n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages