postgresql自定义函数语法

2021-01-06  本文已影响0人  jadefan

最近在写postgres的函数,整理下常用语法备忘

regexp_split_to_table 字符串分割为表格
regexp_split_to_array 字符串分割为数组

定义内部变量

DECLARE
    json text;

执行动态sql,并传入参数

sql1 := 'select * from AA where id=$1';
EXECUTE sql1 using id;

执行动态sql,取出结果

# result 变量提前定义
execute ex_sql into result;

打印变量

RAISE NOTICE 'value %',v1

字符串拼接

name := '111' || '222'
上一篇 下一篇

猜你喜欢

热点阅读