CheckBox in Oracle Forms - oracle

I have a Database block contains 3 columns. in that all are character columns.
I have created a multi record block in a form which contains 2 text item and one check box.
The values in the table are like below
col1 col2 col3
value1 value2 N
Value3 value4 N
Value5 value6 Y
In the form, I want to find only the records with Value 'N' in the col3.
I want to find the values using Enter - Query, Execute Query method, But here in my form, col3 is the checkbox. if ticked -Y, not ticked value will be 'N'.
I know, we cannot search 'N' values using Enter - Query, Execute Query method.
Is there Any other way we can search?

Your problem is that in enter-query standard functionality is that the checkbox contains an empty value (null) and is not unchecked. To search for an unchecked value just go in enter-query mode and click the checkbox to have the "Y" value in your case and click it again to have the "N" value. From now on you can check and uncheck the value.
If you have made a mistake and want it to be empty again use the clear item key to set it back to null.

If you want to allow querying the block based on the checkbox, you need to have the checkbox values stored somewhere, probably in a Y/N column on the table that the block is based on.
Before the block is queried, you'd just need to ensure the checkbox values are posted to the database.
If you can't save them to the table itself, an alternative would be to save them somewhere else, but it has to be something accessible to the query itself - e.g. a global temporary table.

Why not use the check box to enter the needed search criteria form col3? I can't see why that should not be possible and I even tested it quickly. Please try the following
Set properties of your checkbox for col3 as follows
Value when Checked = Y
Value when Unchecked = N
Check Box Mapping of Other Values = Not Allowed
Initial Value = N or Y whatever suites your business need
Database Item = Yes
Column Name = col3
If using this kind of settings you can in Enter Query mode select if you want the query for col3 = N by making sure that the check box is unchecked when executing the query.

Related

Oracle Apex: How to put a dynamic value in filter

is it possible to add a dynamic value on filter.
I'm trying to save a report with a filter using the current user:
A solution to this problem is to include the variable as a column in your query and then filter on that column.
Example:
Your select would be something like
SELECT
your_value1,
CASE WHEN created_by = :APP_USER THEN 1 ELSE 0 END AS is_current_user
FROM
your_table
If you then set a filter on is_current_user you'll only get the rows where created_by = :APP_USER.
Maybe it is possible; though, I don't know how. Whichever option I tried:
:APP_USER
&APP_USER.
v('APP_USER')
created a page item whose source is :APP_USER and base filter on that item
nothing worked. Apex applies single quotes around those expressions and - therefore - treats them as strings, e.g. ':APP_USER'.
However, what you might do in this particular case is to edit the query itself and add WHERE condition:
where blocked_by = :APP_USER
That would certainly work.

Selected items with check box should be printed

I have an entry with child data and here is check button with child items. If I check the items, then selected item should be printed - not all child items of this parent. How to do that?
The simplest option I can think of is to commit changes you've made (i.e. store checkbox values into the table).
Then call the report by passing the "master" row ID. Report's query would then look like this:
select some_columns
from master_table m join detail_table d on d.master_id = m.master_id
where m.master_id = :par_master_id
and d.checkbox = 1
The where condition would make sure that only checked rows are printed.
In order to "reset" it, you could use the "After Report" trigger and
update detail_table set
checkbox = 0
where master_id = :par_master_id
However, this won't work in multi-user environment as many users could work with same data and "overwrite" each other's checkboxes. Better option would be to create additional table and store [user, master_id, detail_id] rows so that everyone uses their own values.
Or, while in form, if there aren't too many child records, use a loop to concatenate IDs of checked rows and pass them to the report which would split that string into rows.

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.

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.

Cascading LOVS - default values

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

Resources