Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Dynamically constructing query...advice sought
Oracle 8i (8.1.7+) and 9i R2
Take the following simplified table structure
person_id number name varchar2(30) QUESTIONS question_id number question varchar2(30) answer_type varchar2(30) -- DATE, NUMBER, FREEFORM, Y/N, PICKLIST picklist_id number ANSWERS answer_id number person_id number -- FK to PEOPLE question_id number -- FK to QUESTIONS answer varchar2(4000)
-------------------------------------------------------
Then we have a bunch of people who have answered a load of questions.
What I am looking into is the feasibility of providing a web interface (easy part!) where a user can specify criteria for listing PEOPLE based on their ANSWERS to QUESTIONS
The user would be presented with a form on which would be listed the questions. Against each one, I anticipate fields to allow entry of value to be matched or min and max (for date or number range) etc. or a pick list of values depending on the ANSWER_TYPE column value.
Then based on the values submitted by the users, construct a query dynamically starting:
SELECT NAME
FROM PEOPLE P, QUESTIONS Q, ANSWERS A
All criteria would be ANDed.
Would I have to join into the QUESTIONS and ANSWERS table once per QUESTION selected by the user?
Anyone done something similar, have any wisdom to share on this?
Not sure if I have explained as clearly on here as it is in my head!
-- jeremyReceived on Fri Jul 09 2004 - 06:01:33 CDT