0

I have created a PostgreSQL database. Now I try to work with it in SQL Workbench, but I have a problem with the way it understands statement delimiters. The documentation on alternate delimiters sais that SQL Workbench takes semicolon as the end of statement, which causes problems for functions and similar code blocks with more than one semicolon. That's why there's the 'alternate delimiter' option. However, the default alternate delimiter (/) makes the code invalid elsewhere - I picked SQL Developer for a workaround and as an alternate front-end, I can't sacrifice pgAdmin for it and I can't afford maintaining two versions of my source code just to avoid this limitation.

I tried to set --/ as the alternate delimiter instead - this disables the default '/', but it doesn't apply - seems that SQL Workbench can't handle multi-char delimiters.

Is there any way how to solve this problem? Is there any char that wouldn't make me trouble in pgAdmin but would be suitable for SQL Workbench alternate delimiter? Or is there any way to enable alternate delimiters consisting of some harmless char sequence?

EDIT: I tried to define the alternate delimiter both at global and connection settings, and with and without the "single line" option, and no success.

1
  • 1
    I use a multi-char alternate delimiter every day - with SQL Server it is set to GO. You probably get a better answer if you post that on the SQL Workbench forum (google groups). But as it is a multi DBMS tool I doubt it will ever work 100% the same way as the "native" tools. But in general --/ can't work because -- starts a (single line) comment and thus the whole line will be ignored.
    – user1822
    Commented Sep 11, 2014 at 9:33

1 Answer 1

0

I have asked in the SQL Workbench forum and Thomas Kellerer (author of SQL Workbench) helped me. This is a summary of his answer.

First, my sequence was wrong because -- is a comment, but the delimiter must be a valid (not commented out) character or a valid sequence of characters. This makes finding something suitable for a delimiter in SQL Workbench and still not breaking sql code for psql and pgAdmin impossible.

However, there is a workaround: to execute the script through following command:

WbInclude -file=/some/dir/my_function.sql -delimiter=XXXXXX;

That XXXXXX can be anything that is not in the code. This way you can only execute scripts, not edit them, but that's sufficient for me. Currently, there's no better way to operate the code both in and out SQL Workbench.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.