Created
November 26, 2019 15:10
-
-
Save dmcghan/5466585849d5444edaacabe7015234e6 to your computer and use it in GitHub Desktop.
Parent-child test data with RAW keys
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
create table p ( | |
id raw(16) default sys_guid() primary key, | |
name varchar2(10) not null | |
); | |
create table c ( | |
id raw(16) default sys_guid(), | |
parent_id raw(16) not null | |
constraint c_p_id_fk | |
references p, | |
name varchar2(10) not null | |
); | |
declare | |
l_p1_id raw(16); | |
l_p2_id raw(16); | |
l_p3_id raw(16); | |
begin | |
insert into p (name) values ('p 1') returning id into l_p1_id; | |
insert into p (name) values ('p 2') returning id into l_p2_id; | |
insert into p (name) values ('p 3') returning id into l_p3_id; | |
insert into c (parent_id, name) values (l_p1_id, 'c 1 p 1'); | |
insert into c (parent_id, name) values (l_p1_id, 'c 2 p 1'); | |
insert into c (parent_id, name) values (l_p2_id, 'c 3 p 2'); | |
insert into c (parent_id, name) values (l_p3_id, 'c 4 p 3'); | |
insert into c (parent_id, name) values (l_p3_id, 'c 5 p 3'); | |
insert into c (parent_id, name) values (l_p3_id, 'c 6 p 3'); | |
end; | |
/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment