Search Postgresql Archives

Re: Dynamically access to field on a RECORD variable

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxx> 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@xxxxxxxxxxxxx>


---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux