79517262

Date: 2025-03-18 11:39:09
Score: 2
Natty:
Report link

How to pass a table name and column name as params? Answered by LLM :

CREATE OR REPLACE FUNCTION increment(x int, row_id int, table_name text, column_name text)
RETURNS void AS
$$
BEGIN
  EXECUTE format('UPDATE %I SET %I = %I + $1 WHERE id = $2', 
                 table_name, column_name, column_name)
  USING x, row_id;
END;
$$ 
LANGUAGE plpgsql VOLATILE;
Reasons:
  • Has code block (-0.5):
  • Ends in question mark (2):
  • Starts with a question (0.5): How to
Posted by: Deckard