Re: Dynamically access to field on a RECORD variable

Поиск
Список
Период
Сортировка
От Ricardo Vaz Mannrich
Тема Re: Dynamically access to field on a RECORD variable
Дата
Msg-id 1115139591.22502.20.camel@curitiba.silcom
обсуждение исходный текст
Ответ на Re: Dynamically access to field on a RECORD variable  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-general
If it's not possible, can I create a function that gets a RECORD and a
tablename and returns the correct value. For example:

CREATE FUNCTION my_value(TEXT, RECORD) RETURNS TEXT AS '
  DECLARE
    table_name ALIAS FOR $1
    rec ALIAS FOR $2
  BEGIN
    IF (table_name = 'my_table1') THEN
      RETURN rec.my1_field;
    ELSIF (table_name = 'my_table2') THEN
      RETURN rec.my2.field;
    ...
  END;
' LANGUAGE plpgsql;

Em Ter, 2005-05-03 às 11:52, Tom Lane escreveu:
> Ricardo Vaz Mannrich <rvm_l1@silcom.com.br> writes:
> > Is it possible?
>
> Not in plpgsql.  I believe you could do it in any of the other PLs though.
>
>             regards, tom lane
--
Ricardo Vaz Mannrich <rvm_l1@silcom.com.br>


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

Предыдущее
От: Rich Shepard
Дата:
Сообщение: Adding Records With SERIAL Primary Key
Следующее
От: Ragnar Hafstað
Дата:
Сообщение: Re: does database shut down cleanly when WAL device