Re: [JDBC] psqlexception syntax error at or near "$"

From: "Kevin Grittner" <Kevin(dot)Grittner(at)wicourts(dot)gov>
To: "Steven Dahlin" <pgdb(dot)sldahlin(at)gmail(dot)com>
Cc: <pgsql-general(at)postgresql(dot)org>
Subject: Re: [JDBC] psqlexception syntax error at or near "$"
Date: 2010-11-09 18:17:04
Message-ID: 4CD93BC00200002500037492@gw.wicourts.gov
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-jdbc

[Please keep the list copied and please don't top-post.]
[Also, this thread really belongs on pgsql-general or pgsql-novice;
it doesn't seem to have anything to do with JDBC, so I'm blind
copying the JDBC list and posting to general to move it.]

Steven Dahlin <pgdb(dot)sldahlin(at)gmail(dot)com> wrote:
> Kevin Grittner <Kevin(dot)Grittner(at)wicourts(dot)gov>wrote:
>
>>> CREATE OR REPLACE FUNCTION system_info_fnc01() RETURNS trigger
>>> AS $$
>>
>>> raise exception ''System Info record already present'';
>>
>>> $$
>>
>> When you use dollar quoting you should not double your
>> apostrophes.
>>
>> Try:
>>
>> raise exception 'System Info record already present';

> That makes no difference.

It seems to make a difference on my machine:

test=# CREATE OR REPLACE FUNCTION system_info_fnc01() RETURNS
trigger AS
test-# $$
test$# declare
test$# iCnt integer;
test$# begin
test$# select count(*) into iCnt from system_info;
test$# if ( iCnt > 0 ) then
test$# raise exception ''System Info record already present'';
test$# end if;
test$# return new;
test$# end;
test$# $$
test-# LANGUAGE 'plpgsql' IMMUTABLE;
ERROR: syntax error at or near "System"
LINE 8: raise exception ''System Info record already present'';
^
test=# CREATE OR REPLACE FUNCTION system_info_fnc01() RETURNS
trigger AS
test-# $$
test$# declare
test$# iCnt integer;
test$# begin
test$# select count(*) into iCnt from system_info;
test$# if ( iCnt > 0 ) then
test$# raise exception 'System Info record already present';
test$# end if;
test$# return new;
test$# end;
test$# $$
test-# LANGUAGE 'plpgsql' IMMUTABLE;
CREATE FUNCTION

If you're getting different results, please copy/paste actual code.

What version of PostgreSQL are you running?

-Kevin

Browse pgsql-general by date

  From Date Subject
Next Message Sandeep Srinivasa 2010-11-09 18:36:08 Re: Why facebook used mysql ?
Previous Message David Boreham 2010-11-09 18:16:17 Re: Why facebook used mysql ?

Browse pgsql-jdbc by date

  From Date Subject
Next Message Nathan Sullins 2010-11-09 23:26:14 JDBC4 and JDK 1.6
Previous Message Kevin Grittner 2010-11-09 14:53:18 Re: psqlexception syntax error at or near "$"