PostgreSQL, stored procedure to update a table

0

I am creating a stored procedure to update the data userid of the table clients based on the id of the client cid ; but so far I have not succeeded: the function does not update the userid of the client.

CREATE OR REPLACE FUNCTION updateclient_uid(cid text,uid text)   RETURNS void AS 
$BODY$
BEGIN
    UPDATE  clients
    SET userid = '@uid' 
    WHERE clientid = '@cid'; 
END;
$BODY$   
LANGUAGE plpgsql VOLATILE   
COST 100; 
ALTER FUNCTION updateclient_uid(text, text)   
OWNER TO postgres;
    
asked by Bryan Romero 04.11.2018 в 18:22
source

1 answer

1

Actually that is not a stored procedure but a function. Although in postgres they are something similar to what in other engines is an SP, only in PG 11 there will be support for stored procedures.

That said, what you're doing does not use the correct syntax. It should be, instead:

BEGIN
    UPDATE  clients
    SET userid = uid 
    WHERE clientid = cid; 
END;
    
answered by 05.11.2018 / 00:18
source