Skip site navigation (1) Skip section navigation (2)

PLPG

From: alfranio correia junior <alfranio(at)lsd(dot)di(dot)uminho(dot)pt>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: PLPG
Date: 2006-11-28 14:04:32
Message-ID: 456C41F0.8000909@lsd.di.uminho.pt (view raw or flat)
Thread:
Lists: pgsql-jdbc
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.


Responses

  • Re: PLPG at 2006-11-28 14:17:24 from Dave Cramer

pgsql-jdbc by date

Next:From: Dave CramerDate: 2006-11-28 14:17:24
Subject: Re: PLPG
Previous:From: Ingmar LötzschDate: 2006-11-28 09:46:31
Subject: Re: PreparedStatement and TYPE bit

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group