I need help with myPS Query. This is how it goes below:
SELECT A.EMPLID, B.STUDENT_ID, C.ADMIT_TERM, D.CHECKLIST_CD,
D.CHECKLIST_STATUS...
FROM TABLE1 A, TABLE2 B, TABLE3C, TABLE4 D...
WHERE……
AND A.EMPLID = :1
AND C.ADMIT_TERM = :2
AND D.CHECKLIST_CD = :3
AND D.CHECKLIST_STATUS = :4
….
Now there are certain conditions wherein prompts 1,2,3 and 4 are not provided that conditions below should happen:
At this point, I don't know how to add a condition if all those prompts are blank. Can you advise what I need to do next? Sub-queries? Expression?
Help please.
This is basically the same as Littlefoot's answer, but I'll try to add some more detail about how to accomplish that solution. This is an example of a query I did which is similar to what you're trying to do, with a little tweak added on the ORDER_NO
field to demonstrate what you're trying to do. I don't know how to make it return certain rows only if all prompts are not provided, but this will let you return certain rows for each specific prompt which isn't provided. For example, if you don't provide a checklist status, then you can return all students that are in incomplete and in progress status.
Note that this is a very old version of PeopleSoft, so your interface is probably different.
First, add your prompts
Now, the trick is to make the WHERE
clause for each optional field work like WHERE (D.CHECKLIST_STATUS = :4 OR (:4 = '' AND D.CHECKLIST_STATUS IN ('I', 'P'))
(or whatever your status codes are). Here's how to do that (again, on my old version). The logic on the ORDER_NO
field is similar to what you'll need.
Make sure to set your AND/OR
operators and your parenthesis appropriately.
Clicking on the Edit button for the '' equal to :2
criteria, this is what it looks like
And the SQL looks like this
Now when you run the query, any of the prompt fields that you leave empty will either not be used to filter the results, or the default values for that field will be used.