[postgis-users] operator is not unique error

Chetan Tiwari chetan.tiwari at gmail.com
Mon Oct 27 07:27:31 PDT 2008


Hi Regina

Thanks much! That fixed it! Yes, you are correct, this is an old piece of
code that generates a weighted quad-tree from a set of points. I spent some
time on this last night, except I was casting temp_geom to geometry instead
of text! Anyway, this is a big relief - thanks again!

Regards,

Chetan

On Mon, Oct 27, 2008 at 6:07 AM, Obe, Regina <robe.dnd at cityofboston.gov>wrote:

>  Chetan,
> I think its this part that may be giving you problems --
>
> ''' || temp_geom || '''
>
> I'm assuming temp_geom is a geometry and 8.3 has taken out a lot of
> default casting behavior.
>
> In general I try to avoid having the database do these automatic castings
> except when its common because its too unpredicatable from database platform
> to platform or even version to version of same db product.
>
> Try changing that to
>
> ''' || CAST(temp_geom As text) || '''
>
> Unfortunately I don't have a 8.3 lying around at the moment to test.
>
> Also it appears from the small snippet you provided that you are using old
> syntax instead of $ quoting, named variables - so its harder to follow what
> you are doing.
>
> Hope that helps,
> Regina
>
>
>  ------------------------------
> *From:* postgis-users-bounces at postgis.refractions.net [mailto:
> postgis-users-bounces at postgis.refractions.net] *On Behalf Of *Chetan
> Tiwari
> *Sent:* Monday, October 27, 2008 2:11 AM
> *To:* PostGIS Users Discussion
> *Subject:* [postgis-users] operator is not unique error
>
>  Hi All
>
> I've been having a bit of trouble after recently upgrading to postgresql
> 8.3. I have a small function that used to work fine before the upgrade. The
> code is in pgsql, and the specific line that is giving me problems is as
> follows:
>
> execute 'select sum(weight) from ' || quote_ident($1) || '.' ||
> quote_ident($2) || ' where the_geom && ''' || temp_geom || ''' order by sum
> desc limit 1' into pts_weight;
>
> I am trying calculate a weighted sum of all points (defined by 'the_geom')
> that fall within the bounding box of a polygon defined by 'temp_geom'. The
> error I get is as follows:
>
>
> ERROR:  operator is not unique: text || geometry
> LINE 1: ...ast (st_extent(the_geom) as geometry) && cast(''' ||  $3  ||...
>                                                              ^
> HINT:  Could not choose a best candidate operator. You might need to add
> explicit type casts.
> QUERY:  SELECT  'select sum(weight) from ' || quote_ident( $1 ) || '.' ||
> quote_ident( $2 ) || ' where cast (st_extent(the_geom) as geometry) &&
> cast(''' ||  $3  || ''' as geometry) order by sum desc limit 1'
> CONTEXT:  PL/pgSQL function "computegrid_quad" line 84 at EXECUTE statement
>
>
> ********** Error **********
>
> ERROR: operator is not unique: text || geometry
> SQL state: 42725
> Hint: Could not choose a best candidate operator. You might need to add
> explicit type casts.
> Context: PL/pgSQL function "computegrid_quad" line 84 at EXECUTE statement
>
> I did find some information about this online, but can't quite get a hold
> on the problem. Any suggestions will be most appreciated.
>
> Thanks much,
>
> Chetan
>
> ------------------------------
>
> * The substance of this message, including any attachments, may be
> confidential, legally privileged and/or exempt from disclosure pursuant to
> Massachusetts law. It is intended solely for the addressee. If you received
> this in error, please contact the sender and delete the material from any
> computer. *
>
> ------------------------------
>
> * Help make the earth a greener place. If at all possible resist printing
> this email and join us in saving paper. *
>
>
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
>
>


-- 
Chetan Tiwari, PhD
Assistant Professor
University of North Texas
Department of Geography
1155 Union Circle #305279
Denton, TX 76203-5017
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20081027/29ab20cb/attachment.html>


More information about the postgis-users mailing list