当前位置:网站首页>[postgresql]postgresql custom function returns an instance of table type
[postgresql]postgresql custom function returns an instance of table type
2022-07-03 20:13:00 【just-do-it-zzj】
CREATE OR REPLACE function test_retable(p_id int)
RETURNS table(id int, name VARCHAR2(50))
LANGUAGE PLPGSQL
AS $$
DECLARE
/*
1. Create table
create table test1(c1 int ,c2 varchar2(50));
insert into test1(c1,c2) values(1,'2');
insert into test1(c1,c2) values(2,'2');
insert into test1(c1,c2) values(1,'3');
2. Execute query function
select * from test_retable(1);
*/
TYPE varray_type IS VARRAY(20) OF INT;
v_varray varray_type;
BEGIN
v_varray := varray_type(1, 2, 3, 4, 5);
RETURN QUERY SELECT c1 AS id, c2 AS name FROM test1 WHERE c1 in (
select regexp_split_to_table(array_to_string(v_varray, ','),',')
);
END ; $$
边栏推荐
- FPGA learning notes: vivado 2019.1 project creation
- Implementation of stack
- Realize user registration and login
- 6006. Take out the minimum number of magic beans
- Oak-d raspberry pie cloud project [with detailed code]
- How to improve data security by renting servers in Hong Kong
- Phpstudy set LAN access
- [raid] [simple DP] mine excavation
- NFT without IPFs and completely on the chain?
- 原生表格-滚动-合并功能
猜你喜欢
Point cloud data denoising
[Yu Yue education] basic reference materials of manufacturing technology of Shanghai Jiaotong University
10 smart contract developer tools that miss and lose
Upgrade PIP and install Libraries
2022 Xinjiang latest construction eight members (standard members) simulated examination questions and answers
How to read the source code [debug and observe the source code]
Xctf attack and defense world crypto advanced area best_ rsa
Xctf attack and defense world crypto master advanced area olddriver
Explore the internal mechanism of modern browsers (I) (original translation)
The 29th day of force deduction (DP topic)
随机推荐
IP address is such an important knowledge that it's useless to listen to a younger student?
Titles can only be retrieved in PHP via curl - header only retrieval in PHP via curl
BOC protected amino acid porphyrins TAPP ala BOC, TAPP Phe BOC, TAPP Trp BOC, Zn · TAPP ala BOC, Zn · TAPP Phe BOC, Zn · TAPP Trp BOC Qiyue
Day6 merge two ordered arrays
BOC protected alanine porphyrin compound TAPP ala BOC BOC BOC protected phenylalanine porphyrin compound TAPP Phe BOC Qi Yue supply
FPGA 学习笔记:Vivado 2019.1 工程创建
Micro service knowledge sorting - three pieces of micro Service Technology
Microservice knowledge sorting - search technology and automatic deployment technology
Get log4net log file in C - get log4net log file in C
7. Data broker presentation
Make a simple text logo with DW
Global and Chinese market of rubidium standard 2022-2028: Research Report on technology, participants, trends, market size and share
【leetcode】1027. Longest arithmetic sequence (dynamic programming)
Part 27 supplement (27) buttons of QML basic elements
NFT without IPFs and completely on the chain?
1.4 learn more about functions
2022-06-28 advanced network engineering (XIII) IS-IS route filtering, route summary, authentication, factors affecting the establishment of Isis neighbor relations, other commands and characteristics
Detailed and not wordy. Share the win10 tutorial of computer reinstallation system
Point cloud data denoising
Pat grade B 1009 is ironic (20 points)