Problem while creating trigger with "if then else" construct

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
bartjeb2
Posts: 7
Joined: Sun Jan 24, 2021 12:44 am

Problem while creating trigger with "if then else" construct

Post by bartjeb2 »

When executing :

Code: Select all

create trigger upd_posten after insert on "Transacties"
referencing new row as newrow
for each row
begin atomic
  if newrow."Relatie" = '(mijzelf)'  and 
              newrow."Mededeling" like '%999999999%'
              then update "Posten"   
              set "Totaal posten" = "Totaal posten" + newrow."Bedrag"
              where "Posten" like ' extra overboeking %';
  else if newrow."Relatie" = '(mijzelf)'  and 
             newrow."Mededeling" like '%PAYPAL%'
             then update "Posten"  
             set "Totaal posten" = "Totaal posten” + newrow."Bedrag"
             where "Posten" like ' betaling aan paypa%';
  else
      update "Posten" 
        set "Totaal posten" = "Totaal posten” +  newrow."Bedrag"
        where "Posten" in (
          select "Rel Post" from "Relaties"
          where "Rel Naam" = newrow."Relatie”);
  end if;
end
I get the message :
unexpected end of statement: required: IF : line: 25

I tried other constructions with "if then" and also with “case when”, but I can’t get it working.
Any suggestions would be much appreciated!

I'm trying this on my Imac (macOS Big Sur 11.1) with Open Office (4.1.9) HSQLDB 2.3.2
Last edited by RusselB on Mon Feb 01, 2021 10:25 pm, edited 2 times in total.
Reason: Code tags added
Open Office (4.1.8) on macOS Big Sur 11.1
User avatar
JohnSUN-Pensioner
Volunteer
Posts: 876
Joined: Fri Jan 14, 2011 1:21 pm
Location: Kyiv, Ukraine

Re: Problem while creating trigger with "if then else" const

Post by JohnSUN-Pensioner »

Sorry, I didn't read your code carefully. Therefore, it is quite possible now I'll write nonsense - be lenient.

I counted all IFs and ENDIFs in your code. It turned out that the number of ENDIFs is less. Perhaps you are just missing one more line with "END IF"?
I may not have a lot to give but what I got I'll give to you...
Apache OpenOffice 4.1.5, LibreOffice 6.4.4.2 (x64) on Windows 7
If you think that I did not answer your question, make allowances for my imperfect English
Post Reply