Couldn't understand the usage of temporary delimiter $$
Why the sql engine will stop reading the further queries in the stored procedures if we use a ";" and why it will read all the queries when we use $$
Hi Soumyojit!
Thanks for reaching out.
In SQL, the semicolon (;
) is a statement terminator, signaling the end of one command and the start of another. If a semicolon is used incorrectly within a stored procedure, it could prematurely end a command, causing the SQL engine to stop processing further queries.
Using $$
is often a way to define a custom delimiter in SQL stored procedures, allowing the entire block of code to be processed as one batch without being interrupted by semicolons that are meant to terminate individual statements within the procedure. This is particularly useful for stored procedures that contain multiple SQL statements.
Hope this helps.
Best,
Tsvetelin