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

Facing issues in trigger file which is generated by ora2pg #1819

Open
nareneee opened this issue Sep 19, 2024 · 2 comments
Open

Facing issues in trigger file which is generated by ora2pg #1819

nareneee opened this issue Sep 19, 2024 · 2 comments

Comments

@nareneee
Copy link

nareneee commented Sep 19, 2024

Hi Darold

we are facing the below error, please help on this part

1)ERROR: unexpected end of function definition at end of input
LINE 6: $BODY$

syntax

CREATE OR REPLACE FUNCTION trigger_fct() RETURNS trigger AS $BODY$
declare
                BEGIN
                    if ( NEW.chooser_id IS NULL ) then
                      SELECT nextval('column_chooser_seq') into STRICT NEW.chooser_id
$BODY$
LANGUAGE 'plpgsql' SECURITY DEFINER;

the PostgreSQL function definition is incomplete. Specifically, the CREATE FUNCTION statement is missing the closing part of the function body. we need to add this END IF; RETURN NEW; END; to close function body.

2)ERROR: syntax error at or near ""XPERT_VITALITY_TREND_TRIGGER""
LINE 2: BEFORE INSERT ON xpert_vitality_trend "XPERT_VITALIT..

syntax

CREATE TRIGGER xpert_vitality_trend_trigger
        BEFORE INSERT ON xpert_vitality_trend "XPERT_VITALITY_TREND_TRIGGER"
    before insert on XPERT_VITALITY_TREND REFERENCING NEW AS NEW for each row
     FOR EACH ROW
        EXECUTE PROCEDURE trigger_fct_xpert_vitality_trend_trigger();

The table name should not be quoted or include any extra identifiers like "XPERT_VITALITY_TREND_TRIGGER". Just use the table name xpert_vitality_trend and repeating line in this syntax.
In PostgreSQL, triggers use EXECUTE FUNCTION to call the trigger function, not EXECUTE PROCEDURE.

These are the problem we are getting while executing triggers. is there any solution to fix the issue by ora2pg without manual intervention. As we are developing automation tool we need fix these error by ora2pg.

@darold
Copy link
Owner

darold commented Sep 19, 2024

Please post the Oracle source code of the trigger.

@nareneee
Copy link
Author

nareneee commented Sep 19, 2024

See the oracle source code of mentioned errors
1)CREATE TRIGGER Trigger_name
on column_chooser for each row
declare
begin
if( :new.chooser_id IS NULL ) then
SELECT COLUMN_CHOOSER_SEQ.nextval into :new.chooser_id from dual
/

2)CREATE TRIGGER "TRIGGER_NAME"
before insert on XPERT REFERENCING NEW AS NEW for each row
begin
select XPERT_0.nextval into :new.ID from dual;
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

3 participants
@darold @nareneee and others