簡體   English   中英

錯誤:列索引超出范圍:1,列數:0

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

我正在使用 wso2dss 3.0.0。我正在嘗試執行 postgresql 查詢,即

SELECT addressid, geocode
FROM maddress
WHERE geocode::point <@ circle '((18.9750,72.8258), 5)';

它在 PostgreSQL 中工作正常。當我在 wso2dss 中使用相同的查詢時,即

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

它給了我這樣的錯誤:

DS Fault Message: Error in 'SQLQuery.processNormalQuery'
DS Code: DATABASE_ERROR
Source Data Service:-
Name: Geofence_DataService
Location: /Geofence_DataService.dbs
Description: N/A
Default Namespace: http://ws.wso2.org/dataservice
Current Request Name: adding_geofence_op
Current Params: {longitude=72.8258, radius=4, latitude=18.9750}
Nested Exception:-
DS Fault Message: Error in 'createProcessedPreparedStatement'
DS Code: UNKNOWN_ERROR
Nested Exception:-
org.postgresql.util.PSQLException: The column index is out of range: 1, number of columns: 0.

如果我刪除圓的" ' "引號),那么它也不會執行。 查詢 '' 看起來像這樣:

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

它會給出以下錯誤:

Caused by: javax.xml.stream.XMLStreamException: DS Fault Message: Error in 'SQLQuery.processNormalQuery'
DS Code: DATABASE_ERROR
Source Data Service:-
Name: Geofence_DataService
Location: /Geofence_DataService.dbs
Description: N/A
Default Namespace: http://ws.wso2.org/dataservice
Current Request Name: geofence_op
Current Params: {longitude=72.8258, radius=4, latitude=18.9750}
Nested Exception:-
org.postgresql.util.PSQLException: ERROR: function circle(record, double precision) does not exist
  Hint: No function matches the given name and argument types. You might need to add explicit type cast

但是圓是PostgreSQL內置的地理函數,那么有必要寫顯式函數嗎? 否則確切的錯誤在哪里? 即使我在 PostgreSQL 中執行時將查詢與輸入參數放在一起,它也可以工作。如果是這樣,那么為什么它不接受動態參數? 請告訴我..

幾何類型可以通過多種方式輸入。

  • 在第一種形式中,您的? 參數不會被值替換,因為它們是字符串的文字部分。 所以預計0個參數......

  • 在沒有單引號的第二種形式中,您的? 參數被替換,但((18.9750,72.8258), 5)被解釋為行類型,​​它不適用於circle()

您正在嘗試調用采用pointdouble precision (“圓心和半徑”)的幾何函數circle() )。 這些是有效的語法變體:

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 小提琴。
轉換為::text只是為了清理 SQL 小提琴中的混亂顯示

在您的情況下,要提供數值(不是字符串文字),請使用最后一種形式,它應該可以工作:

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

如果 wso2dss(我沒有經驗)不接受函數,則必須使用前兩種形式之一並提供單個參數作為字符串文字:

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

... 其中參數是如上所示的連接文字。

可以讓 Postgres 進行連接並仍然傳遞三個數值:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM