ERROR : The column index is out of range: 1, number of columns: 0

后端 未结 1 1227
轻奢々
轻奢々 2021-01-12 14:15

I\'m using wso2dss 3.0.0.I\'m trying to execute a postgresql query i.e.

SELECT addressid, geocode
FROM maddress
WHERE geocode::point <@ circle \'((18.9750         


        
相关标签:
1条回答
  • 2021-01-12 14:29

    Geometric types can be input in multiple ways.

    • In the first form, your ? parameters are not replaced with values because they are literal parts of a string. So 0 parameters are expected ...

    • In the second form without single quotes, your ? parameters are replaced, but ((18.9750,72.8258), 5) is interpreted to be a row type, which doesn't work with circle().

    You are trying to invoke the function circle() that takes a point and a double precision ("center and radius to circle"). These are valid syntax variants:

    SELECT circle '((18.9750,72.8258), 5)'        AS cast_literal
         ' <(18.9750,72.82580),5>'::circle        AS cast_literal2
         , circle(point '(18.9750,72.8258)', '5') AS literal_point_n_radius
         , circle(point(18.9750,72.8258), '5')    AS point_n_literal_radius
         , circle(point(18.9750,72.8258), 5)      AS point_n_radius
    

    SQL fiddle.
    The cast to ::text is just to sanitize the deranged display in SQL fiddle

    In your case, to provide numeric values (not a string literal), use the last form and it should work:

    SELECT addressid, geocode
    FROM   maddress
    WHERE  geocode::point <@ circle(point(?,?), ?);
    

    If wso2dss (which I have no experience with) does not accept functions, you have to use one of the first two forms and provide a single parameter as string literal:

    SELECT addressid, geocode
    FROM   maddress
    WHERE  geocode::point <@ circle ?;
    

    ... where the parameter is the concatenated literal as displayed above.

    You could let Postgres do the concatenation and still pass three numeric values:

    SELECT addressid, geocode
    FROM   maddress
    WHERE  geocode::point <@ ('(('::text || ? || ',' || ? || '),' || ? || ')')::circle;
    
    0 讨论(0)
提交回复
热议问题