pg的存储过程的创建如下所示:

create or replace function "public"."update_sequence"("v" int4)
returns void as
$$
   declare
   seq_record record;
   begin
        for seq_record in (select relname from pg_class where relkind='S') loop
             execute 'alter sequence ' || seq_record.relname || ' restart with ' || v || ';';
         end loop;     
    end;         
$$
language plpgsql volatile
cost 100;

存储过程中 执行sql语句,要加execute

mybatis的mapper.xml文件中调用pg的存储过程如下:

<select >
      select update_sequence(#{number})
</select>

注意:mybatis调用存储过程的入参类型要和pg中创建的存储过程的入参类型一致,不要会找不到对应的存储类型

mybatis 中执行pg的存储过程 用select  ; 执行mysql的存储过程 用call

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-10
  • 2022-12-23
  • 2021-07-02
  • 2022-12-23
猜你喜欢
  • 2021-05-20
  • 2022-12-23
  • 2022-02-05
  • 2022-12-23
  • 2021-08-15
  • 2021-06-13
  • 2022-12-23
相关资源
相似解决方案