DEV Community

AntDB
AntDB

Posted on

AntDB-Oracle Compatibility Developer’s Manual P4–4

Stored Procedure Overview

A procedure is an SPL program that can be invoked as a separate SPL application. When a procedure is called, it can receive values from the caller in the form of input parameters and return the final execution result to the caller in the form of output parameters. To use the PLSQL language in AntDB, you must first open plsql_mode.

Creat Stored Procedures

The CREATE PROCEDURE command defines and names the procedure that will be stored in the database.

CREATE [ OR REPLACE ] PROCEDURE name [ (parameters) ]

{ IS | AS }

[ declarations ]

BEGIN

statements

END [ name ];

name is the procedure identifier. If [ OR REPLACE ] is defined and a procedure with the same name already exists in the schema, then the newly created procedure will replace the existing procedure. Conversely, a newly created procedure will not replace an existing procedure in the same schema. parameters is a list of formal parameters. declarations are declarations of variables, cursors, or types. statements are the statements used by the SPL application. The BEGIN-END block contains a section to catch exceptions.

The following is a simple procedure that takes no arguments. Note that in AntDB, even without any arguments, the function or procedure name is followed by an empty parenthesis, which is incompatible with Oracle.

\set PLSQL_MODE ON
CREATE OR REPLACE PROCEDURE simple_procedure()
IS
BEGIN
DBMS_OUTPUT.PUT_LINE('That''s all folks!');
END;
Enter fullscreen mode Exit fullscreen mode

By writing the code in AntDB, we store this procedure in the database.

For more information on creating stored procedures, see the CREATE PROCEDURE command.

Top comments (0)