function to provide part of function (language='sql')

Поиск
Список
Период
Сортировка
От Moray McConnachie
Тема function to provide part of function (language='sql')
Дата
Msg-id 022001bf0b68$fec682b0$760e01a3@oucs.ox.ac.uk
обсуждение исходный текст
Список pgsql-general
Hi, all.
I need to write functions along these lines:

CREATE FUNCTION functiongetfieldname(char) RETURNS varchar
AS 'SELECT fieldname FROM listoffields WHERE criterion=$1;' LANGUAGE
'sql'

CREATE FUNCTION blah(char,int2) RETURNS float
AS 'SELECT functiongetfieldname($1) FROM maintable WHERE
secondcriterion=$2;'

However, the second function obviously only returns the fieldname
returned by the first function. What I want it to do is return the
contents of the field whose name is returned by the first function. Is
this possible?

Alternative ways round considered, but I'd prefer not to mess with the
database design....

Thanks,
Moray

----------------------------------------------------------------------
----------------
Moray.McConnachie@computing-services.oxford.ac.uk


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

Предыдущее
От: Rissman
Дата:
Сообщение: Red Hat 6.0 / Postgresql 6.4.2 Installed / How to manage? Where are docs?
Следующее
От: pgomez@arrakis.es
Дата:
Сообщение: Found a weird problem: ¿bug?