function, that uses different table(names)

Поиск
Список
Период
Сортировка
От Moritz Bayer
Тема function, that uses different table(names)
Дата
Msg-id c244500b0511020530i713d9748j@mail.gmail.com
обсуждение исходный текст
Ответы Re: function, that uses different table(names)  (Moritz Bayer <moritz.bayer@googlemail.com>)
Re: function, that uses different table(names)  ("A. Kretschmer" <andreas.kretschmer@schollglas.com>)
Re: function, that uses different table(names)  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-sql
Hello group,<br /><br /> I've a bunch of tables, which have just about the same name. They are just iterated like
this:<br/><br /> tbl_table1<br /> tbl_table2<br /> tbl_table3<br /> ...<br /><br /> They all have the same field, but
differentdata.<br /><br /> Now I'm wondering, if I have to write functions for every table,  although they perform the
sameoperation?<br /> Or is it possible to pass an integer parameter to the function, use it to put the right tablename
togetherand perform the operation.<br /><br /> This would something look like this:<br /><br /> CREATE OR REPLACE
functiongetmaxuserid(integer) RETURNS integer AS'<br /> DECLARE tmp_tmp_tmp_table varchar(100);<br />        DECLARE
tmp_tablevarchar(100);<br />        DECLARE tmp_tmp_table varchar(100);<br />        DECLARE live_table
varchar(100);<br/>        DECLARE i_return integer;<br /> BEGIN<br />      --live_table := ''tbl_highscore_app'' ||
cast($1as varchar);<br />      SELECT   max(userid) FROM ''tbl_highscore_app'' || cast($1 as varchar);<br />      <br
/>     <br /><br />  return(0);<br />  END;<br /> 'LANGUAGE 'plpgsql' VOLATILE CALLED ON NULL INPUT SECURITY
INVOKER;<br/><br /><br /> I don't know if this is good practise, but I'm trying to create a function which gets an
integer.<br clear="all" /><br /><br /> 

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

Предыдущее
От: "Mark R. Dingee"
Дата:
Сообщение: Re: PGSQL encryption functions
Следующее
От: Moritz Bayer
Дата:
Сообщение: Re: function, that uses different table(names)