function to update different tables
От | Lars Eckberg |
---|---|
Тема | function to update different tables |
Дата | |
Msg-id | 20041103112919.M58332@eckbergconsulting.com обсуждение исходный текст |
Ответы |
Re: function to update different tables
|
Список | pgsql-novice |
Hey all, Newbie question: I'm trying to create a function, where the first parameter will be the tablename to update. I have tried to escape $1 in every way I can think of, but with no luck. I get an error when trying to create the function. ERROR: parser: parse error at or near "$1" at character 11 Here is the function: CREATE FUNCTION reserve_ports(text,smallint,text,text,int) RETURNS smallint AS ' UPDATE $1 SET status = \'reserved\', vlan_uid = $2, c_uid = $3 WHERE status = \'free\' AND oid IN (SELECT oid FROM $1 WHERE status = \'free\' AND module_type ILIKE $4 ORDER BY id LIMIT $5); SELECT 1; ' LANGUAGE SQL; I have looked at the manual but i cant seem to find anything covering this. Do i have to use another approach?? Any examples or hints will be appreciated greatly. =) Cheers, --Lars
В списке pgsql-novice по дате отправления: