Received: from localhost (maia-2.hub.org [200.46.204.187]) by postgresql.org (Postfix) with ESMTP id 5F24B9FB1DF for ; Tue, 28 Nov 2006 10:04:50 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.187]) (amavisd-new, port 10024) with ESMTP id 09499-02 for ; Tue, 28 Nov 2006 10:04:34 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from dcs.lsd.di.uminho.pt (linux.di.uminho.pt [193.136.19.96]) by postgresql.org (Postfix) with ESMTP id 13FC59FB1C4 for ; Tue, 28 Nov 2006 10:04:39 -0400 (AST) Received: (qmail 4897 invoked by uid 89); 28 Nov 2006 14:04:35 -0000 Received: from unknown (HELO ?192.168.82.115?) (alfranio@lsd.di.uminho.pt@192.168.82.254) by dcs.lsd.di.uminho.pt with ESMTPA; 28 Nov 2006 14:04:35 -0000 Message-ID: <456C41F0.8000909@lsd.di.uminho.pt> Date: Tue, 28 Nov 2006 14:04:32 +0000 From: alfranio correia junior User-Agent: Thunderbird 1.5.0.8 (X11/20061117) MIME-Version: 1.0 To: pgsql-jdbc@postgresql.org Subject: PLPG Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200611/159 X-Sequence-Number: 16201 How do I create a PLPG procedure by means of a statement ? For instance: private static String createFunction = "CREATE OR REPLACE FUNCTION process_audit_customer() RETURNS TRIGGER AS \n" + "$process_audit$ \n" + "BEGIN \n" + "IF (TG_OP = 'DELETE') THEN \n" + "INSERT INTO tmp_customer SELECT OLD.*, 'D', now(), user\\; \n" + "RETURN OLD\\; \n" + "ELSIF (TG_OP = 'UPDATE') THEN \n" + "INSERT INTO tmp_customer SELECT OLD.*, 'U', now(), user\\; \n" + "RETURN NEW\\; \n" + "ELSIF (TG_OP = 'INSERT') THEN \n" + "INSERT INTO tmp_customer SELECT NEW.*, 'I', now(), user\\; \n" + "RETURN NEW\\; \n" + "END IF\\; \n" + "RETURN NULL\\; \n" + "END\\; \n" + "$process_audit$ \n" + "LANGUAGE plpgsql SECURITY DEFINER;"; When I try to execute such statement an exception is raised: ERROR: unterminated dollar-quoted string at or near "$process_audit$ BEGIN IF (TG_OP = 'DELETE') THEN INSERT INTO tmp_customer SELECT OLD.*, 'D', now(), user Does anybody have a suggestion ? Regards, Alfranio.