proc_def:
CREATE [OR REPLACE] PROCEDURE qname '(' [ paramlist] ')' routine_body
| CREATE [OR REPLACE] PROCEDURE qname '(' [ paramlist] ')' EXTERNAL NAME external_function_name
routine_body:
procedure_statement
| BEGIN procedure_statement_list procedure_statement ';' END
| BEGIN ATOMIC procedure_statement_list procedure_statement ';' END
procedure_statement:
update_statement
| select_statement_single_row
| schema
| grant
| revoke
| create_statement
| drop_statement
| alter_statement
| declare_statement
| set_statement
| control_statement
| transaction_statement
update_statement:
delete_stmt
| truncate_stmt
| insert_stmt
| update_stmt
| merge_stmt
| copyfrom_stmt
| copyto_stmt
declare_statement:
DECLARE variable_list
| DECLARE table_def
set_statement:
SET variable_ref '=' search_condition
| SET variable_ref_commalist_parens '=' subquery
| SET SESSION AUTHORIZATION opt_equal ident
| SET session_schema opt_equal ident
| SET session_user opt_equal ident
| SET session_role opt_equal ident
| SET session_timezone opt_equal LOCAL
| SET session_timezone opt_equal literal
control_statement:
call_procedure_statement
| call_statement
| while_statement
| if_statement
| case_statement
| return_statement
transaction_stmt:
{ START | BEGIN } TRANSACTION transaction_mode_list
| COMMIT opt_work opt_chain
| ROLLBACK opt_work opt_chain opt_to_savepoint
| SAVEPOINT ident
| RELEASE SAVEPOINT ident
| SET LOCAL TRANSACTION transaction_mode_list
| SET TRANSACTION transaction_mode_list
CREATE OR REPLACE PROCEDURE test.refresh_sales_per_country()
BEGIN
TRUNCATE TABLE test.sales_per_country;
INSERT INTO test.sales_per_country SELECT * FROM test.sales_per_country_view;
CALL sys.analyze('test', 'sales_per_country');
END;
CALL test.refresh_sales_per_country();
CREATE ... EXTERNAL NAME ... is a MonetDB language extension
See also system tables/views: sys.functions where type = 2
,
sys.args,
information_schema.routines where routine_type = 'PROCEDURE'
,
information_schema.parameters where function_type = 2
.