我正在尝试使用 RIGHT()
函数,因此它只会显示从客户表中提取的信用卡号的最后 4 位数字。这是我目前所拥有的:
create function get_customer(text) returns setof cusinfo as
$$
select upper(first_name)||' '||upper(last_name) as full_name, upper(address), upper(city)||', '||upper(state)||' '||zip as citystatezip, email, '************'||right(cc_number,4), cc_name
from customer
where customer_id = $1;
$$ language sql;
我得到的错误是:
psql:finalproject.sql:273: ERROR: function right(text, integer) does not exist LINE 3: ...|' '||zip as citystatezip, email, '****'||right(cc_n...
关于为什么会发生这种情况的任何想法?我尝试仅单独使用 RIGHT()
并放入类似 RIGHT('Help me', 2)
的内容,但我遇到了同样的错误。
最佳答案
我假设 psql
是 PostgreSQL。如果是这样,您应该阅读 PostgreSQL documentation描述您可以使用的字符串函数。
对
不是其中之一。
尝试 substring(cc_number from char_length(cc_number) - 3)
。
将来您可能希望使用 Google 来帮助回答此类问题。谷歌是一个搜索引擎;您可以使用搜索引擎查找文档;文档告诉您如何使用产品。
关于postgresql - PostgreSQL 中的 RIGHT() 函数报错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10592944/