Popup LOV with multiple values on Interactive Grid displays APEX 19.2 - oracle-apex

I'm using Oracle Apex 19.2 and I have an editable interactive grid with a POP LOV.
Multiple Values is checked
Display As is set to Modal Dialog
My List of Values is a SQL Query:
select name as d, id as r from table_x
I have two issues and I don't think I found a good question on SO that solves it:
Although the modal shows the human readable names to select from, once a record is Saved AND there's more than one value selected, the cell is displayed as ID1:ID2:ID3.... instead of NAME1:NAME2:NAME3...
IF the "name" is a string and not a number AND multiple values are selected THEN an "ORA-01722: invalid number" occurs
Note that in both cases, as long as only 1 value is selected there is no issues with saving.
I understand the storing the field with colons however I'm talking about the visible grid for the user. It should not show the user colon separated IDs after save but show the user list of users for example.
For example, here's a list of room numbers (100, 101...) and they correspond to IDs (3, 7 , 4)
I would suspect after I save, the table still shows 100, 101, .. NOT the IDs to the user.
Any thoughts anyone?

Related

How get display value of checkbox in a checkbox group?

I am using APEX 21.1. I have a checkbox group whose list of values is retrieved using a query...
select disease, id from history;
The query returns many checkboxes. I have another textarea item. I need to get the display value for any checkbox whenever it's checked and set item HISTORY to that value. How to do so?
Describing a how-to would be so much easier if you had provided some example page item names and example data. So, lets call your checkbox group P10_CHECKBOX and your textarea P10_TEXT.
Usually, your checkbox group will save the item ids as a colon seperated list, like this: 3:4:5
To display the corresponding display values, make a dynamic action on change on your item P10_CHECKBOX.
Then, use an action of type Execute PL/SQL Code to fetch the display values of your items.
The code could look like this:
select listagg(disease,chr(10)) within group (order by disease) into :P10_TEXT
from history h
join table(apex_string.split_numbers(:P10_CHECKBOX,':')) t on (h.id = t.column_value);
apex_string.split_numbers will convert your colon list into an actual "table" with the column column_value you can use in the join clause. listagg will do the actual concatenation and will work up to a couple thousand characters. chr(10) is an ordinary line break and will have your items be shown line by line, but any other seperator will do.
Last step is to set up P10_CHECKBOX in your Items to submit and P10_TEXT in your Items to return.
Now, whenever you click a checkbox, the textarea will be updated immediately.

How to sort in Oracle Apex 19.1 Interactive Grid

I'm using Oracle Apex 19.1 on a 18.c platform.
I have a page with two regions: 1) Interactive Grid and 2) Interactive Report
I use the Interactive Grid to display a list of Producer names. When the user selects one of the names, the Interactive Report refreshes and displays the events assigned to that Producer. I use a Dynamic Action to update the Interactive Report.
This all works fine, except for the list in the Interactive Grid. It seems to display names in order by the table's PRIM_KEY and I want to sort the Interactive Grid by last name. The Source Code for the IG doesn't accept an Order By clause.
Select ac.first_name || ' ' || ac.last_name PRODUCER
From aff_contact ac, aff_contact_role acr
Where ac.prim_key = acr.contact_fkey
And acr.role = 'Producer'
;
The problem is, the column names in the IG toolbar's Actions / Data / Sort never populate. I wondered if the dual column in the Select statement was the problem, so I tested it with a simpler query for the Source:
Select last_name
From aff_contact
;
That still didn't produce columns to select for the sort. I receive a screen like the one below:
The Column select field has nothing to pull down. That holds true for both the original and the simplified query.
How can I get the IG to sort based on the LAST_NAME field? Is there another way to achieve this goal?
Thanks for looking at this.
After further checking, it seems that a VARCHAR2 column with a width <= 99 is selectable as a Sort or Control Break. A VARCHAR2 column with a width >= 100 is NOT selectable for Sort or Control Break in an interactive grid.
To identify the fields in the report Source I used the syntax:
cast( first_name as varchar2(32)) "FIRST_NAME",
cast( last_name as varchar2(32)) "LAST_NAME"
to avoid the default column width.
To sort by column:
01. Click the Actions menu, select Data, then Sort. The Sort dialog appears.
02. In the Sort dialog: Select a column, the sort direction (Ascending or Descending), and the null sorting behavior (Default, Nulls Always Last, or Nulls Always First).
a. Column - Select a column.
b. Direction - Select Descending or Ascending.
c. Nulls - Select First or Last.
03. To add another sort rule, click the Add button (+).
04. Click Save.
05. Click Report
06. Click Save
The interactive grid reloads.
Note:To ensure column sorting active. To ensure that you are login developer mode, otherwise it is not show other user

How to write a query based on the Date item, in interactive grid

I have a date field and a interactive grid. I am trying to generate the Interactive grid based on the value inputted in the date field.
I am trying to write the query as below :
select pap.effective_start_date , pap.effective_end_date
from per_all_people_f pap
where :SELECT_DATE between pap.effective_start_date and
pap.effective_end_date
Here, SELECT_DATE is the name of the Date field (datatype Date picker). I am writing a dynamic action on Change of Date field, and refreshing the interactive grid region.
But when I change the value in Date field, it doesn't return any rows.
I have done a similar change where my interactive grid was based on a dropdown. There I had to set the "page action on selection" to Submit, and it worked. But here, since it is a Date field, the "Page Action on selection" property doesn't appear on the page .
Can somebody please suggest, how can I achieve this.
You need to explicitly convert your bind variables, which are treated as strings, to dates.
to_date(:SELECT_DATE)
The format mask will come from the application properties, or you can be explicit with that, too.

Oracle-apex dynamic list of values

I want to make a select list in apex in which when i select any number from select list then it displays diffrent column table for example when i select 1 then it display (bags) when select 2 it displays (trousers)...
I hope I understand your question right.
For a select list you need to create a list of values. There you have to fill two columns, the Display Value Column and the Return Value Column.
Like the label says, the Display Column is for displaying (like trousers, bags) and the return value returns another value (like 2, 1) to the database. On the database it won't be saved as trousers or bags, it will be saved as 2 and 1.
Hope this helped you.

Capture values of a shuttle list

I am using APex 4.2
I have a page (page 31) with a shuttle list. The list contains several job categories (a, e, x, c, etc). I have a button on that page that generates a report based on the selected job category. I click my button, a query runs, and it takes me to a report page (page 27). The query is along these lines
select * from 'table'
where (instr(':'||:P31_JOB_CATEGORY||':',':'||JOB_CATEGORY||':') > 0)
where P31_JOB_CATEGORY is represented by a shuttle list. This gives me the desired results on page 27, however, is there a way to capture each selected job category that was selected in the shuttle list on page 31 and pass it to page 27 to be displayed? It would be nice to have it stored in a concatenated string of some sort for easy handling, i.e. A, E, C, X.
Any help would be greatly appreciated. Thanks in advance.
The reason is in how shuttle values are saved to session state and how the apex URL is constructed.
Shuttle values are constructed, as you have seen, by concatenating the selected values with a colon. So for example, I have a shuttle on ENAME from EMP, select 3 values and submit the page. Session state for the shuttle is: URUGUAY:HOWARD:M BENZ.
Now say that you redirect to another page, setting an item with the value of this shuttle item. The URL will look like this: f?p=54687:6:100741653098795::NO::P6_TEXT:URUGUAY:HOWARD:M BENZ
The apex URL is constructed by using colons. You putting values in there which has colons simply doesn't work for apex.
Solution? You could submit the page and use a computation to replace the colons, and then branch away to the destination page.
For example, with my enames I'm replacing the colon with a ~: URUGUAY~HOWARD~M BENZ. On your destination page you can then use this value and adapt your sql or use a computation in before/after header to replace the seperator again.