当前位置:网站首页>postgresql 函数的参数为自定义类型时传参格式
postgresql 函数的参数为自定义类型时传参格式
2022-06-11 03:14:00 【谷满满】
自定义类型
CREATE TYPE test_type_input AS (
id integer,
name character varying(200)
);自定义函数
CREATE OR REPLACE FUNCTION public.test_function(
in_pro_arr test_type_input[],
OUT pro_len integer,
OUT out_name character varying[])
RETURNS record
LANGUAGE 'plpgsql'
COST 100
VOLATILE
AS $BODY$
DECLARE
loop_index integer;
pro_info record;
arr_length integer;
BEGIN
IF in_pro_arr is null or cardinality(in_pro_arr) <= 0 then
pro_len = -1;
out_name = null;
return;
END IF;
loop_index = 1;
arr_length = array_length(in_pro_arr,1);
pro_len = arr_length;
LOOP
pro_info = in_pro_arr[loop_index];
out_name[loop_index] = pro_info.name;
loop_index = loop_index + 1;
IF loop_index > arr_length THEN
exit;
END IF;
END LOOP;
END;
$BODY$;函数调用示例
SELECT * from test_function(
array[
(1, '电脑'),
(2, '书本'),
(3, '水杯')
]::test_type_input[]
);边栏推荐
- ORA-00392 ORA-00312 错误处理
- 突破中国品牌创新技术实力,TCL做对了什么?
- The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received
- Resolved: JDBC connection to MySQL failed with an error:'The last packet sent successfully to the server was 0 milliseconds ago. '
- Lombok use
- Whether the outbound sequence is the inbound sequence
- B_ QuRT_ User_ Guide(19)
- 【安全科普】今天你被社工了吗?
- 多值映射:ArrayListMultimap和HashMultimap
- ArTalk | 如何用最小投入,构建国产超融合进化底座?
猜你喜欢

被“内卷”酸翻的OPPO Reno6

Computer vision (AI) interview

org. apache. solr. common. SolrException:Could not load core configuration for core hotel

B_ QuRT_ User_ Guide(16)

msg=SolrCore ‘collection1‘ is not available due to init failure: Could not l

How to ensure reliable delivery of messages?

【安全科普】挖矿技术,从一个理工男的爱情故事讲起

文件合成器

WinDbg-虚拟机-双机调试-驱动文件的调试

Artalk | how to build a domestic hyperfusion evolutionary base with minimum investment?
随机推荐
Ora-00392 ora-00312 error handling
pip 安装 qt5 。
Whether the outbound sequence is the inbound sequence
[safety science popularization] have you been accepted by social workers today?
【云原生】什么是微服务?怎么搭建?手把手教你搭建第一个微服务(框架)
Gd32 can sends no mailbox fault
Operations on annotation and reflection
cv. Houghcircles: Circular Hough transform opencv
Hqchart nailing applet tutorial 1- create a K-line diagram
LVGL中文字体制作
B_ QuRT_ User_ Guide(16)
postgresql源码学习(二十)—— 故障恢复①-事务日志格式
Shell 按行读取文件
GD32 can发送报no mailbox 故障
In June, 2022, China Database ranking: tidb made a comeback to win the crown, and Dameng was dormant and won the flowers in May
[cloud native] what is micro service? How to build it? Teach you how to build the first micro service (framework)
OPPO K9试水“捆绑销售”,消费者“赚了”还是“亏了”?
canvas+svg线条粒子动画网页背景
Chapter VII introduction to common protocols (1)
Mazhiqiang: research progress and application of speech recognition technology -- RTC dev Meetup