How the get variables out of a plggsql RECORD by column number - Mailing list pgsql-novice

From Tjibbe Rijpma
Subject How the get variables out of a plggsql RECORD by column number
Date
Msg-id 01c601c4fcee$b2dbc5e0$0100a8c0@TJIBBE
Whole thread Raw
Responses Re: How the get variables out of a plggsql RECORD by column number  (Jeff Eckermann <jeff_eckermann@yahoo.com>)
List pgsql-novice
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;

pgsql-novice by date:

Previous
From: Jaime Casanova
Date:
Subject: Re: Updating views : cannot figure out what goes wrong
Next
From: Ramon Orticio
Date:
Subject: can't add connection to server in windowsXP using pgadminIII