470,581 Members | 2,427 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,581 developers. It's quick & easy.

Function parameter

X
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.
Jul 19 '05 #1
0 2931

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

9 posts views Thread by Derek Hart | last post: by
14 posts views Thread by dover | last post: by
4 posts views Thread by Vish | last post: by
16 posts views Thread by hzmonte | last post: by
4 posts views Thread by Tony Lownds | last post: by
5 posts views Thread by pauldepstein | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.