Home » SQL & PL/SQL » SQL & PL/SQL » Insert into a table from another
Insert into a table from another [message #20600] Thu, 06 June 2002 07:33 Go to next message
Debby
Messages: 3
Registered: June 2002
Junior Member
I have two tables like this:

Table T1
--------
A1 VARCHAR2 (2)
B1 VARCHAR2 (2)

Table T2
--------
A2 VARCHAR2 (2)
B2 VARCHAR2 (2)
C2 DATE

I want to insert all the rows from table T1 into
Table T2 into fields A2, B2. This can be done
using:

INSERT INTO T2(A2, B2) (SELECT * FROM T1);

But my problem is, now I also want the C2 field
to be populated with SYSDATE.

Can it be done with a nice and easy SQL? A PL/SQL
construct may also be OK. But I am more comfortable
with a single SQL query.

I also do not want a Trigger.

TIA,

Deborah
Re: Insert into a table from another [message #20601 is a reply to message #20600] Thu, 06 June 2002 07:48 Go to previous messageGo to next message
Sujit Mahapatra
Messages: 19
Registered: March 2002
Junior Member
A little modification to the above query:

INSERT INTO T2 (SELECT A1, B1, SYSDATE FROM T1);

Cheers,

Sujit
Re: Insert into a table from another [message #20603 is a reply to message #20600] Thu, 06 June 2002 08:26 Go to previous message
bechir
Messages: 23
Registered: November 2001
Junior Member
Use Sujit's statement. I thought the insert was from T2 to T1 and you just want to insert sysdate in the date field.
Previous Topic: to prevent a package from being executed again when it's already running
Next Topic: SQL running slow!
Goto Forum:
  


Current Time: Fri Apr 26 00:43:50 CDT 2024