Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mysql noop or null statement equivalent

Tags:

mysql

When coding I personally like to complete my flow control/structure before filling it in. To allow it to work in oracle I could just put a null; command oracle null command in the empty block to satisfy the parser. In mysql i'm getting an error for an empty codeblock and using null; doesn't work.

e.g.

if( _orgId IS NULL ) then
   select _orgId;

else
   null; -- this throws an error.
   -- TODO: Write complex statement.
end if;

Does Mysql have a null command equivalent and if so what is it?

like image 578
m12lrpv Avatar asked Oct 29 '25 09:10

m12lrpv


1 Answers

MySQL supports a statement DO <expression>;

See https://dev.mysql.com/doc/refman/8.0/en/do.html

It doesn't matter what the expression is, the statement does not return any results. The common use of this statement is for calling functions such as RELEASE_LOCK() or any other function that has a side-effect.

So you can use it as a no-op by writing any expression that has no side-effect:

DO NULL;
like image 63
Bill Karwin Avatar answered Oct 31 '25 02:10

Bill Karwin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!