Problem while creating trigger with "if then else" construct

Creating a macro - Writing a Script - Using the API

Problem while creating trigger with "if then else" construct

Postby bartjeb2 » Mon Feb 01, 2021 8:26 pm

When executing :
Code: Select all   Expand viewCollapse view
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
bartjeb2
 
Posts: 7
Joined: Sun Jan 24, 2021 12:44 am

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

Postby JohnSUN-Pensioner » Wed Feb 03, 2021 11:24 am

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
User avatar
JohnSUN-Pensioner
Volunteer
 
Posts: 840
Joined: Fri Jan 14, 2011 1:21 pm
Location: Kyiv, Ukraine


Return to Macros and UNO API

Who is online

Users browsing this forum: No registered users and 4 guests