Received: from www-uk-05.digiserve.com ([195.97.231.11]) by postgresql.org (8.11.3/8.11.1) with ESMTP id f2TD4HK12841 for ; Thu, 29 Mar 2001 08:04:17 -0500 (EST) (envelope-from dev@archonet.com) Received: from mainbox.archonet.com (mwynhau.demon.co.uk [193.237.186.96]) by www-uk-05.digiserve.com (8.9.1/8.9.1) with ESMTP id OAA05541; Thu, 29 Mar 2001 14:05:08 +0100 (BST) Received: from client (client.archonet.com [192.168.1.16]) by mainbox.archonet.com (Postfix) with SMTP id 575C92A3AC; Thu, 29 Mar 2001 13:35:57 +0100 (BST) Message-ID: <011d01c0b84c$cc9f6f80$1001a8c0@archonet.com> From: "Richard Huxton" To: "Martijn van Dijk" , References: <007a01c0b827$10d5b450$0301000a@collective> Subject: Re: Escaping \ Date: Thu, 29 Mar 2001 13:35:53 +0100 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4133.2400 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 X-Archive-Number: 200103/603 X-Sequence-Number: 2274 From: "Martijn van Dijk" > I've a problem with escaping a \ in a string. > > When I enter the query: > > SELECT '''\\\''; I get the right result: '\' > > But when I try this in a Function: > > CREATE FUNCTION sp_tmp() RETURNS varchar(10) > AS ' > SELECT ''\\\' AS RESULT' > LANGUAGE 'sql'; > > I get the following Parse-erros: > > psql:tmp1:4: ERROR: Unterminated quoted string. I don't understand why, > when you leave the SELECT-statement out you get '''\\\'' and that is not > unterminated. Had something similar myself the other day. The reason is that you are already one deep in Postgres' string-parser, so you need something like: SELECT ''\\\\'' AS RESULT HTH - Richard Huxton