3

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?

4
  • Interesting, works just fine on my local db (postgresql 9.1) Commented Feb 5, 2013 at 15:45
  • Maybe its a bug with sqlfiddle? I've tried it with a few different versions and it throws up the same error each time. Commented Feb 5, 2013 at 15:54
  • Start by providing the version number you use and how you execute the code. Commented Feb 5, 2013 at 16:21
  • 5
    Sorry Jimmy, this is a confusing part of SQL Fiddle. The problem is that your semi-colon within your function body is breaking my default parsing mechanism. If you change your "query terminator" to something other than a semi-colon (the default) your function will work fine: sqlfiddle.com/#!1/ede11 Commented Feb 7, 2013 at 17:06

1 Answer 1

0

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.

Sign up to request clarification or add additional context in comments.

4 Comments

If you uncomment the function at the bottom and build schema it gives the error. I think based on what you say it is a bug with the website: sqlfiddle.com/#!11/6810d
@ErwinBrandstetter Actually, SQL Fiddle does support functions. You just have to change the "query terminator" to something other than a semi-colon. sqlfiddle.com/#!1/ede11
@JakeFeasel: That's awesome! I didn't know that. Deleted my incorrect comment. Would be great, of course, if the query terminator thingy could be fixed somehow, too.
@ErwinBrandstetter yes, it's a feature that I've long thought about how to improve its visibility. Clearly a UX fail. I have some ideas about how to improve it that I'm hoping to get around to trying out soon.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.