Re: [GENERAL] Return results of join with polymorphically-defined table in pl/pgsql

2016-07-25 Thread Peter Devoy
>Outputs two columns, one polymorphic match and one constant. Nice. >I couldn't figure out a way to get the output into columns. I have had a fair play and am struggling also. Seems like any work around is going to be too unholy to be worth running. Thanks for having a crack! Peter

Re: [GENERAL] Return results of join with polymorphically-defined table in pl/pgsql

2016-07-25 Thread David G. Johnston
On Mon, Jul 25, 2016 at 6:14 AM, Peter Devoy wrote: > > BEGIN > RETURN QUERY > EXECUTE > format( > ' > SELECT > %1$I.*, > dist_query.distance AS appended_distance, > dist_query.centroid AS appended_centroid > FROM %1$I >

Re: [GENERAL] Return results of join with polymorphically-defined table in pl/pgsql

2016-07-25 Thread Peter Devoy
@David, thanks for the tip. >Providing a concrete example might help. My use case is a database with a large number of spatial tables. I have written a spatial search function which, given an arbitrary table extended with PostGIS, will search for records in that table whose geometries are within

Re: [GENERAL] Return results of join with polymorphically-defined table in pl/pgsql

2016-07-24 Thread John R Pierce
On 7/24/2016 4:45 PM, Peter Devoy wrote: However, I would like to create a function which returns the resultset of an INNER JOIN with table1 being polymorphic and table2 being a result set of column types which do not change. Is this possible? SQL tables are /not/ polymorphic. -- john r pie

Re: [GENERAL] Return results of join with polymorphically-defined table in pl/pgsql

2016-07-24 Thread David G. Johnston
On Sunday, July 24, 2016, Peter Devoy wrote: > > However, I would like to create a function which returns the resultset > of an INNER JOIN with table1 being polymorphic and table2 being a > result set of column types which do not change. Is this possible? > Providing a concrete example might hel

[GENERAL] Return results of join with polymorphically-defined table in pl/pgsql

2016-07-24 Thread Peter Devoy
Hi list The example at the bottom of this (http://stackoverflow.com/questions/11740256/11751557#11751557) answer shows how the anyelement polymorphic type can be used to have a function accept -- and return rows from -- an arbitrary table decided by the user at runtime. However, I would like to c