Cascading LOVS - default values - oracle

I have two cascading LOVs. After changing value of my first LOV in second LOV appropriate values are populated.
First LOV:
name - P2_DEPTNO
select dname, deptno
from dept
order by 1;
Second LOV:
name - P2_EMPNO
select ename, empno
from emp
where deptno = :P2_DEPTNO;
cascading LOV parent - P2_DEPTNO
What should I add to set default value of second LOV (first row from query) after changing first LOV value?

Make sure you have Display Null Value set to No and it should use the first value in the list. (Although I am not sure what it will do with Popup LOV).

Finally, I got the correct answer on the Oracle community forum.
This is possible in only one case, because I'm more familiar with this type of issue in my project.
We need to change the second item type i,e "Empno" item type from Pop-up LOV to Select-List.
Also make null setting changes as per given below :
On DEMO works proper.
Please note that this will CAN NOT be achieved with item type as POP-UP LOV directly using simple step. To make this work using you need to work on POP-UP LOV we need so much custom changes, like DYnamic Actions , JS Code, Asynchronous calls to DB.
Source - https://community.oracle.com/thread/4048009
Author - EnigmaCoder

Related

Make Specific rows not editable using Interactive Report

I am using Apex 18.2. I created an interactive report which has 10 records. I try to add a logic that user can only be able to edit those records which recently created. User cannot do an edit to an old records. Means when user try to edit old records, it show as 'Display only' or not editable. Is there any way I can do that? Your help is really appreciated. Thanks
One option is to create your own link (icon, if you wish), just like another column in report's query.
As you're in SQL now, use any condition you want. Obviously, you have to be able to distinguish "old" from "new" rows. If we suppose that it is some DATE datatype column, so whatever is "yesterday" or older is considered to be "old", you'd
select case when datum < trunc(sysdate) then null
else 'Click here'
end as link,
empno,
ename
from emp
LINK column's type would be "link" (of course) and you'd make it navigate to another page in this application, pass values from here to there, etc.

Classic report dynamic heading in APEX 5.1

I have a classic report driven by a SQL query.
How can I dynamically set column headings, based on the value of another column?
For example, my SQL returns columns A, B, VERSION. I'd like the classic report column heading for SQL column A to be 'Foo' if VERSION is 1, but 'Bar' if VERSION is 2.
I don't know what you meant by saying that the query is constrained by primary key.
Anyway, here's a suggestion which might (or might not) help.
Based on sample SCOTT schema, I created a simple classic report as
select e.ename, e.job
from emp e
where e.deptno = :P42_DEPTNO
I also created a P42_DEPTNO item which - kind of - constrains the result to just one department. For example, if you enter 10 into P42_DEPTNO, you'll get employees that work in the ACCOUNTING department.
Furthermore, I created a hidden item P42_DNAME whose souce is a SQL query
select dname
from dept
where deptno = :P42_DEPTNO
and it returns department name for the P42_DEPTNO value. Its "Used" property is set to "Always, replacing any existing value in session state". This item (P42_DNAME) will be used as a custom heading for the ENAME column returned by the report.
In order to do that, open ENAME column's properties and put this into the "Name" property: &P42_DNAME. (literally ampersand + item name + dot - don't forget the trailing dot!).
That's all;
run the report
enter 10 into P42_DEPTNO item
press ENTER key
report will display employees that work in department 10, and ENAME column's heading will be ACCOUNTING

Pre Populate Text Fields in Apex

I'm trying to fill out various text fields on an apex application when I select a Reference Number in a select list.
When the page loads I'd like the text fields to be filled with the information from the database related to the reference number from the select list, however, I don't know how to do so. Any suggestions or help would be most appreciated!
As far as I understood the question:
user opens a page
there's a Select List item
user picks a value
you want to populate certain items on that page, based on a value user previously selected
If that's so, you'd use a dynamic action - create it on the Select List item, pick set value type.
[EDIT: How to do that?]
Scott's schema, DEPT table. Suppose that the select list item is P15_DEPTNO, while two other items are P15_LOC and P15_DNAME.
create a dynamic action on P15_DEPTNO
event: change
item: P15_DEPTNO
create its True action:
action: set value
type: SQL statement
select loc, dname
from dept
where deptno = :P15_DEPTNO
items to submit: P15_DEPTNO
affected elements: items P15_LOC, P15_DNAME
That's all.

Oracle Apex 18 shuttle item show last selected values on right side

I have implemented Shuttle List Successfully Using Dynamic Action with Below Code
declare
tab apex_application_global.vc_arr2;
begin
tab := apex_util.string_to_table (:P14_NEW_1);
for i in 1..tab.count loop
insert into xxtest (COL1, COL2)
values (:P14_NEW, tab(i));
end loop;
commit;
end;
Problem is that each the time user open the forms it don't show the last selected values to Right Hand Side, I didn't understand this logic how can i show selected items as saved In table to Right side when page loads
You did the first part of job - stored selected values into a table.
The next step is to retrieve them back. In order to do that,
navigate to shuttle item's source property
set its type to "SQL Query (return colon separated values)
SQL query should look like this:
select listagg(col2, ':') within group (order by null)
from xxtest
where ... --> include condition, if there is any - I believe it should
set "Used" property to "Always, replacing any existing value in session state
Run the page; shuttle item should now have populated right hand side.
As of the where clause: I don't know what is the purpose of doing what you're doing, but - if you don't distinguish rows stored into the xxtest table, all users will use the same recordset and overwrite each other's data. If xxtest.col1 represents username (so that wouldn't be :P14_NEW but :APP_USER instead), you should use it in WHERE clause. Otherwise, consider doing that.

How to write the query for interactive grid based on the select list in Oracle Apex

I have a drop down select list (P2_ROLE). I want to generate the interactive grid based on the value that I select from the drop down.
I am trying to do that but the query is not returning any result in the grid. However, if I query it in the database, it returns me the result.
It looks like that it is not substituting the value from the dropdown into the IG query. But If I hard code the value, it gives me the results.
dropdown_IG issue
I also tried returning the value selected from the dropdown in the item : P2_SELECT_LIST_VALUE and then using it in the query. But it also doesn't work.
The query that I have used for my Interactive grid is :
Select USER_NAME
From WF_USER_ROLES
Where ROLE_NAME = :P2_SELECT_LIST_VALUE ; --using the value from new item
or
Select USER_NAME
From WF_USER_ROLES
Where ROLE_NAME = :P2_ROLE; -- using the value directly from Dropdown
After selecting the value in the dropdown, I am refreshing the IG region using dynamic action on change select list. But that also doesn't help. How can I do that ?
Select list returns two values: display and return. Its form is, for example,
select dname disp_val,
deptno ret_val
from dept;
Its return value is then used in interactive grid's query.
Also, in order to be able to use select list's value, it has to be stored in session state; if it is not, query won't work. The simplest option is to submit the page, and you can do that by setting that item's Page action on selection property to "Submit page". Doing so, your IG query:
Select USER_NAME
From WF_USER_ROLES
Where ROLE_NAME = :P2_ROLE
should work OK. If it still does not, create an example on apex.oracle.com, provide credentials so that we could have a look at what you did.

Resources