Skip site navigation (1) Skip section navigation (2)

Access a Field / Column of a resultset by Number

From: Daniel Schuchardt <d(dot)schuchardt(at)prodat-sql(dot)de>
To: pgsql-general(at)postgresql(dot)org
Subject: Access a Field / Column of a resultset by Number
Date: 2009-11-27 15:22:28
Message-ID: heoqrb$9rv$1@news.hub.org (view raw or flat)
Thread:
Lists: pgsql-general
hy group,

i currently look for a solution to access a resultset in a db-stored 
function by number. in plpgsql thats not possible.
so i checked out plpython. so far so good, thats working:

CREATE OR REPLACE FUNCTION dokv_dorecnokeywords(sqlstatement VARCHAR) 
RETURNS VOID AS
$$
  rv = plpy.execute(sqlstatement, 1)
  |||||->"SELECT * FROM art WHERE ak_nr='TEST'"
  s  = 'ak_bez'  |||| fieldname is static here, should be by number
  plpy.notice(s+'='+rv[0][s])
  return
$$ LANGUAGE plpythonu;

now i need a solution to get the number of fields as well as the 
fieldnames of that resultset and run through all fields (by number or by 
name). (i need the fieldname too)

-- 

Daniel Schuchardt
/Softwareentwicklung/

/http://www.prodat-sql.de/

Responses

pgsql-general by date

Next:From: CjkalbenteDate: 2009-11-27 15:44:05
Subject: Re: Mysql migration to Postgresql
Previous:From: Tom LaneDate: 2009-11-27 15:20:40
Subject: Re: date_trunct() and start of week

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group