Database Function giving an error - Postgresql

牧云@^-^@ 提交于 2019-12-10 20:17:18

问题


I had some help on here and got the following code:

-- Setup Solrid Function
CREATE OR REPLACE FUNCTION solrid(IN local_id INTEGER, OUT result TEXT) AS $$
DECLARE
  database_id TEXT := 'A';
BEGIN
  result := database_id || local_id::TEXT;
END;
$$ LANGUAGE PLPGSQL;

However when I run it in sqlfiddle it says:

Schema Creation Failed: ERROR: unterminated dollar-quoted string at or near "$$ DECLARE database_id TEXT := 'A'":

This error may seem pretty self explanatory but I can't figure out the way to fix it. Would anyone mind shedding some light on this please?


回答1:


There is absolutely nothing wrong with this function, it is 100 % legit. I tested with 8.4 and 9.1 in my installation.

There must be some kind of misunderstanding. This cannot be exactly the same code that triggers the error message.



来源:https://stackoverflow.com/questions/14711103/database-function-giving-an-error-postgresql

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