I have the below sql query to insert the records from a table. The problem is when there is no records for select query i still want an record with the sequence number,null,’3′ value inserted. Nothing get’s inserted when there is no record found for select query. how can i do it?
insert into test_details(seqnbr,trepid,type)
select '&seqid'
,REP_ID
,'3'
FROM ref_details
WHERE REP_ID >13;
Oracle 9i+:
To fill in gaps, you need to create a list of sequencial values:
…then LEFT JOIN to the table that can have gaps.