简体   繁体   English

PostgreSQL函数更新一行的特定列

[英]PostgreSQL Function that updates a specific column of a row

I am trying to make a function which calls a specific data from the table but why it's showing column doesn't exist even tho its on database . 我试图做一个从表中调用特定数据的函数,但是为什么它显示列甚至在数据库上也不存在。

CREATE FUNCTION public."updateDB"(IN userid bigint DEFAULT 00000, OUT uinfo json, IN clname text DEFAULT info)
RETURNS json
LANGUAGE 'plpgsql'
AS $BODY$
BEGIN
    SELECT clname into uinfo 
    FROM public.users 
    WHERE uid = userid;
END;
$BODY$;

but when i try to call it , it shows this error here i tried to make info default so this error occurs . 但是当我尝试调用它时,它在这里显示此错误 ,因此我尝试将信息设置为默认值,因此发生此错误。 If i don't make anything default and run the function from code , it shows that error again. 如果我没有做任何默认设置并从code运行函数,它将再次显示该错误。

您需要引用文本,否则postgres认为您是在指一列

IN clname text DEFAULT 'info'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Postgresql函数,它锁定表,更新值并返回行 - Postgresql function which locks table, updates value and returns row 用 postgreSQL 更新每一行中的特定列 - Update specific column in every row with postgreSQL 特定字符的Postgresql更新列功能 - Postgresql Update Column Function From Specific Characters 触发功能,在更新特定列后更新一些列 - Trigger function that Updates some columns after update of a specific column Postgresql-函数获取行作为参数-如何访问该行的列? - Postgresql - Function get row as parameter - How to acces to a column of this row? PostgreSQL:基于特定列和条件的模式中每个表的行数 - PostgreSQL : Row Counts of Every Table in Schema Based on Specific Column and Conditions 如何通过postgresql中的公共列找到两个表之间的特定行? - How to find a specific row between two tables by a common column in postgresql? PostgreSQL选择所有列和具有行特定值的列名 - Postgresql Select all columns and column names with a specific value for a row PostgreSQL 分区并选择具有特定列值的第一行 - PostgreSQL partition by and select first row with specific column value python & postgresql:可靠地检查特定表中的更新 - python & postgresql: reliably check for updates in a specific table
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM