clear markdown compare help donate or buy diddy dollings comments/suggestions/bugs a leap of faith? bible365
clear markdown donate comments/suggestions/bugs a leap of faith? bible365 diddy dollings
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0. 818513 fiddles created (9187 in the last week).

create table road_vertices ( road_id number, vertex_index number, x number, y number );
 hidden batch(es)


begin insert into road_vertices values ('100',1,0,5); insert into road_vertices values ('100',2,10,10); insert into road_vertices values ('100',3,30,0); insert into road_vertices values ('100',4,50,10); insert into road_vertices values ('100',5,60,10); end; /
1 rows affected
 hidden batch(es)


create or replace type shape_t as object ( road_id number , vertex_index number , x number , prev_x number , y number , prev_y number , dist_to_prev number , member function getdistance return number ); /
ORA-01031: insufficient privileges
 hidden batch(es)


create or replace type body shape_t is member function getdistance return number is begin if vertex_index > 1 then return round( sqrt( power( x - prev_x, 2 ) + power( y - prev_y, 2 ) ) , 2 ); else return 0 ; end if; exception -- needs some more stuff when others then dbms_output.put_line ( 'snookered!' ); end; end; /
ORA-01031: insufficient privileges
 hidden batch(es)


create or replace procedure populate_shape_table is type tost_ is table of shape_t index by pls_integer ; -- use the vertex type munged tost_ ; begin select shape_t ( road_id , vertex_index , x , case when vertex_index = 1 then 0 else lag ( x,1 ) over ( partition by road_id order by vertex_index ) end , y , case when vertex_index = 1 then 0 else lag ( y,1 ) over ( partition by road_id order by vertex_index ) end , 0 -- dist_to_prev ) bulk collect into munged from road_vertices order by road_id, vertex_index ; for i in 1 .. munged.count loop -- cannot use FORALL here (FORALL <> FOR) munged(i).dist_to_prev := munged(i).getdistance() ; end loop; forall i in munged.first .. munged.last insert into shape_table values ( munged(i) ) ; end populate_shape_table; / begin populate_shape_table; end; /
ORA-24344: success with compilation error
 hidden batch(es)