Unterminated dollar-quoted string at or near "$$

馋奶兔 提交于 2020-01-21 09:17:05

问题


I'm trying to declare some variables using DBeaver and keep hitting this error.

Unterminated dollar-quoted string at or near "$$

 DO $$
 DECLARE A integer; B integer;

BEGIN   
END$$;

Any ideas?


回答1:


DBeaver was the issue. Switched to PGAdmin and no more problems.




回答2:


As of DBeaver 6, you can execute the script with ALT-X (on Windows), which does not attempt to do variable capture/interpolation involving dollar signs.




回答3:


The syntax posted is fine. Your problem is that the client application or driver is mangling the query, probably because it doesn't understand dollar-quoting.

It might be trying to split it into separate statements on semicolons, running:

  • DO $$ DECLARE A integer;
  • B integer;
  • BEGIN END$$;

as three separate statements. This would result in the reported error, e.g.

$ psql -c 'DO $$ DECLARE A integer;'
ERROR:  unterminated dollar-quoted string at or near "$$ DECLARE A integer;"
LINE 1: DO $$ DECLARE A integer;
           ^

This is why you must specify your client driver/application when asking questions.


Another possibility with some clients is that it might treat $ as an escaped query-parameter placeholder and replace it with a single $ or try to substitute it for a server-side placeholder like $1. That's not what's happening here, though.



来源:https://stackoverflow.com/questions/32634418/unterminated-dollar-quoted-string-at-or-near

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!