8000 While using EXCEPTION block in trigger function format get misplaced return statment under EXCEPTION block. · Issue #345 · darold/pgFormatter · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
While using EXCEPTION block in trigger function format get misplaced return statment under EXCEPTION block. #345
Open
@bmk9727

Description

@bmk9727

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;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0