Home » Developer & Programmer » Forms » Selecting and passing values for a query
Selecting and passing values for a query [message #474443] Mon, 06 September 2010 07:50 Go to next message
ahazin
Messages: 39
Registered: August 2010
Member
hi guys,

I have a form in which the user selects values above from a LOV and then selects a run query button which then uses the values selected in the LOV to refine the query and output the appropriate values.

What i have done in the pre-query trigger is: (the block i am querying is called cars where the block i am selecting values from the LOV is called selection)

:cars.make := :selection.make; (repeated for other fields)

this worked fine untill i introduced a from and to date in my form in which i passed the data through to the query like this:

declare

v_dates_between varchar2(1000);

begin


v_dates_between := 'reg_date between ''' || :selection.from_date || ''' and ''' || :selection.to_date;
Set_Block_Property( 'cars', DEFAULT_WHERE, v_dates_between ) ;


Now i have added the above bit of code the from and to date work fine, but when a car make is selected it still bring back every car make and not just the one selected.

Anyone know what went wrong or how to fix this? is it possibly because i am setting the where clause in the block property? perhaps i need to now incoperate my other selections into this where clause?

are the two blocks exclusive to eachother? and if i put the whole code into the block property I assume i will get problems. E.G. the user leaves a selection criteria blank (if they want to query all car models they wouldnt select one from the list) i assume the query would only return back values which contain no car model which would be 0 records.

Any advice is appreciated.
Re: Selecting and passing values for a query [message #474445 is a reply to message #474443] Mon, 06 September 2010 07:57 Go to previous messageGo to next message
Littlefoot
Messages: 21818
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Perhaps you should put
:cars.make := :selection.make; (repeated for other fields)
into the DEFAULT_WHERE (or ONETIME_WHERE).
Re: Selecting and passing values for a query [message #474446 is a reply to message #474445] Mon, 06 September 2010 08:10 Go to previous messageGo to next message
cookiemonster
Messages: 13938
Registered: September 2008
Location: Rainy Manchester
Senior Member
I don't believe default_where and pre-query are mutually exclusive.
Where exactly are you setting default_where?
Re: Selecting and passing values for a query [message #474447 is a reply to message #474443] Mon, 06 September 2010 08:24 Go to previous messageGo to next message
ahazin
Messages: 39
Registered: August 2010
Member
in my pre-query trigger. my trigger looks like this:

declare

v_dates_between varchar2(1000);

begin


v_dates_between := 'reg_date between ''' || :selection.from_date || ''' and ''' || :selection.to_date;
Set_Block_Property( 'cars', DEFAULT_WHERE, v_dates_between ) ;
:cars.make := :selection.make;
Re: Selecting and passing values for a query [message #474448 is a reply to message #474447] Mon, 06 September 2010 08:41 Go to previous messageGo to next message
cookiemonster
Messages: 13938
Registered: September 2008
Location: Rainy Manchester
Senior Member
Ought to work. If it was the other way around it might not.
Pre-query should work like enter-query mode, whatever values you assign in it should be appended to the where clause.
Try using get_block_property(<block_name>, last_query) to check exactly what forms is sending to the server.
Re: Selecting and passing values for a query [message #474451 is a reply to message #474448] Mon, 06 September 2010 09:37 Go to previous messageGo to next message
ahazin
Messages: 39
Registered: August 2010
Member
Thanks, I done as you suggested and the query appears to be correct but it seems to bring back the same 3 records no matter what is input, (even though they dont match the critera being enterd, so the problem must lie else where). I will try to figure out what it is now.


WHERE standard_date between '06-SEP-10' and '04-OCT-10' and ( UPPER(MAKE) = 'TEST' and (MAKE LIKE 'te%' or MAKE LIKE 'tE%' or MAKE LIKE 'Te%' or MAKE LIKE 'TE%'))

and it alwyas brings back the same 3 models which dont even begin with T.


Thank You
Re: Selecting and passing values for a query [message #474456 is a reply to message #474451] Mon, 06 September 2010 09:45 Go to previous message
cookiemonster
Messages: 13938
Registered: September 2008
Location: Rainy Manchester
Senior Member
Try tracing the session to be absolutely certain of what query is being run.
Previous Topic: RECORD_GROUP
Next Topic: Re Modify run report
Goto Forum:
  


Current Time: Thu Sep 19 18:14:59 CDT 2024