I am creating a database (using Oracle 12c) that will be used by a number of client applications. To simplify, I try to keep as much of the logic as possible inside the database by creating different views, so that the clients can just ask simple question without more complicated constructs like JOIN
or GROUP BY
. They should just have to do a simple SELECT
with some WHERE
conditions from a view, and let the view do the heavy lifting.
Now my problem is that I want to ask questions on the form
SELECT
-- Some fields.
FROM a
LEFT JOIN b ON a.id = b.id AND b.type = x
LEFT JOIN c ON a.id = c.id AND c.type = y
LEFT JOIN d ON a.id = d.id AND d.type = z
where x
, y
and z
are input from the client. I do not want the clients to have to construct that query. I would much rather have them do something more similar to this:
SELECT * FROM a_view WHERE b_type = x AND c_type = y AND d_type = z
Of course I could create one view for every possible combination of x
, y
and z
, but that would be a lot of views. Is there any better way to solve this problem, or should I just give up and let the clients write the query with the JOIN
?