Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

While using EXCEPTION block in trigger function format get misplaced return statment under EXCEPTION block. #345

Open
bmk9727 opened this issue Sep 14, 2024 · 0 comments

Comments

@bmk9727
Copy link

bmk9727 commented Sep 14, 2024

While formatting code with pg_format facing issue when my query use EXCEPTION block for trigger. Can someone please help here? I'm missing anything here?

Before format:
image

After format:
image

Code:

CREATE OR REPLACE FUNCTION trigger_before_insert_tg_name ()
    RETURNS TRIGGER
    AS $$
BEGIN
    -- do some operation
    -- Check if the resource_type is list of monitored resources
    RETURN NEW;
EXCEPTION
    -- Catch any errors that occur in the trigger
    WHEN OTHERS THEN
        -- Optionally log the error to another table or perform some action
        RAISE WARNING 'Trigger failed: %', SQLERRM;
        -- Continue without interrupting the original INSERT
        RETURN NEW;
END;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant