Home » SQL & PL/SQL » SQL & PL/SQL » copy the contents from one table to another throug trigger
copy the contents from one table to another throug trigger [message #235334] Sat, 05 May 2007 01:56 Go to next message
oradat
Messages: 18
Registered: April 2007
Junior Member
Hello every one
how to write an trigger which would enable me to copy the contents of one table to an another .
eg create table temp(
empno varchar2(5),
name varchar2(40));
create table temp_bakup(
empno varchar2(5),
name varchar2(40);
);

now i want to write an such an trigger that would copy the values while inserting in temp into temp_bak.
Re: copy the contents from one table to another throug trigger [message #235341 is a reply to message #235334] Sat, 05 May 2007 02:47 Go to previous messageGo to next message
Mohammad Taj
Messages: 2412
Registered: September 2006
Location: Dubai, UAE
Senior Member

Hi,

Create Trigger with below option.
1.ALTER INSERT
2.FOR EACH ROW
3.:NEW


http://www.adp-gmbh.ch/ora/sql/create_trigger.html


Regards
Taj
Re: copy the contents from one table to another throug trigger [message #235350 is a reply to message #235334] Sat, 05 May 2007 04:30 Go to previous messageGo to next message
Michel Cadot
Messages: 68722
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
What is your final purpose?
It is more than likely that trigger is not the correct way to achieve what you need.

Regards
Michel
Re: copy the contents from one table to another throug trigger [message #235362 is a reply to message #235334] Sat, 05 May 2007 06:23 Go to previous messageGo to next message
brizwanahammad.msc
Messages: 1
Registered: May 2007
Location: kldkifkfkf
Junior Member

Hi
I am rizwan may be the folling code will helps u try it
create table a(roll_num number(5), name varchar2(15));
create table b(st_num number(5), name varchar2(15));
--------------
create or replace trigger tg1
before insert on a for each row
begin
insert into b(st_num,name) values(:new.roll_num,:new.name);
end;
/
check the code by inserting values in to the table 'a' the values
of the a will be inserted in the table 'b'.
/
--regards--
rizwan
Re: copy the contents from one table to another throug trigger [message #235628 is a reply to message #235362] Mon, 07 May 2007 08:21 Go to previous messageGo to next message
joy_division
Messages: 4963
Registered: February 2005
Location: East Coast USA
Senior Member
brizwanahammad.msc wrote on Sat, 05 May 2007 07:23
Hi
I am rizwan may be the folling code will helps u try it



Please translate this sentence into english, or any other language for that matter.
Re: copy the contents from one table to another throug trigger [message #235639 is a reply to message #235362] Mon, 07 May 2007 09:20 Go to previous messageGo to next message
Michel Cadot
Messages: 68722
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
And format the code.

Regards
Michel
Re: copy the contents from one table to another throug trigger [message #237218 is a reply to message #235362] Sun, 13 May 2007 09:12 Go to previous message
oradat
Messages: 18
Registered: April 2007
Junior Member
Thanks
Mr Rizwan this code really works and the concept
of for each row is also cleared .
pls send email me for ur queries regarding pl/sql.
my email id is zizu9096@gmail.com
Previous Topic: what Bitand Function ????
Next Topic: what is hard-coded
Goto Forum:
  


Current Time: Wed Dec 11 21:21:07 CST 2024