I am using the following SQL code:
CREATE TABLE container (
 containerID         UUID PRIMARY KEY,
 parentContainerId   UUID,
 description         VARCHAR(50) NOT NULL,

 FOREIGN KEY(parentContainerID) REFERENCES (containerID)
);
INSERT INTO container (containerID, description) VALUES
(random_UUID(), 'vriezer');
INSERT INTO container (
 containerID,
 parentContainerID,
 description
) VALUES (
 random_UUID(),
 SELECT containerID FROM container WHERE description = 'vriezer',
 'bovenste lade'
);
INSERT INTO container (
 containerID,
 parentContainerID,
 description
) VALUES (
 random_UUID(),
 SELECT containerID FROM container WHERE description = 'vriezer',
 'middelste lade'
);
INSERT INTO container (
 containerID,
 parentContainerID,
 description
) VALUES (
 random_UUID(),
 SELECT containerID FROM container WHERE description = 'vriezer',
 'onderste lade'
);

Now the containerID for 'vriezer' is fetched three times. That sounds
inefficient to me. Can that be done more efficient in SQL? (In a
program it would not be to difficult, but I would like a 'pure' SQL
solution.) Or is it not a real problem because of caching?

-- 
Cecil Westerhof

-- 
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/h2-database?hl=en.

Reply via email to