java调用gbase存储过程,GBase 8s触发存储过程示例

GBase 8s的触发器不支持raise exception,条件判断等存储过程中可以使用的功能,若有需求,可以使用触发存储过程的功能。

以下以insert触发器为示例,创建触发存储过程:

1,创建相应的表create table tab1

(

id integer,

name varchar(40),

primary key (id)

) ;

create table tab2

(

id integer,

name varchar(40),

uptime datetime year to second

default current year to second

) ;

2,创建触发存储过程中的存储过程create procedure proc_tri_insert_tab1()

referencing new as new for tab1;

define pid int;

select count(id) into pid from tab2 where id = new.id;

if pid = 1 then

raise exception -746,0,'ID exists!';

end if;

end procedure;

3,创建触发存储过程中的触发器create trigger tri_insert_tab1 insert on tab1

for each row(

execute procedure proc_tri_insert_tab1() with trigger references

);

当表tab1插入时,触发存储过程执行,当符合插入的id存在于tab2中时,raise exception。> insert into tab1 values(2,'testssdadsfas');

746: ID exists!

错误在 1 行

第 1 字符

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值