A record type contians the 1st row form dynamic query result.
From that row I want to select the 1st column.
How do I do that?
CREATE OR REPLACE FUNCTION dswz.save_query (TEXT) RETURNS BOOL AS '
DECLARE
_query ALIAS FOR $1;
_temp_query TEXT;
_row RECORD;
_id INT8;
_type INT8;
BEGIN
/* select the 1st row*/
_temp_query := ''SELECT * FROM ('' || _query || '') AS table_source LIMIT 1'';
FOR _row IN EXECUTE temp_query LOOP
/* select the 1st column */
_id := ????_row[0]??????
END LOOP;
/* Saves the query and his type */
SELECT INTO _type type FROM objects WHERE id = _id;
INSERT INTO queries VALUES (_query, _type);
RETURN TRUE;
END
' LANGUAGE 'plpgsql' SECURITY DEFINER;