问题
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