gpt4 book ai didi

sql - 将更新的列返回到数组变量中

转载 作者:行者123 更新时间:2023-11-29 14:34:16 25 4
gpt4 key购买 nike

这个更新查询是我的功能的一部分

update  tax_table it
set updated_by = 1,
updated_on = now(),
customer_id = gs.colum,
site_id = t.colum
from table1 ri
inner join table2 t on t.colum = ri.colum
inner join table3 gs on ri.colum = gs.colum
inner join table4 vg on vg.colum = ri.colum
where ri.table1 = _id ;

我想在我的函数中将更新后的 site_id 存储到一个整型数组变量中

最佳答案

应该做的事:

with u as (
update tax_table it
set updated_by = 1,
updated_on = now(),
customer_id = gs.colum,
site_id = t.colum
from table1 ri
inner join table2 t on t.colum = ri.colum
inner join table3 gs on ri.colum = gs.colum
inner join table4 vg on vg.colum = ri.colum
where ri.table1 = _id
returning site_id
)
select array_agg(site_id) from u into YOUR_VAR;

关于sql - 将更新的列返回到数组变量中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47393286/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com