Home » SQL & PL/SQL » SQL & PL/SQL » INSERT and SELECT statements (Windows)
INSERT and SELECT statements [message #674967] Tue, 26 February 2019 08:53 Go to next message
Messages: 1
Registered: February 2019
Junior Member

I'm trying to create a query to insert multiple entries into a table(TABLE B) based on a SELECT query on another table(TABLE A), but cant get the syntax....would be grateful for any input.

The tables can be simplified as:
TABLE_A {user_id, last_login_date,...}
TABLE_B {sequential_id, field_1, field_2, ...}

I put together the following, which ceases to work as soon as the 'SELECT FROM TABLE A' statement returns more than one row. I've read the documentation around the topic, so have an outline understanding of why it comprises an error condition, but am not sure how to resolve.

( sequential_id,
field_2 )
( (SELECT MAX(sequential_id) + 1 FROM TABLE_B),
(SELECT user_id FROM TABLE_A where last_login_date > 'some date' AND last_login_date < 'some other date'),
'some text' );

I'd appreciate any input/suggestions...?

Thanks in advance,

Re: INSERT and SELECT statements [message #674968 is a reply to message #674967] Tue, 26 February 2019 09:08 Go to previous message
Messages: 13894
Registered: September 2008
Location: Rainy Manchester
Senior Member
See my answer over here https://community.oracle.com/thread/4203551
Previous Topic: Scenario Dates
Next Topic: Huge XML data in BLOB columns
Goto Forum:

Current Time: Wed Dec 01 08:06:05 CST 2021