This topic is locked

How to Use a selected value in another fields SQL dynamically?

10/4/2014 11:51:45 PM
PHPRunner General questions
M
mfriend author

Hi Folks:
I'm trying figure out how to include a field that is entered by a user into a dropdown that uses what was entered in an SQL Where statement if that is possible.
The field is called "DATE_FED"
The sql I was using to filter the data included in the the dropdown box is:
SELECT

CATTLE.GRAZING_RECORDS.PASTURE,

CATTLE.GRAZING_RECORDS.GROUP_DESCRIPTION,

CATTLE.GRAZING_RECORDS.DATE_IN,

CATTLE.GRAZING_RECORDS.DATE_OUT,

FROM

CATTLE.GRAZING_RECORDS

WHERE

CATTLE.GRAZING_RECORDS.DATE_OUT IS NULL OR

CATTLE.GRAZING_RECORDS.DATE_OUT = trunc(sysdate -1) OR

CATTLE.GRAZING_RECORDS.DATE_OUT = trunc(sysdate -2)
There are about 1500 pastures included in the table, only about 50 to 60 actually are active on any particular date.
The DATE_FED date is going to be saved in a table called BALES_FED_PASTURES. I would like the DATE_FED entered by the user to be dynamically used in the combo/dropdown box later in the same form called in a field called "PASTURES."
I would like to have an SQL dropdown that is like this:
SELECT

CATTLE.GRAZING_RECORDS.PASTURE,

CATTLE.GRAZING_RECORDS.GROUP_DESCRIPTION,

CATTLE.GRAZING_RECORDS.DATE_IN,

CATTLE.GRAZING_RECORDS.DATE_OUT,

FROM

CATTLE.GRAZING_RECORDS

WHERE

CATTLE.GRAZING_RECORDS.DATE_OUT IS NULL OR

CATTLE.GRAZING_RECORDS.DATE_OUT = trunc(CATTLE.BALES_FED_PASTURES.DATE_FED)
So the Date_fed must be => Date_In

and Date_Out can be either NULL

Or Date_Out <=Date_FED
[Date_In is the date the cattle were brought into a pasture for feeding. Date_Out is the Date the cattle were moved to a different pasture and if not NULL (meaning they are still in the pasture) it would have a date.

Date_Fed which would be selected prior
This would limit the users to only being able to pick the pastures that were open/available on the day they actually fed the animals. The way it works now (using sysdate) if they wait too many days before entering the data they may not be able to select the pasture.

I have tried some of the ideas in the advanced manual for PHPRunner but haven't got it to work.

Is this possible? I'm using PHPRunner 7.1 (I have put in a requisition for 8.0) and Oracle 11g R2.
Matthew