Home » Developer & Programmer » Forms » how to protect selecting same row from the LOV..........
how to protect selecting same row from the LOV.......... [message #132758] Tue, 16 August 2005 01:02 Go to next message
imtiazmasud
Messages: 49
Registered: May 2005
Location: Bangladesh
Member

Hi everyone,
I am facing a problem with my Lov that,Suppose I have a LOV

1. Rice
2. Potato
3. Jute
4. Sugar etc..

Now Suppose I am a shopkeeper.I have to make a bill for my customer.I have a product list LOV(Containing my product list).I have to select some goods from lov into a block and will have to put some corresponding value to each item and then save and make a bill.

Now The problem is that Suppose I have select Rice from lov and put corresponding price. If want to select the item Rice twice or thrice or more times for the same bill then it will send a message that " You Have selected rice one time and you can not select it twice for the same bill"...the core fact is that I just want that I can choose several items but will be able to select one item onetime for a bill from LOV....

So please... I will be very helpful if someone replies..if any problem to understand problem then ask I will try to make it more clear in another way..........





[Updated on: Tue, 16 August 2005 01:15]

Report message to a moderator

Re: how to protect selecting same row from the LOV.......... [message #132765 is a reply to message #132758] Tue, 16 August 2005 01:41 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
Search this forum for 'record_group'. There is a solution where when you 'use' an item you add it to a record_group, then in your When-Validate-Item trigger you 'scan' the record_group to make sure that it is not in it. If it is in the 'used' record_group, give a message, and raise form-trigger-failure.

David
icon7.gif  Re: how to protect selecting same row from the LOV.......... [message #137160 is a reply to message #132765] Tue, 13 September 2005 08:45 Go to previous messageGo to next message
Shahzad_Khan
Messages: 8
Registered: September 2005
Location: Karachi
Junior Member

Hi allz

Dear Imtiaz here is code try it

1. Create data block (EMP) with item (DEPT_ID).
2. Add command button CMD_DEPT near item (DEPT_ID).
3. Create TWO record groups (RGR_DEPT_FULL and RGR_DEPT_PART)
Both groups have the same SQL-statement

select DEPT_ID,DEPT_NAME from dept

4. Populate these record groups in Pre-Form trigger

declare
Num NUMBER:=0;
begin
Num:=populate_group('RGR_DEPT_FULL') ;
Num:=populate_group('RGR_DEPT_PART') ;
end;

5.Create LOV (LOV_DEPT) based on first record group (RGR_DEPT_FULL)
6. Set column Mapping Properties for this LOV.
7. Set LOV's Property "Automatic refersh" to NO
8. Set item's property "List of Values" to 'LOV_DEPT'.
9. Add WHEN-BUTTON-PRESSED trigger for command button (CMD_DEPT)

declare
     rec_count   number;
     lAsk            BOOLEAN :=FALSE;
begin
     -- Change LOV's record group
     set_lov_property('LOV_DEPT',GROUP_NAME,'RGR_DEPT_PART');
     -- Call LOV
     lAsk:=show_lov('LOV_DEPT');
     -- Come back LOV's record group
     set_lov_property('LOV_DEPT',GROUP_NAME,'RGR_DEPT_FULL');
     -- if value selected then removed it from second record group
    if lAsk then
       rec_count:=get_group_row_count('RGR_DEPT_PART');     
       for j in 1..rec_count loop
        if get_group_char_cell('RGR_DEPT_PART.DEPT_ID',j) = :EMP.DEPT_ID then 
               delete_group_row('RGR_DEPT_PART',j);
               exit;
            end if;
        end loop;
     end if;
end;

Thsi solution has one problem.

When your call LOV directly from item (DEPT_ID) by pressing F9 function key you will see full list of department. But when you press command button (CMD_DEPT) you will see only not selected list.


Good Luck. Razz

Khurram Siddiqui

[Updated on: Tue, 13 September 2005 18:57] by Moderator

Report message to a moderator

Re: how to protect selecting same row from the LOV.......... [message #137161 is a reply to message #132765] Tue, 13 September 2005 08:47 Go to previous message
Shahzad_Khan
Messages: 8
Registered: September 2005
Location: Karachi
Junior Member

Hi Allz

Dear Imtiaz here is code try it

1. Create data block (EMP) with item (DEPT_ID).
2. Add command button CMD_DEPT near item (DEPT_ID).
3. Create TWO record groups (RGR_DEPT_FULL and RGR_DEPT_PART)
Both groups have the same SQL-statement

select DEPT_ID,DEPT_NAME from dept

4. Populate these record groups in Pre-Form trigger

declare 
   Num NUMBER:=0;
begin 
   Num:=populate_group('RGR_DEPT_FULL') ;
   Num:=populate_group('RGR_DEPT_PART') ;
end;

5. Create LOV (LOV_DEPT) based on first record group (RGR_DEPT_FULL)
6. Set column Mapping Properties for this LOV.
7. Set LOV's Property "Automatic refersh" to NO
8. Set item's property "List of Values" to 'LOV_DEPT'.
9. Add WHEN-BUTTON-PRESSED trigger for command button (CMD_DEPT)

declare
     rec_count   number;
     lAsk            BOOLEAN :=FALSE;
begin
     -- Change LOV's record group
     set_lov_property('LOV_DEPT',GROUP_NAME,'RGR_DEPT_PART');
     -- Call LOV
     lAsk:=show_lov('LOV_DEPT');
     -- Come back LOV's record group
     set_lov_property('LOV_DEPT',GROUP_NAME,'RGR_DEPT_FULL');
     -- if value selected then removed it from second record group
     if lAsk then
        rec_count:=get_group_row_count('RGR_DEPT_PART');     
        for j in 1..rec_count loop
            if get_group_char_cell('RGR_DEPT_PART.DEPT_ID',j) = :EMP.DEPT_ID then 
               delete_group_row('RGR_DEPT_PART',j);
               exit;
            end if;
        end loop;
     end if;
end;

Thsi solution has one problem.
When your call LOV directly from item (DEPT_ID) by pressing F9 function key you will see full list of department. But when you press command button (CMD_DEPT) you will see only not selected list.


Good Luck. Razz

Khurram Siddiqui

khurrampc@hotmail.com
oraware@yahoo.com

[Updated on: Tue, 13 September 2005 18:59] by Moderator

Report message to a moderator

Previous Topic: ora-00439 while inserting blob image in a table.
Next Topic: on-error trigger does not trap ORA-28002
Goto Forum:
  


Current Time: Fri Sep 20 00:42:54 CDT 2024