How to Select Multiple Records in Oracle Forms?

How to Select Multiple Records in Oracle Forms?

The tutorial is given below to how to select multiple records in Oracle Forms.

In the following example, we will create a tabular data block based on the EMP table, a checkbox, a multiline textbox and a push button. We will give a functionality to the user that after executing the query, the user can select the records using checkbox and after clicking on the button, it will show the selected employee numbers in the multiline textbox.

multi select in oracle forms

Follow These Steps to Perform This Task

1. Create a tabular data block based on any table and open the layout editor.

2. In the layout editor, create a checkbox in the same tabular data block and set the following properties.

  • Value When Checked: Y
  • Value When Unchecked: N
  • Database Item: No
  • Initial Value: N

3. Create a Push Button and on the When-Button-Pressed Trigger, write the following code:

DECLARE
v_string VARCHAR2 (4000);
BEGIN
GO_BLOCK ('emp');
FIRST_RECORD;

LOOP
IF :emp.c_cb = 'Y'
THEN
v_string := v_string || :emp.empno || ', ';
END IF;

IF :SYSTEM.LAST_RECORD = 'TRUE'
THEN
EXIT;
END IF;

NEXT_RECORD;
END LOOP;

FIRST_RECORD;
:emp.selected_items := RTRIM (v_string, ', ');
END;

Your form is ready now and you can test it by running it.

Also, you can download this form via the following link:

Download Multi-Select Demo Form

See also:

This Post Has 4 Comments

  1. adwan

    hi .
    question
    if i have a tlist in oracle forms and i need to select multiple values from the list and
    use selected value to run a query . using set_block_property default where
    can you advice or give an example for this matter ?????

    1. Vinish Kapoor

      You can get list element using the following code:

      Declare
         n number := 1;
         n_total_count number;
         v_values varchar2(1000);
      Begin
         n_total_count := get_list_element_count('yourblock.yourlistitem') + 1;
         while n <= n_total_count loop
            v_values := v_values || get_list_element_value('yourblock.yourlistitem', n) | |',';
            n := n + 1;
         end loop;
      End;
      

      After completing the loop you will have the multiple values separated by comma into the variable v_values.

      You can use then its value in SQL query to filter records.

    2. adwan

      ok , first thank you for advice but my problem is i need to get more one value in two separated lists like in picture one for first_name and one for dept_name and hire date between d1 and d2 

      i need to do search button set_block_property default where 

      can you help me with this situation

    3. Vinish Kapoor

      You can check the following post on setting default_where for custom search filters:

      Oracle Forms default_where example for custom search

      If it does not solve your problem, then please ask your question on orclqa.com in more detail so that other community members can help you better.

Comments are closed.