On 09/02/10 11:07, Willy-Bas Loos wrote:
Hi, in my plpgsql function I'm looping through tables and their fields and i want to return their field names and the corresponding values. It all works fine, except i can't retrieve the values, which is really a bummer. I tried a couple of things (in vain), of which this seemed the most promising:
...
t_rec_out.field_value := t_record.t_fields[t_i]; --<==== happens here
...
And then i get the error: ERROR: record "t_record" has no field "t_fields" Any tips there?
This isn't going to be practical in plpgsql. You can just about do it if you want to build a "SELECT" statement and cast everything to text. Not worth the trouble though. The problem is that plpgsql is very static in its typing and just doesn't have the flexibility for this sort of task.
Use pltcl or plperl or plpython or one of the other more dynamic languages. It's straightforward then.
-- Richard Huxton Archonet Ltd -- Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general