Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Using subquery in a insert statement.

777326Jun 5 2010 — edited Jun 7 2010
Hello All,

I read in a book that you can't use subquery in an insert statement . E.g:

1)insert into dates (date_col) values (select sysdate fom dual)

but when i tried using subquery like this:

2)insert into regions values ((select max(region_id)+1 from regions), 'Oce');

This query worked but 1st query didnt.From my assumptions if we try inserting values in table with the subqueries
for a particular column as in 1st query , it will throw error but not while inserting values in all columns as in 2nd query.

Please explain if my assumptions are correct or not. Also please clarify.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 5 2010
Added on Jun 5 2010
3 comments
3,808 views