SingleStore Studio SQL Editor
On this page
Important
Studio is designed to work with MemSQL 6.
The Studio SQL Editor page is a feature of Studio that allows customers to edit and run SQL queries against their SingleStore clusters.
The editor in this page works like a worksheet where users can type in multiple SQL queries and then choose which queries they want to run.
Creating and Running a Stored Procedure
In order to create a Stored Procedure in the SQL editor, simply paste a regular CREATE PROCEDURE block into the editor:
DELIMITER //CREATE PROCEDURE charge_account(id BIGINT, amount DECIMAL(18,4)) ASDECLAREbalance_tbl QUERY(bal DECIMAL(18,4)) =SELECT remaining_balanceFROM account_balanceWHERE account_id = id;balance DECIMAL(18,4) = SCALAR(balance_tbl);updated_balance DECIMAL(18,4) = balance - amount;BEGINIF balance > amount THENUPDATE account_balanceSET remaining_balance = updated_balanceWHERE account_id = id;END IF;END //DELIMITER ;
Then, you can either select and execute the entire block or simply place the editor cursor anywhere in between the //
delimiters and click Run.
Finally, running the stored procedure works like running any query.CALL charge_
into the SQL Editor and click Run.
Last modified: September 24, 2024