Re: How the get variables out of a plggsql RECORD by column number

Поиск
Список
Период
Сортировка
От Tjibbe Rijpma
Тема Re: How the get variables out of a plggsql RECORD by column number
Дата
Msg-id 002901c4fe0f$09f5e150$0100a8c0@TJIBBE
обсуждение исходный текст
Ответ на Re: How the get variables out of a plggsql RECORD by column number  (Jeff Eckermann <jeff_eckermann@yahoo.com>)
Ответы Re: How the get variables out of a plggsql RECORD by column number
Список pgsql-novice
Yes I'm looking for a generic function, because I do not know the
fieldnames.

Is there no possibility to insert the query result  into a ARRAY and then
select _result[0][0]? (I didn't get it work.....)

Or to get the fieldnames?

Pl/tcl, pl/python or pl/perl are not installed by my provider and I have no
experience with it.


Tjibbe
----- Original Message -----
From: "Jeff Eckermann" <jeff_eckermann@yahoo.com>
To: "Tjibbe Rijpma" <t.b.rijpma@student.tudelft.nl>;
<pgsql-novice@postgresql.org>
Sent: Tuesday, January 18, 2005 15:41
Subject: Re: [NOVICE] How the get variables out of a plggsql RECORD by
column number


> --- Tjibbe Rijpma <t.b.rijpma@student.tudelft.nl>
> wrote:
>
> > 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?
>
> By name, i.e. "_row.firstfieldname".  Perhaps you are
> looking for a generic function, that can be applied to
> any table?  Pl/pgsql is not equipped to do that.  I
> believe that you can achieve what you want with
> pl/tcl, pl/python or pl/perl (not sure about the
> last).
>
> >
> >
> > 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;
>
>
>
>
> __________________________________
> Do you Yahoo!?
> Yahoo! Mail - now with 250MB free storage. Learn more.
> http://info.mail.yahoo.com/mail_250
>


В списке pgsql-novice по дате отправления:

Предыдущее
От: Ramon Orticio
Дата:
Сообщение: reinstalled postgresql-8.0.0-rc5-2
Следующее
От: "Keith Worthington"
Дата:
Сообщение: 8.0 release