Hello All,

I want to write the plsql stored procedure to insert multiple rows in a table.

Table t1, table t2.
Table t1 column names(c1,c2,c3,c4,c5)
table t2 column name (c2,c3,c4)
column names c2, c3, c4 are same in both tables.

now I want to insert the data into t1 by selecting table t2 data for those columns.

Thank you.

Recommended Answers

All 4 Replies

Hi

I haven't used Oracle so this may not be correct, but you might be able to use something like the following:

INSERT INTO t1 (c2, c3, c4) SELECT c2, c3, c4 FROM t2

You might need to tweak it a bit.

HTH

Thank you, But how to Insert the remaining column values.

Insert into t1(c1,c2,c3,c4,c5)
"Select c2,c3,c4 from t2" --- only gives the value of c2,c3,c4

Well what data would go into c1 and c5 in t1 if they don't exist in t2?

Solved, C1 and c5 data will be manual. so I used,
Insert into t1(c1,c2,c3,c4,c5)
select "a" as c1, c2, c3, c4, "b" as c5 from t2

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.