Re: [GENERAL] Need help to dynamically access to colomns in function!

2008-12-17 Thread David Fetter
On Tue, Dec 16, 2008 at 11:37:17PM +0300, Иван Марков wrote: > Hello. I have table classif with columns: > ... , group1, group2, group3, ... , group48, ... That's a very poor design because it's both denormalized and has very poor naming. There are likely plenty of other things wrong with it, too

Re: [GENERAL] Need help to dynamically access to colomns in function!

2008-12-17 Thread Sam Mason
On Tue, Dec 16, 2008 at 11:37:17PM +0300, wrote: > Hello. I have table classif with columns: > ... , group1, group2, group3, ... , group48, ... > > In function i do query and want run on every row and dynamically operate on > columns from group1 to group20. I do something like this: It s

Re: [GENERAL] Need help to dynamically access to colomns in function!

2008-12-16 Thread Hoover, Jeffrey
age- From: pgsql-general-ow...@postgresql.org [mailto:pgsql-general-ow...@postgresql.org] On Behalf Of Ivan Pavlov Sent: Tuesday, December 16, 2008 3:55 PM To: pgsql-general@postgresql.org Subject: Re: [GENERAL] Need help to dynamically access to colomns in function! If you need them one by one

Re: [GENERAL] Need help to dynamically access to colomns in function!

2008-12-16 Thread Ivan Pavlov
If you need them one by one why fetch them into tmprec? Take a look at the docs for FETCH: http://www.postgresql.org/docs/8.3/static/sql-fetch.html especially the FETCH ABSOLUTE... regards, Ivan Pavlov On Dec 16, 3:37 pm, aesthete2...@gmail.com ("Иван Марков") wrote: > Hello. I have table class

Re: [GENERAL] Need help to dynamically access to colomns in function!

2008-12-16 Thread Ivan Pavlov
Please disregard my other message. I didn't get what you are trying to do at first. You can do this with dynamic SQL: Look at 38.5.4. Executing Dynamic Commands (http://www.postgresql.org/docs/current/static/plpgsql- statements.html). I guess something like EXECUTE 'SELECT tmprec.group' || i INTO

[GENERAL] Need help to dynamically access to colomns in function!

2008-12-16 Thread Иван Марков
Hello. I have table classif with columns: ... , group1, group2, group3, ... , group48, ... In function i do query and want run on every row and dynamically operate on columns from group1 to group20. I do something like this: OPEN curs FOR select * from classif; loop fetch curs into tmprec;