pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
PLPG
2+ messages / 2 participants
[nested] [flat]

* PLPG
@ 2006-11-28 14:04 alfranio correia junior <alfranio@lsd.di.uminho.pt>
  2006-11-28 14:17 ` Re: PLPG Dave Cramer <pg@fastcrypt.com>
  0 siblings, 1 reply; 2+ messages in thread

From: alfranio correia junior @ 2006-11-28 14:04 UTC (permalink / raw)
  To: 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.




^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: PLPG
  2006-11-28 14:04 PLPG alfranio correia junior <alfranio@lsd.di.uminho.pt>
@ 2006-11-28 14:17 ` Dave Cramer <pg@fastcrypt.com>
  0 siblings, 0 replies; 2+ messages in thread

From: Dave Cramer @ 2006-11-28 14:17 UTC (permalink / raw)
  To: alfranio correia junior <alfranio@lsd.di.uminho.pt>; +Cc: pgsql-jdbc

handling dollar quoted functions is a recent addition to the driver.

You should probably build the driver from source if you really need it.

Dave
On 28-Nov-06, at 9:04 AM, alfranio correia junior wrote:

> 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.
>
>
> ---------------------------(end of  
> broadcast)---------------------------
> TIP 2: Don't 'kill -9' the postmaster
>




^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2006-11-28 14:17 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2006-11-28 14:04 PLPG alfranio correia junior <alfranio@lsd.di.uminho.pt>
2006-11-28 14:17 ` Dave Cramer <pg@fastcrypt.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox