1. 程式人生 > 其它 >zero-length delimited identifier at or near """"的解決辦法(zero-length delimited...)

zero-length delimited identifier at or near """"的解決辦法(zero-length delimited...)

當程式中向postgresql或postgis中插入或者更新資料時,出現如下的錯誤:
org.postgresql.util.PSQLException: ERROR: zero-length delimited identifier at or near """"

...

報錯原因是:在一些資料庫中,雙引號“”可以用來標示字串String,但是在Postgres資料庫中,雙引號只能用來引用標示符(Double quotes are used only to quote an "identifier", i.e., the name of a table, column, view, etc. ),例如用來引用表名、列名等。所以,當你的語句裡用雙引號來標引String時,Postgre解析器以為你在引用一個標示符“identifier”(表名或者列名),但是卻發現雙引號裡面沒有對應的“標示符”,因此會報這個錯誤。


解決辦法:在Postgres查詢時,對於String你只能用單引號或者&來標識。In a Postgres query, you should always use single quotes or "dollar quotes" (see http://www.postgresql.org/docs/8.1/interactive/sql-syntax.html#SQL-SYNTAX-DOLLAR-QUOTING) for string literals.

參考:https://blog.csdn.net/gis1226/article/details/8894312