小编spi*_*edd的帖子

Postgres 将表声明为函数的参数?

我想创建一个对表进行操作的函数,例如

create or replace function test(t table) 
    returns void language plpgsql as
$func$
begin   
    select * from t limit 10;
end;
$func$
Run Code Online (Sandbox Code Playgroud)

然后,我可以使用任何表名调用该函数,例如

select test(myTable);
Run Code Online (Sandbox Code Playgroud)

我该怎么做这样的事情?

postgresql plpgsql

3
推荐指数
1
解决办法
2万
查看次数

PostgreSQL; 使用 CASE 语句根据条件更新不同的列

我有一张有不同类型余额的表,我需要根据可用性从不同的列中扣除余额。

这是我尝试使用的查询(示例),但没有用

update table_A
set case
    when column_A>table_B.balance then column_A
    when column_B>table_B.balance then column_B
    when column_C>table_B.balance then column_C
    end =value
from table_B
on table_A.Id=table_B.id
Run Code Online (Sandbox Code Playgroud)

谢谢!

postgresql-9.5

2
推荐指数
1
解决办法
1万
查看次数

标签 统计

plpgsql ×1

postgresql ×1

postgresql-9.5 ×1