When a stored procedure is created or replaced with with plugins.rawSQL we get the following error:
org.postgresql.util.PSQLException: ERROR: unterminated dollar-quoted string at or near "$
BEGIN
RETURN 1" ERROR: unterminated dollar-quoted string at or near "$
BEGIN
RETURN 1"
The sql sent to the server is:
"CREATE OR REPLACE FUNCTION idf_test() RETURNS integer AS $
BEGIN
RETURN 1;
END;
$ LANGUAGE plpgsql;"
Should a different string then $$ surrounding the procedure implementation be used?
When copied/pasted to command line psql the procedure is created correctly.
If you want to have PL/PgSQL installed in all your databases that you will be creating you can simply add it to the database named ‘template1’. PostgreSQL uses this database as a template to create a new one.
Note that you can use any database as a template, so very handy if you want to duplicate a production database (with data and all) to have a test environment.
The syntax for this is:
CREATE DATABASE myNewDB TEMPLATE myExistingDB;
TIP: if you screw up the database ‘template1’ you can drop it and create a new one using (for obvious reasons, read-only) database ‘template0’.