I am trying to figure out the correct syntax to insert a row into a table that is part of a joined inheritance strategy.
If I have Detail and SubDetail. SubDetail extends Detail using JOINED. Detail has the single attribute name. SubDetail doesn’t have any fields specific to it; it is just an alias for Detail, really. I am trying to insert a SubDetail into the database.
WITH ppIDtble AS ( INSERT INTO SAMPLE_SUBDETAIL ( ID ) VALUES ( NEWID() ) RETURNING * ) INSERT INTO SAMPLE_DETAIL ( ID, VERSION, NAME ) VALUES ( (SELECT ID FROM ppIDtble limit 1), 1, 'P. Sherman' );
INSERT INTO SAMPLE_SUBDETAIL ( ID, VERSION, NAME ) VALUES ( NEWID(), 1, 'P. SHERMAN' );
INSERT INTO TEST_DETAIL (ID, VERSION, NAME) VALUES ( (NEWID(), 1, 'P. SHERMAN') ); INSERT INTO TEST_SUBDETAIL (ID) VALUES (SELECT l.ID as ID FROM TEST_DETAIL l where l.name = 'P. SHERMAN');
I’m not able to get it to insert. I do not have much experience in SQL and Googling around didn’t give me many leads so I’m rather stuck here.