0
点赞
收藏
分享

微信扫一扫

GBase 8s SPL语法

才德的女子 2022-04-20 阅读 84
数据库

概述
SPL例程由开始语句,语句块,结束语句组成。 SPL例程根据是否需要返回值,分为存储过程和函数。 语句块由SQL和SPL语句组成。
存储过程
语法
create procedure proc_name(param1 data_type1, param2 data_type2, …)
spl_code;
end procedure;

函数
语法
create function func_name(param1 data_type1, param2 data_type2, …)
returning data_type1 [as id1], data_type2 [as id2], …
spl_code;
return val1, val2, … [with resume];
end function;

语法
变量声明
语法
create procedure proc_name(param1 data_type1, param2 data_type2, …)
spl_code;
end procedure;
define m, n int;
define global i int default 1;

变量赋值
语法
let var = value;
let var1, var2,… = val1, val2, …;
let var1, var2, … = function(args1, args2, …);
let var1, var2, … = (select col1, col2, … from table_name);

条件
语法
case expr
when val_1 then
code_1
[when val_2 then
code_2 …]
else
code_n
end case;

循环
GOTO
语法
<<lbl_goto>>
spl_code;
if expr then
goto lbl_goto;
end if;

LOOP
语法

loop
if expr then
exit; end if;
end loop;
loop
exit when expr;
end loop;

FOR/FOREACH
语法
for i in (start_val to end_val) loop
spl_code;
end loop;
for i in (start_val to end_val)
spl_code;
end for;
foreach select col1, col2,… into var1, var2,… from table_name
spl_code;
end foreach;

WHILE
语法
while expr loop
spl_code;
end loop;
while expr
spl_code;
end while;

异常处理
语法
on exception [in (…)] set sql_err_num[,isam_err_num]
spl_code;
end exception [with resume];

举报

相关推荐

GBase 8s客体重用

产品介绍|GBase 8s产品

GBase 8s的用户管理

GBase 8s MPP开发接口

GBase 8s 常用函数总结

GBase 8s MPP产品架构

0 条评论