Apex 5.0 : Action on buttons ? Get value from textfield? - oracle

The first problem is that I have a button. I created a process called nextweek( to get data for next week from reservation table). I tried this The PL/SQL only as a trial:
begin
if :RESERVNO is null then
select RESERVNO
into :RESERVNO
from reservation;
end if;
end;
but the page keeps telling me "NO DATA FOUND". I would like to create a report with the result of my PL/SQL Query
My second problem is that I want to take values from a textfield and use it in my PL/SQL Query in another button as the "ACCEPT" in oracle.

As I understand, you need following:
Create report: click Create new page button (or create region if you already have a page), then choose region type Report. Write your source SQL query in the field Region source (choose Source type - SQL Query).
Create an item (textfield). For example, with the name P_MY_ITEM
Create a button. Here you don't need to change default properties. (Action on button click should be Submit page)
Add this item name to the source query in the region. It should look like:
select column1, column2, column3
from table1, table2, table3
where column4 = :P_MY_ITEM
and <other conditions>
After that, user can write something to the input field and press the button, page will be reloaded, and report will be changed accordingly to the item value.

Related

how to pass selected drop-down list value to a variable or data block to execute a query

I have a form and I a dropdown pop-list with year values in it(year field is not a primary key).
I have to fill all other field values when i select a year from dropdown(need to execute query of data block).
how can i achieve this.
If that dropdown list is part of the data block (it doesn't matter whether it is or is not a primary key), then
navigate to that block
enter query mode
select year
execute query
If dropdown belongs to another (control?) block, then
in Forms Builder, open data block year field's property palette and set "Copy value from item" property to CTRL_BLOCK.YEAR
alternatively, create a data block-level pre-query trigger:
:data_block_name.year := :control_block.year;
create a button (in control block)
create a when-button-pressed trigger which will
go_block('data_block_name');
execute query;
run the form
select year
push the button

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.

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