Hi there,
I need to do something like this:
-- Function: public."ModifyOrder"(int4, text, int4)
CREATE FUNCTION public."ModifyOrder"(int4, text, int4) RETURNS void AS
'UPDATE orders SET $2 = $3 WHERE "OrderId" = $1;' LANGUAGE 'sql'
IMMUTABLE;
COMMENT ON FUNCTION public."ModifyOrder"(int4, text, int4) IS
'ModifyOrder(OrderId, FieldToUpdate, NewValue)';
where parameter $2 will be a text value that represent a column name.
Is there any way to do something like that?
I just want to be able to change values of several columns using this
function, writting something like this:
ModifyOrder(19283, "DestinationId", 5);
so that it will update the record with OrderId = 19283, and change
DestinationId to value 5.
Thanks.