Search notes:

Oracle: Lateral inline views

A subquery (or more accurately an inline view) can be marked with the lateral keyword which turns it into a lateral inline view.
Lateral inline views were introduced with Oracle 12c.
create table tq84_a (
  id   number          primary key,
  txt  varchar2(10) 
);

create table tq84_b (
  id_a number          references tq84_a,
  txt  varchar2(10) 
);

insert into tq84_a values (0, 'zero' );
insert into tq84_a values (1, 'one'  );
insert into tq84_a values (2, 'two'  );
insert into tq84_a values (3, 'three');

insert into tq84_b values (1, '.'    );

insert into tq84_b values (2, '-'    );
insert into tq84_b values (2, '--'   );

insert into tq84_b values (3, '*'    );
insert into tq84_b values (3, '**'   );
insert into tq84_b values (3, '***'  );


insert into tq84_b values (null,'<>');

select
  a.id,
  a.txt   txt_a,
  b.txt   txt_b
from
  tq84_a a,
  lateral(select id, b.txt
            from tq84_b b
           where b.id_a = a.id) b;


drop table tq84_b;
drop table tq84_a;
Github repository Oracle-Patterns, path: /SQL/select/12c/lateral.sql

See also

Setting events 22829.
cross apply

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1758198567, '216.73.216.150', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/databases/Oracle/SQL/select/subquery/lateral/index(86): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78