sam andrew
asked on
How to Query a function whose parameter is a value from different table
I had this question after viewing Create Function which returns records from multiple tables..
I see this query from the above question:
select * from table(DepartmentEmployees( '07/09/201 7','07/20/ 2017'));
how to change the above to get the parameters from other table.
TableA ==> This table will only have one record as below, and I need to get those into above query.
=========
start_date|end_date
=================
07/19/2017|07/22/2017
I tried something like below but I'm getting error ORA--00936 Missing Expression.
select (select start_Date from tableA where rownum = 1) as start_date,
(select end_Date from tableA where rownum = 1) as end_date,
*
from table(DepartmentEmployees( start_date - 30, end_date) );
I see this query from the above question:
select * from table(DepartmentEmployees(
how to change the above to get the parameters from other table.
TableA ==> This table will only have one record as below, and I need to get those into above query.
=========
start_date|end_date
=================
07/19/2017|07/22/2017
I tried something like below but I'm getting error ORA--00936 Missing Expression.
select (select start_Date from tableA where rownum = 1) as start_date,
(select end_Date from tableA where rownum = 1) as end_date,
*
from table(DepartmentEmployees(
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Even though you've already accepted this, since I was involved in the creation of your function I wanted to add that I wouldn't do it that way.
I would add logic to the function that would do the lookup from the table. You could easily add logic that if one of the input parameters were null, go look in the table for that value.
Here is the modified test case on how I would do this:
Open in new window