From: thomas at tada.se (Thomas Hallgren) Date: Mon, 23 Oct 2006 10:46:27 +0200 Subject: [Pljava-dev] Cancelling trigger operation In-Reply-To: <003601c6f679$9e1af3c0$1e03a8c0@fhrbek> References: <449f4cf70610180438x3c928febw693667dae457e841@mail.gmail.com> <45367CD0.8090202@tada.se> <003601c6f679$9e1af3c0$1e03a8c0@fhrbek> Message-ID: <453C8163.8090100@tada.se> Hi Filip, Something is definitely missing in the TriggerData interface. It should have a 'setCancelled()' method that causes the returned tuple to be null. Please add a bug for this. Regards, Thomas Hallgren Filip Hrbek wrote: > Hi Thomas, > > when a trigger function is written in pl/pgsql, you can decide to cancel the > operation in a trigger(defined as "before event") by returning null instead > of "new", e.g. > > create function cancelling_trigger() returns trigger as > ' > begin > if new.num < 0 then > -- cancel operation for negative numbers > return null; > else > -- continue > -- do something... > return new; > end if; > end > ' language 'plpgsql'; > > Is there any way to do the same in pljava? I can't see it now, since the > trigger functions are mapped to static java methods with no return values > (void): > > public static void cancellingTrigger(TriggerData td) throws SQLException { > if (td.getNew().getInt("num") < 0) { > //Cancel operation - HOW??? > } > else { > //Continue > //do something... > } > } > > Filip > > _______________________________________________ > Pljava-dev mailing list > Pljava-dev at gborg.postgresql.org > http://gborg.postgresql.org/mailman/listinfo/pljava-dev >