Thread: plpgsql - accessing field in RECORD variable by text variables
Hello! I have the following code which does not work: CREATE OR REPLACE FUNCTION td1(integer) RETURNS REFCURSOR AS ' DECLARE r article%ROWTYPE; BEGIN SELECT INTO r * FROM article WHERE key = $1; a := ''some_other_field''; RAISE NOTICE ''%'', r.a; END; ' LANGUAGE 'plpgsql'; SELECT td1(229); I would like to access RECORD type variables fields by assigning field (attribute) name to some text variable and then access the field in RECORD which has the same name. Is this possible in plpgsql? I can not use the dot notation (fully qualification). What I would like to do is some automatic field copying from another table to table being updated and that this field copying can be managed in DB by changing some record in my meta table. Damjan
"Damjan Pipan" <damjan.pipan@siol.net> writes: > I would like to access RECORD type variables fields by assigning field (attribute) name > to some text variable and then access the field in RECORD which has the same name. > Is this possible in plpgsql? I don't think so, but you could probably do it in pltcl, since Tcl is such a weakly typed language ... regards, tom lane
I would like to try it, but I was unable to install tcl under cygwin. I have installed ActiveTCL and tried to compile with with-tcl option and got undefined reference for all Tcl functions. Then I have tried to set path --with-libs= set to tcl/lib dir and also with tclConfig.sh and tkConfig.sh, but nothing worked. I have also tried to compile the sources from sourceforge (for tcl) but got back the same error. Can anybody help me setting up the right path for tcl libs. Damjan > "Damjan Pipan" <damjan.pipan@siol.net> writes: > > I would like to access RECORD type variables fields by assigning field (attribute) name > > to some text variable and then access the field in RECORD which has the same name. > > > Is this possible in plpgsql? > > I don't think so, but you could probably do it in pltcl, since Tcl is > such a weakly typed language ... > > regards, tom lane >