Home » Developer & Programmer » Forms » validate from list in LOV
validate from list in LOV [message #169467] Thu, 27 April 2006 00:10 Go to next message
juicyapple
Messages: 92
Registered: October 2005
Member
I have two text fields in a form, batch no. and date. User will key in batch no. and select the date through LOV.

The LOV query as below:
select date1 from tbl1 where batch = :frmRec.batch
group by date1

If I set validate from list in LOV to Yes, it will only allow user key in date which is exist in LOV. If no records return from LOV, user is not allow to key in anything in the date field, am I right?

Please give idea/suggestion on how this can be done when no records is returned.

Thanks.

Re: validate from list in LOV [message #169470 is a reply to message #169467] Thu, 27 April 2006 00:38 Go to previous messageGo to next message
RAS_SANKAR
Messages: 42
Registered: March 2006
Location: India
Member
hi apple,

It is an alternative way of doing that u required.

set autodisplay of lov to FALSE
set validate from list to NO

write the following code in trigger when-validate-item
on bathno.
declare
     b boolean;
     c number;
begin
     select count(*) into c from tab1 where batch=:frmRec.batch
     if c>0 then
	b := show_lov('batchlov');
     end if;
end;


Ras.

Re: validate from list in LOV [message #169476 is a reply to message #169467] Thu, 27 April 2006 01:42 Go to previous messageGo to next message
juicyapple
Messages: 92
Registered: October 2005
Member
thanks.
It works better.
Re: validate from list in LOV [message #169483 is a reply to message #169476] Thu, 27 April 2006 02:29 Go to previous messageGo to next message
Maaher
Messages: 7065
Registered: December 2001
Senior Member
Ras: doing a count to see whether ONE record exists? I'd opt to restrict the select or to work with a NO_DATA_FOUND or an OPEN-FETCH-CLOSE like below:

declare
  b boolean;
  c number := 0;
     
  cursor c_test
  is
  select 1 x
  from   tab1 
  where  batch = :frmRec.batch;
begin
  open  c_test;
  fetch c_test into c;
  close c_test;

  if c=1 then
    b := show_lov('batchlov');
  end if;
end;


A little bit more code but you'll find it a lot better performing (certainly when working with large tables) Wink

MHE

PS: u = you?

[Updated on: Thu, 27 April 2006 02:29]

Report message to a moderator

Re: validate from list in LOV [message #169486 is a reply to message #169483] Thu, 27 April 2006 03:13 Go to previous messageGo to next message
RAS_SANKAR
Messages: 42
Registered: March 2006
Location: India
Member
I think we can also write like this

declare
     b boolean;
     c number ;
begin
     select 1 into c from tab1 where batch = :frmRec.batch;
     b := show_lov('batchlov');
exception
     when no_data_found then
     null;
end;

Re: validate from list in LOV [message #169494 is a reply to message #169486] Thu, 27 April 2006 03:59 Go to previous message
Maaher
Messages: 7065
Registered: December 2001
Senior Member
Yes, you are right. That's why I mentioned it in my previous reply Wink. But here we have a coding standard stating that exception handling cannot be used to alter the normal process flow.

MHE

[Updated on: Thu, 27 April 2006 04:00]

Report message to a moderator

Previous Topic: update a column having no value
Next Topic: Urgent Help - Problem in sending Parameters from form to form
Goto Forum:
  


Current Time: Fri Sep 20 07:37:33 CDT 2024