Plpgsql functions and Variable Tablenames

Поиск
Список
Период
Сортировка
От Steffers
Тема Plpgsql functions and Variable Tablenames
Дата
Msg-id 20000526035534.506591F57C@chronozon.dyndns.org
обсуждение исходный текст
Список pgsql-interfaces
Hello everyone,          I hope that this is the correct forum in which to post the     question I have.
         Currently I have code which tries to do the following:
     CREATE FUNCTION upd_history_no_location()     RETURNS opaque     AS 'BEGIN            new.history_id=SELECT
(max(history_id)+1)FROM client                                where client.CLIENT_ID=new.CLIENT_ID;        END;'
LANGUAGE'plpgsql';
 
         I plan on tying this trigger onto the 'client' table on     an INSERT condition. I will be using the same
'basic'trigger on 70-80     tables or so. To stop pointless re-iteration of code therefore I tried
 
to create a     dynamic trigger as follows :
     CREATE FUNCTION upd_history_no_location(text)     RETURNS opaque     AS 'BEGIN            new.history_id=SELECT
(max(history_id)+1)FROM $1                                where $1.CLIENT_ID=new.CLIENT_ID;          END;'     LANGUAGE
'plpgsql';
         Needless to say, this didnt work. It seems to CREATE     okay, but when I try to trigger the action. urm. no.
niceerror
 
message.     (and each table will have the field CLIENT_ID, and history_id, thats     not really an issue =)
         I have been told that this will work in tcl (and infact that is     the way it is working at the minute),
seeingas how everything is in     python though (the program that ties into the database), I would
 
prefer     to stick to two languages (python/[plpg]sql) and tcl doesnt really sit     well with me as a language (jst a
personalbias from a long ago school     lecture).
 
         So, the question is, can I do this somehow under plpgsql     or can I raise this as a feature request to the
maintener? (assuming     he/she is here and reading the list).
 
         many thanks,         Stefs.

     (p.s because of the structure of the database, i cant use OID's or     sequence id's, as the 'uniqueness' of this
counteris also tied into     a clients number and a clients workorder number. (dont ask ;))
 



В списке pgsql-interfaces по дате отправления:

Предыдущее
От: "S.F. Lee"
Дата:
Сообщение: Re: Postmaster is getting bigger
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Postmaster is getting bigger