0
votes

I'm developing a functionality that fills a collection, using two select lists, with a shuttle . I'm not getting the correct way to display the name, and recover its correspondent id, on shuttle's select item at right side, when I change an specific list, after repeated interventions. I developed a procedure to update, insert or delete the selected items on shuttle, and I suppose its works well after several tests on sql commands.

My test case uses three tables : contracts, worksations and employees. I intend to insert the employees of any workstation of a given contract to another contract. That new contract, whose will receive the employees, must have its owns workstations, previously inserted. The general structure of the tables is:

contracts : pk_contract, number_contract, company_name etc...

workstations : pk_workstation, fk_contract, description etc...

employees: pk_employee, fk_workstation, employee_name, employee_sex etc...

I created an app to demonstrate it: https://apex.oracle.com/pls/apex/f?p=43921
USER: test, PASSWORD : TEST

Page 2- Migrate Employees - has three major regions, and 2 another to display information inserted :

  1. Contracts with a select list, that must choice, preferrable the contract 070/2016, witch have workstation inserted, and a display field with static value, representing a contract, with workstations and employees attached.

  2. workstations: with two select list, the gordian knot, I suppose : old workstations, related original contract's wokstations - related to display field, at contract's region; and new workstation, related to new contract selected above.

  3. Employees: with a shuttle that represents, at left side, a bunch of employees, of a given original workstation and button witch do nothing.

  4. Two more regions representing a classical report, only to inform the inserted, updated or deleted employees, from shuttles right size, using a collection. I made two report's regions because don't know make joins with collections and tables. This collection have the employee id, old_workstation id, new_workstation id, and new contract id, for further migration, not yet implemented.

I'm submiting almost all the fields, for recover its values on apex session's state.

Apparently, the collection works well, with a procedure, but when I choose again the original worksation the shuttle don't display, on right size, the previous inserted employee on that workstation. I configured on my list of values to not include extra values, when i change it, it shows the employee's ids, not their names, regards to source type listed here below:

SELECT e.pk_employee
  FROM tb_employee e
 INNER JOIN tb_workstation pt
    ON pt.pk_workstation = e.fk_workstation
 WHERE pt.typo IS NOT NULL
   AND e.fk_workstation = p2_original_workstation
   AND e.pk_employee IN (                       
                         SELECT to_number(c001) AS id_employee
                           FROM apex_collections
                          WHERE collection_name = 'WORKSTATION_EMPLOYEES');

My shutlle's lov has this rationale:

SELECT e.name, e.pk_employee
  FROM tb_employee e
 INNER JOIN tb_workstation pt
    ON pt.pk_workstation = e.fk_workstation
 WHERE pt.typo IS NOT NULL
   AND e.fk_workstation = p2_original_workstation
   AND e.pk_employee NOT IN (                             
                             SELECT to_number(c001) AS id_employee
                               FROM apex_collections
                              WHERE collection_name = 'WORKSTATION_EMPLOYEES');

Could anyone help me on this issue?

Regards!

1

1 Answers

0
votes

I consider this a regular and fine solution. The shuttle permits recover entire registers on left side, changing it to another original workstation. After have removed the last "and" subclause, added at SHUTTLE an source sql query - return colon separated value, like this:

select e.pk_employee from employee e inner join workstations w on w.pk_workstation = e.fk_workstation where w.typo is not null and e.fk_workstation = :P2_ORIGINAL_WORKSTATION and e.pk_employee in ( SELECT TO_NUMBER(c001) as id_employee FROM APEX_collections WHERE collection_name = 'WORKSTATION_EMPLOYEES' and c002 = :P2_NEW_WORKSTATION);

But for purpose of goood usabilty, and my better interpretation that what shuttle obect does, I reinsert the 'and' clause with an 'and' more, reflecting that on lov has all employees of a given original workstation, except by the employees also inserted and that ones became from another new workstations. This particularité avoids the user thinks that a employee previously attached, on new workstation needed to be inserted:

select e.name, e.employee from employees e inner join workstations w on w.pk_workstation = e.workstation where w.typo is not null and e.worktation = :P2_ORIGINAL_WORKSTATION and e.pk_employee not in ( SELECT TO_NUMBER(c001) as id_employee FROM APEX_collections WHERE collection_name = 'WORKSTATION_EMPLOYEES' and c002 != :P2_NEW_WORKSTATION)

I could be consider use without these cited subclauses, using a disable jquery, in case of same original_wrkstion but at a diferent new, at left size, however its will be an improvement, and I need to understand the jqueries features. I consider this an basic and good, yet functional solution.