pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
problem with selecting from a function
2+ messages / 2 participants
[nested] [flat]

* problem with selecting from a function
@ 2011-06-21 01:55 Andreas <maps.on@gmx.net>
  2011-06-21 03:56 ` Re: problem with selecting from a function Pavel Stehule <pavel.stehule@gmail.com>
  0 siblings, 1 reply; 2+ messages in thread

From: Andreas @ 2011-06-21 01:55 UTC (permalink / raw)
  To: pgsql-sql

Hi,

I've got a table with a couple of objects.
Primary key object_id.

There is a function that fetches some values from another table that 
relate to an object_id.
Like   fctX ( 7 )  --> set of typX ... ( 14, 'bla' ), ( 17, 'blu' ), ( 
21, 'ble' ), ...
The result of the function can have 0 or more lines of a defined 
result-type typX.
Those resulting numbers are not object_ids.

Now I'd need a SELECT that lists all function results of all object_ids.
Like:
...
6, ...
7, 14, 'bla'
7, 17, 'blu'
7, 21, 'ble'
8, ...

Actually it was enough to get just the numerical column of the function 
result.

I tried
select object_id, fctX (object_id) from objects;
Then I get:
7, (14, 'bla')
7, (17, 'blu')
7, (21, 'ble') <--- round brackets
This looks like an array but how can I split it up to columns or at 
least extract the number-column?



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: problem with selecting from a function
  2011-06-21 01:55 problem with selecting from a function Andreas <maps.on@gmx.net>
@ 2011-06-21 03:56 ` Pavel Stehule <pavel.stehule@gmail.com>
  0 siblings, 0 replies; 2+ messages in thread

From: Pavel Stehule @ 2011-06-21 03:56 UTC (permalink / raw)
  To: Andreas <maps.on@gmx.net>; +Cc: pgsql-sql

2011/6/21 Andreas <maps.on@gmx.net>:
> Hi,
>
> I've got a table with a couple of objects.
> Primary key object_id.
>
> There is a function that fetches some values from another table that relate
> to an object_id.
> Like   fctX ( 7 )  --> set of typX ... ( 14, 'bla' ), ( 17, 'blu' ), ( 21,
> 'ble' ), ...
> The result of the function can have 0 or more lines of a defined result-type
> typX.
> Those resulting numbers are not object_ids.
>
> Now I'd need a SELECT that lists all function results of all object_ids.
> Like:
> ...
> 6, ...
> 7, 14, 'bla'
> 7, 17, 'blu'
> 7, 21, 'ble'
> 8, ...
>
> Actually it was enough to get just the numerical column of the function
> result.
>
> I tried
> select object_id, fctX (object_id) from objects;
> Then I get:
> 7, (14, 'bla')
> 7, (17, 'blu')
> 7, (21, 'ble') <--- round brackets
> This looks like an array but how can I split it up to columns or at least
> extract the number-column?
>

this is composite value

you can try

SELECT object_id, (fctX(object_id)).* from objects

Regards

Pavel Stehule


> --
> Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-sql
>



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2011-06-21 03:56 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2011-06-21 01:55 problem with selecting from a function Andreas <maps.on@gmx.net>
2011-06-21 03:56 ` Pavel Stehule <pavel.stehule@gmail.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox