pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
how to create rule as on delete
3+ messages / 3 participants
[nested] [flat]

* how to create rule as on delete
@ 2005-10-19 04:43 efa din <efa_din80@yahoo.com>
  2005-10-25 03:08 ` Re: how to create rule as on delete elein <elein@varlena.com>
  0 siblings, 1 reply; 3+ messages in thread

From: efa din @ 2005-10-19 04:43 UTC (permalink / raw)
  To: pgsql-sql

This is my rule for doing the delete event. The rule
can be created. But the problem is, after the record
has been deleted from the 'mytable', this record
cannot be inserted into table 'maytable_log'.

CREATE RULE on_delete AS ON DELETE TO mytable DO
INSERT INTO mytable_log values (old.id,old.name);     
            


If I add the DO INSTEAD,the record can be inserted
into 'maytable_log' and also still remain in the table
'maytable'. Which is exactly not exist at all. It just
show it as im using the DO INSTEAD.

CREATE RULE on_delete AS ON DELETE TO mytable DO
INSTEAD INSERT INTO mytable_log values
(old.id,old.name); 

My problem is, how to insert the deleted record into
table 'mytable_log' without showing it in table
'maytable'. I really need the solution..please

                                   


	
		
__________________________________ 
Yahoo! Mail - PC Magazine Editors' Choice 2005 
http://mail.yahoo.com



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

* Re: how to create rule as on delete
  2005-10-19 04:43 how to create rule as on delete efa din <efa_din80@yahoo.com>
@ 2005-10-25 03:08 ` elein <elein@varlena.com>
  0 siblings, 0 replies; 3+ messages in thread

From: elein @ 2005-10-25 03:08 UTC (permalink / raw)
  To: efa din <efa_din80@yahoo.com>; +Cc: pgsql-sql

I think you want a delete trigger which does your
insert and then follows through with the delete
by returning old.

--elein
elein@varlena.com

On Tue, Oct 18, 2005 at 09:43:34PM -0700, efa din wrote:
> This is my rule for doing the delete event. The rule
> can be created. But the problem is, after the record
> has been deleted from the 'mytable', this record
> cannot be inserted into table 'maytable_log'.
> 
> CREATE RULE on_delete AS ON DELETE TO mytable DO
> INSERT INTO mytable_log values (old.id,old.name);     
>             
> 
> 
> If I add the DO INSTEAD,the record can be inserted
> into 'maytable_log' and also still remain in the table
> 'maytable'. Which is exactly not exist at all. It just
> show it as im using the DO INSTEAD.
> 
> CREATE RULE on_delete AS ON DELETE TO mytable DO
> INSTEAD INSERT INTO mytable_log values
> (old.id,old.name); 
> 
> My problem is, how to insert the deleted record into
> table 'mytable_log' without showing it in table
> 'maytable'. I really need the solution..please
> 
>                                    
> 
> 
> 	
> 		
> __________________________________ 
> Yahoo! Mail - PC Magazine Editors' Choice 2005 
> http://mail.yahoo.com
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 1: if posting/reading through Usenet, please send an appropriate
>        subscribe-nomail command to majordomo@postgresql.org so that your
>        message can get through to the mailing list cleanly
> 



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

* Re: how to create rule as on delete
@ 2005-10-25 02:45 Stewart Ben (RBAU/EQS4) * <Ben.Stewart@au.bosch.com>
  0 siblings, 0 replies; 3+ messages in thread

From: Stewart Ben (RBAU/EQS4) * @ 2005-10-25 02:45 UTC (permalink / raw)
  To: pgsql-sql

> If I add the DO INSTEAD,the record can be inserted
> into 'maytable_log' and also still remain in the table
> 'maytable'. Which is exactly not exist at all. It just
> show it as im using the DO INSTEAD.
> 
> My problem is, how to insert the deleted record into
> table 'mytable_log' without showing it in table
> 'maytable'. I really need the solution..please

Add a DELETE clause on the table 'maytable' as part of the DO INSTEAD,
after the INSERT INTO.

Or, IIRC, you could INSERT INTO (without the DO INSTEAD) with the
variable NEW - the NEW variable will store the row being deleted.

Best regards,

Ben Stewart

--
Robert Bosch (Australia) Pty. Ltd.
Engineering Quality Services, Student Software Engineer (RBAU/EQS4)
Locked Bag 66 - Clayton South, VIC 3169 - AUSTRALIA
Tel: +61 3 9541-7002 Fax: +61 3 9541-7700
mailto:ben.stewart@au.bosch.com
http://www.bosch.com.au/ 



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


end of thread, other threads:[~2005-10-25 03:08 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2005-10-19 04:43 how to create rule as on delete efa din <efa_din80@yahoo.com>
2005-10-25 03:08 ` elein <elein@varlena.com>
2005-10-25 02:45 Re: how to create rule as on delete Stewart Ben (RBAU/EQS4) * <Ben.Stewart@au.bosch.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