小编Pau*_*aul的帖子

如果函数的参数与列名相同怎么办

我有一个 SQL 函数,其参数名称为 id。但是,我有一个具有相同名称 id 的列名。我如何告诉函数如何区分参数和列。如果我将参数名称从 id 更改为 num,我的函数可以完美运行,但这不是这里的选项,而且我也无法更改列名称。

create or replace function
    test(id integer) return text
as $$
    select address
    from customers c
    where c.id = id
$$ language sql;
Run Code Online (Sandbox Code Playgroud)

sql database postgresql sql-function

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

标签 统计

database ×1

postgresql ×1

sql ×1

sql-function ×1