我有一个存储过程,我必须以这样的方式转换bigint数组中的字符串数组:
lst_id bigint[];
SELECT ARRAY[_id] INTO lst_id FROM tablename WHERE ARRAY[codes] <@ $1;
lst_id 是我的bigint数组, _id 是我的 tablename 的列,代码是另一列桌子。 $ 1是我的字符串数组。
不幸的是,这不起作用。它只需要数组字符串中的第一个单词而不是所有单词。 为什么?有人能帮我吗? 谢谢 基督教
答案 0 :(得分:0)
它应该有效,也许你的WHERE子句?
create table tbl(id int[]); create table tbl2 (id bigint[]); insert into tbl select array[1,2,3,4,5]; insert into tbl select array[1,2,3,14,5]; insert into tbl select array[1,2,3,4,5];
DO $$ declare lst_id bigint[]; BEGIN select id into lst_id from tbl where id @> array[14]; insert into tbl2 (id) values (lst_id); END $$;
select * from tbl2;
| id | | :----------- | | {1,2,3,14,5} |
dbfiddle here