Search Postgresql Archives

Dynamically access to field on a RECORD variable

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

 



Supose I have this function

CREATE OR REPLACE my_func(TEXT) RETURNS text AS '
  DECLARE
    var_name ALIAS FOR $1;
    rec RECORD;
  BEGIN
    SELECT * INTO rec FROM my_table WHERE my_key = 1;
    -- Here is my problem
    RETURN rec.var_name;
  END;
' LANGUAGE plpgsql;

SELECT my_func('my_field');

I want the return row in the function executes as:

RETURN rec.my_field;

Is it possible?

Thank you.

-- 
Ricardo Vaz Mannrich <rvm_l1@xxxxxxxxxxxxx>


---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

[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