X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 0A8675654C; Fri, 11 Mar 2005 17:47:30 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 17698-03; Fri, 11 Mar 2005 17:47:21 +0000 (GMT) Received: from tigger.fuhr.org (tigger.fuhr.org [63.214.45.158]) by svr1.postgresql.org (Postfix) with ESMTP id 7D8AA565AC; Fri, 11 Mar 2005 17:47:17 +0000 (GMT) Received: from winnie.fuhr.org (winnie.fuhr.org [10.1.0.1]) by tigger.fuhr.org (8.13.3/8.13.3) with ESMTP id j2BHlA6r015414 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 11 Mar 2005 10:47:13 -0700 (MST) (envelope-from mfuhr@winnie.fuhr.org) Received: from winnie.fuhr.org (localhost [127.0.0.1]) by winnie.fuhr.org (8.13.3/8.13.3) with ESMTP id j2BHlA6k015752; Fri, 11 Mar 2005 10:47:10 -0700 (MST) (envelope-from mfuhr@winnie.fuhr.org) Received: (from mfuhr@localhost) by winnie.fuhr.org (8.13.3/8.13.3/Submit) id j2BHlAUW015751; Fri, 11 Mar 2005 10:47:10 -0700 (MST) (envelope-from mfuhr) Date: Fri, 11 Mar 2005 10:47:10 -0700 From: Michael Fuhr To: William Shatner Cc: pgsql-novice@postgresql.org, pgsql-general@postgresql.org, pgsql-jdbc@postgresql.org Subject: Re: MS Access to PostgreSQL Message-ID: <20050311174710.GA15654@winnie.fuhr.org> References: <9af1b1990503110919553a66ec@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <9af1b1990503110919553a66ec@mail.gmail.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.004 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200503/481 X-Sequence-Number: 74796 On Fri, Mar 11, 2005 at 05:19:35PM +0000, William Shatner wrote: > I have recently migrated from MS Access to PostgreSQL.Previously I had > a SQL command > > ResultSet aGroupResultSet = aGroupPathStmt.executeQuery( > "SELECT \"groupID\",\"fullpath\" FROM \"groups\" WHERE > \"fullpath\" Like '" + > aPath + "'"); > > where aPath was equal to 'folder\another folder\%'. > > The field to be edited stores the full path in the format > 'folder\folder1\folder2' and so on... > The purpose being to change all groups at this level of the > hieracarchy and below, this was achieved using the '%' in Access, this > however doesn't seem to work in PostgreSQL, it doesn't error out but > it just seems to see the '%' as a normal character. You're running into problems with \ being the escape character in string constants and again in patterns. There's some discussion of this in the "Pattern Matching" section of the "Functions and Operators" chapter in the documentation: http://www.postgresql.org/docs/8.0/interactive/functions-matching.html Here are some ways to make it work (dollar quoting available only in 8.0 and later): fullpath LIKE 'folder\\\\another folder\\\\%' fullpath LIKE 'folder\\another folder\\%' ESCAPE '' fullpath LIKE $$folder\\another folder\\%$$ fullpath LIKE $$folder\another folder\%$$ ESCAPE '' -- Michael Fuhr http://www.fuhr.org/~mfuhr/