I have the following function definition for a PostgreSQL 9.3.4 database:
CREATE OR REPLACE FUNCTION update_modified_timestamp()
RETURNS TRIGGER AS $$
BEGIN
NEW.modified_at = now();
RETURN NEW;
END;
$$ LANGUAGE plpgsql;
When I try to execute this in SQuirreL (3.5.3 or 3.6), I get the following error:
Error: ERROR: unterminated dollar-quoted string at or near "$$
BEGIN
NEW.modified_at = now()"
Position: 77
SQLState: 42601
ErrorCode: 0
So far I've learned this can be mitigated by using single quotes to delimit the function body like so:
CREATE OR REPLACE FUNCTION update_modified_timestamp()
RETURNS TRIGGER AS '
BEGIN
NEW.modified_at = now();
RETURN NEW;
END;
' LANGUAGE plpgsql;
Still I would like to know if this can't be solved otherwise - I think it must be possible since Flyway can execute this script and it uses the exact same JDBC driver that is configured in SQuirreL.
Update: @a_horse_with_no_name noted that this error has nothing to do with the JDBC driver, but with how SQuirreL parses the SQL statement and splits it into chunks before sending them to the database. Thus the remaining question is: Can SQuirreL send a query raw/unparsed? I've searched quite a bit couldn't find a way to do that.
You can change the statement separator so the statement is not split on a ;
:
Go to: Session → Session Properties → SQL → Statement Separator
Even though you can't change it to an empty string, you can change it for example to //
, which allows execution of the statement in the question.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With