agora inbox for pljava-dev@postgresql.org
help / color / mirror / Atom feed[Pljava-dev] Cancelling trigger operation
6+ messages / 0 participants
[nested] [flat]
* [Pljava-dev] Cancelling trigger operation
@ 2006-10-23 08:02
2006-10-23 08:46 ` [Pljava-dev] Cancelling trigger operation
0 siblings, 1 reply; 6+ messages in thread
From: @ 2006-10-23 08:02 UTC (permalink / raw)
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
^ permalink raw reply [nested|flat] 6+ messages in thread
* [Pljava-dev] Cancelling trigger operation
2006-10-23 08:02 [Pljava-dev] Cancelling trigger operation
@ 2006-10-23 08:46 `
2006-10-23 08:52 ` [Pljava-dev] Cancelling trigger operation
0 siblings, 1 reply; 6+ messages in thread
From: @ 2006-10-23 08:46 UTC (permalink / raw)
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
>
^ permalink raw reply [nested|flat] 6+ messages in thread
* [Pljava-dev] Cancelling trigger operation
2006-10-23 08:02 [Pljava-dev] Cancelling trigger operation
2006-10-23 08:46 ` [Pljava-dev] Cancelling trigger operation
@ 2006-10-23 08:52 `
2006-10-23 09:07 ` [Pljava-dev] Cancelling trigger operation
2006-10-23 09:12 ` [Pljava-dev] Cancelling trigger operation
0 siblings, 2 replies; 6+ messages in thread
From: @ 2006-10-23 08:52 UTC (permalink / raw)
Hi, Thomas,
Thomas Hallgren wrote:
> 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.
What about using TriggerData.getNew().deleteRow() - is this too cryptic?
Thanks,
Markus
--
Markus Schaber | Logical Tracking&Tracing International AG
Dipl. Inf. | Software Development GIS
Fight against software patents in Europe! www.ffii.org
www.nosoftwarepatents.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 252 bytes
Desc: OpenPGP digital signature
URL: <http://lists.pgfoundry.org/pipermail/pljava-dev/attachments/20061023/84be2e4e/attachment.bin;
^ permalink raw reply [nested|flat] 6+ messages in thread
* [Pljava-dev] Cancelling trigger operation
2006-10-23 08:02 [Pljava-dev] Cancelling trigger operation
2006-10-23 08:46 ` [Pljava-dev] Cancelling trigger operation
2006-10-23 08:52 ` [Pljava-dev] Cancelling trigger operation
@ 2006-10-23 09:07 `
1 sibling, 0 replies; 6+ messages in thread
From: @ 2006-10-23 09:07 UTC (permalink / raw)
Unfortunately, deleteRow() is not supported in TriggerResultSet.
----- Original Message -----
From: "Markus Schaber" <schabi at logix-tt.com>
To: "Thomas Hallgren" <thomas at tada.se>
Cc: "Filip Hrbek" <filip.hrbek at plz.comstar.cz>;
<pljava-dev at gborg.postgresql.org>
Sent: Monday, October 23, 2006 10:52 AM
Subject: Re: [Pljava-dev] Cancelling trigger operation
^ permalink raw reply [nested|flat] 6+ messages in thread
* [Pljava-dev] Cancelling trigger operation
2006-10-23 08:02 [Pljava-dev] Cancelling trigger operation
2006-10-23 08:46 ` [Pljava-dev] Cancelling trigger operation
2006-10-23 08:52 ` [Pljava-dev] Cancelling trigger operation
@ 2006-10-23 09:12 `
2006-10-23 10:01 ` [Pljava-dev] Cancelling trigger operation
1 sibling, 1 reply; 6+ messages in thread
From: @ 2006-10-23 09:12 UTC (permalink / raw)
I see what you mean :-) and yes, I do think it is a bit too cryptic
since it suggests that there actually is a row that can be deleted. It
might lead to some semantic confusion. The reason the new and old row is
represented as ResultSet instances are not that they are sets as such,
it's just the best interface when dealing with a tuple. I don't want to
add to that confusion by allowing the deletion of the tuple that they
represent. An explicit method that denotes the cancellation of the
trigger is a better choice, IMO.
Regards,
Thomas Hallgren
Markus Schaber wrote:
> Hi, Thomas,
>
> Thomas Hallgren wrote:
>
>
>> 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.
>>
>
> What about using TriggerData.getNew().deleteRow() - is this too cryptic?
>
> Thanks,
> Markus
>
>
^ permalink raw reply [nested|flat] 6+ messages in thread
* [Pljava-dev] Cancelling trigger operation
2006-10-23 08:02 [Pljava-dev] Cancelling trigger operation
2006-10-23 08:46 ` [Pljava-dev] Cancelling trigger operation
2006-10-23 08:52 ` [Pljava-dev] Cancelling trigger operation
2006-10-23 09:12 ` [Pljava-dev] Cancelling trigger operation
@ 2006-10-23 10:01 `
0 siblings, 0 replies; 6+ messages in thread
From: @ 2006-10-23 10:01 UTC (permalink / raw)
Hi, Thomas,
Thomas Hallgren wrote:
> An explicit method that denotes the cancellation of the
> trigger is a better choice, IMO.
Thinking about it, I fully agree.
HTH,
Markus
--
Markus Schaber | Logical Tracking&Tracing International AG
Dipl. Inf. | Software Development GIS
Fight against software patents in Europe! www.ffii.org
www.nosoftwarepatents.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 252 bytes
Desc: OpenPGP digital signature
URL: <http://lists.pgfoundry.org/pipermail/pljava-dev/attachments/20061023/78052b6c/attachment.bin;
^ permalink raw reply [nested|flat] 6+ messages in thread
end of thread, other threads:[~2006-10-23 10:01 UTC | newest]
Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2006-10-23 08:02 [Pljava-dev] Cancelling trigger operation
2006-10-23 08:46 `
2006-10-23 08:52 `
2006-10-23 09:07 `
2006-10-23 09:12 `
2006-10-23 10:01 `
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox