I am trying to debug a future trigger. I make an example of a contrived and very simple

begin IF (1<>0) THEN select * from aa.csv; ELSE select * from aa.csv; END IF; end 

But does not work returns an error

Unrecognized statement type. (near "begin" at position 0)

begin IF (1<>0) THEN select * from aa.csv

# 1064 - You have an error in your SQL syntax; check the syntax to use the syntax to use the line if it is near (IF <1) THEN select * from aa.csv 'at line 2

At the same time, everything seems to work fine for others (the example was taken from the forum where everything works fine for a person) - the request seems to be simple to the point of dullness ...

Tell me why it does not work out?

MySQL 5.7

  • What are you trying to do with this code and how do you run it? Is this your procedure? - Anton Shchyrov
  • MySQL has no anonymous code. At all. And blocks can exist only within procedural structures (procedures, functions, triggers, etc.). At the same time, with others, everything seems to work fine , either within a procedure (judging by the text - a trigger), or not in MySQL. But not in the console. - Akina
  • Yes ... I put everything in the procedure - thanks ... - Stas Borzikh

0