PostgreSQL Function that updates a specific column of a row

62 Views Asked by At

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.

1

There are 1 best solutions below

3
On

You need quote your text otherwise postgres think you are referring to a column

IN clname text DEFAULT 'info'