BEGIN
Function
BEGIN may be used to initiate an anonymous block or a single transaction. This section describes the syntax of BEGIN used to initiate an anonymous block. For details about the BEGIN syntax that initiates transactions, see START TRANSACTION.
An anonymous block is a structure that can dynamically create and execute stored procedure code instead of permanently storing code as a database object in the database.
Precautions
None
Syntax
- Enable an anonymous block:
1 2 3 4 5
[DECLARE [declare_statements]] BEGIN execution_statements END; /
- -- Start a transaction:
1 2 3 4 5 6 7
BEGIN [ WORK | TRANSACTION ] [ { ISOLATION LEVEL { READ COMMITTED | READ UNCOMMITTED | SERIALIZABLE | REPEATABLE READ } | { READ WRITE | READ ONLY } } [, ...] ];
Parameter Description
- declare_statements
Declares a variable, including its name and type, for example, sales_cnt int.
- execution_statements
Specifies the statement to be executed in an anonymous block.
Value range: an existing function name
Examples
- Start a transaction block.
1
BEGIN;
- Submit a transaction block.
1
COMMIT;
- Start a transaction block at the REPEATABLE READ isolation level.
1
BEGIN TRANSACTION ISOLATION LEVEL REPEATABLE READ;
- Generate a string using an anonymous block.
1 2 3 4 5
BEGIN dbms_output.put_line('Hello'); END; / ;
Helpful Links
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot