postgresql函数相关操作笔记

pg库批量插入数据

create or replace function aa1(a2 bigint) returns void
AS d e c l a r e i i i n t e g e r ; b e g i n I I : = 1 ; F O R i i I N 1.. a 2 L O O P s e l e c t i i ; i n s e r t i n t o t e s t ( i d , b i l l n o ) v a l u e s ( i i : : t e x t , i i : : t e x t ) ; e n d l o o p ; e n d ; declare ii integer; begin II:=1; FOR ii IN 1..a2 LOOP --select ii; insert into test(id,bill_no) values(ii::text,ii::text); end loop; end; LANGUAGE plpgsql;

select aa1(3::bigint);

case when else end

select CASE WHEN r.name in (‘1’,‘3’) THEN 1

      ELSE -1 end   from test r limit 2;

猜你喜欢

转载自blog.csdn.net/hbn1326317071/article/details/84639592
今日推荐