Oracle Apex 5.0: Wait to generate IR until criteria fields entered - oracle

I have an APEX 5.0.3.00.03 page with dozens of criteria fields, followed by a region containing an Interactive Report (IR). I want to defer the IR being produced until a "Generate" button is clicked, but I am having troubles. The report without criteria would generate millions of rows, via a nasty 5 table join, so I want to defer it processing until the user is ready. I know that I can do a /*+ FIRST_ROWS */ hint, but still want to avoid invoking the SQL until the user picks some criteria.
I tried the following:
Created a Hidden Field P210_WAIT, initial value of 'TRUE', which I included in the SQL criteria like this:
select * from tab_1, tab_2, tab_3, tab_4, tab_5
where :P210_WAIT != 'TRUE'
and -- join, and dozens of other criteria here
and in a dynamic action on the Generate button, I do two things:
Execupte PL/SQL Code to set :P210_WAIT := 'FALSE';
Refresh Action:
Action: Refresh
Affected elements: Selection Type: Region. Region: (region containing my IR)
I have debug statements in the PL/SQL code, and they are appearing, but the SQL to produce the report is not being run, implying that the Refresh Action is not "waking up" the IR.
It does appear the IR SQL is being executed on page load, as I was dynamically setting the IR Attribute "When No Data Found" value to initially say "Please select criteria and click the Generate button to display report" and that was working.

If I understand your problem correctly, your main problem here would be: the dyanamic action to refresh the region is not working, am i correct?
If that is the problem, try this:
First, make sure that all the bind variables in the source query is listed on the Page Items to Submit under the source query region.
Then, Assign Static ID for the IR region.
Next will be, changing the Refresh dynamic action to Execute Javascript and paste this
$('#static_id').trigger('apexrefresh');
Hope this helps.

Related

Clear Page Item in Oracle Apex

I am calling an IR with a link using a hidden page item to filter the IR records. The IR has a search region as well. Now when I click the link, the IR report opens with desired records.
Now as IR is already open and when I try to use the search region LOV to see other records it always shows me records with the previous page item hidden column even though I am changing the LOV.
how can I fix it?
IR query is as below:
(SELECT email_address, status, description FROM recipients
WHERE recipient_group_id = NVL ( :P6_$RECIPIENT_GROUP_ID, recipient_group_id )
AND recipient_id = NVL ( :p8_recipient_id, recipient_id ))
The :P6_$RECIPIENT_GROUP_ID is coming from the previous page from where I am calling the IR using the link column.
The p8_recipient_id is the value coming from the search region of IR.
That is expected behaviour. The page item value for :P6_$RECIPIENT_GROUP_ID will be set until it is reset, either by setting the value to NULL or clearing the cache on page 6 (I'm assuming that is where this page item is defined).
If you want to clear the value of P6_$RECIPIENT_GROUP_ID then define a dynamic action on change of P8_RECIPIENT_ID to set P6_$RECIPIENT_GROUP_ID to NULL. Make sure the interactive report has attribute "items to submit" including both P6_$RECIPIENT_GROUP_ID and P8_RECIPIENT_ID.
Note: referencing a page item from another page is not a good practice. It may lead to unexpected results. A cleaner solution would be to define a P6_$RECIPIENT_GROUP_ID on page 8 and set that from the link to the IR.

Oracle Apex Application manual tabular form

I have an interactive report, where the query is combined, so I can't use editable interactive grid. That's why I have to use manual form in my query.
I've found some nice tips about the APEX_ITEMs, but I have problem with my process.
In my query there are columns like:
APEX_ITEM.HIDDEN(1,coursestudent.id)
...
APEX_ITEM.SELECT_LIST(2,coursestudent.signed,'Signed;1,Failed;0')
I have a submit button, and here is my process:
FOR i in 1..apex_application.g_f01.count LOOP
UPDATE coursestudent
SET signed=apex_application.g_f02(i)
WHERE id=apex_application.g_f01(i);
END LOOP;
I've thought that it's not too difficult, but after I press Submit nothing happens, except that the Success message is written out the page.
What should I do?
I'm using the Oracle Apex version: 5.1.1.00.08
Thanks to Jeffrey, I found the error: it is a bug.
I had to copy-paste the sql query again, and it works now. Ok, really, in that case I always put a select 1 from dual in it's place, save, and just after that paste back the query.
I've faced this bug before that, sometimes the new columns just don't showing in the page. Since I put the hidden column after I first create the query, it hadn't shown in the page, so the loop in the process never worked.

Clearing one block before entering query mode in another

Before I ask my question, I have to say that the database that I'm working on doesn't have foreign keys, so I can't make master-detail blocks, and because of that I'm using workaround with go_block, clear_block, execute_query and triggers.
I have a form with two blocks. If we presume that the both blocks are filled with info, and that I want to execute query on first one, is there a way to clear the other block before entering query mode?
e.g.
Block1: ID, NAME, SURNAME
Block2: INFO1, INFO2, ..., Id_block1 etc.
So, if there is info on both blocks, and I enter the query mode on Block1, whole block clears so I can enter search criteria, but the second block still has the data from the last executed query. Is there a way to clear the data on the second block as well? Once again, I want to clear the data from Block2 when I'm IN ENTER-QUERY MODE on Block1.
Workflow: Enter-query mode Block1, execute-query Block1, NEW-RECORD-INSTANCE trigger activates (where workflow continues), go_block('Block2'), execute_query on Block2 (with where clause Id_block1 = block1.id).
I'm using Oracle Forms 10g. I appreciate any help you can provide.
It is possible to create the MASTER-DETAIL relationship while creating one of the blocks in your form
or
you can just write the following on the KEY-ENTQRY trigger :
go_block('block2');
clear_block;
go_block('block1');
enter_query;
After this, the block1 will be in the enter-query mode and you can search the data and just execute the block.

Oracle form builder trigger

I want add to my block text item where I display count of my all record:
code is:
BEGIN
GO_ITEM('KIEKKAT');
SELECT COUNT(*)
INTO :KATEGORIJA.KIEKKAT
FROM KATEGORIJA;
END;
This wordk only if I choose trigger "WHEN-MOUSE-CLICK" ,but then all other items not display data. If I choose other trigger all items not displaying anything. i want tat this text item will all time display count of record. Please say me, how to do it, whicj trigger set I do my code if correct ?
I would consider a Summary item for this purpose - especially if you already have a block based on the KATEGORIJA table.
You add an item which is based on a COUNT from that block: set Calculation Mode to Summary, Summary Function to Count, and set Summarized Block to the block. Set the Query All Records property on the block to True.
Try it on the POST-SELECT trigger at the block level.
From the documentation:
Description
The Post-Select trigger fires after the default selection phase of query processing, or after the successful execution of the On-Select trigger. It fires before any records are actually retrieved through fetch processing.
Usage Note:
Use the Post-Select trigger to perform an action based on the outcome of the Select phase of query processing such as an action based on the number of records that match the query criteria.
Edit.
take a look at this
https://forums.oracle.com/forums/thread.jspa?threadID=883340
You can get the number from a block property.

Passing more than 3 items in a reports column link

I have a report that is listing students and I want a column to edit a student. I've done so by following this answer:
How do you add an edit button to each row in a report in Oracle APEX?
However, I can only seem to pass 3 items and there's no option to add more. I took a screenshot to explain more:
I need to pass 8 values, how can I do that?
Thanks!
Normally, for this you would only pass the Primary Key columns (here looks like #RECORD_NUMBER# only). The page that you send the person to would then load the form based on the primary key lookup only. If multiple users were using this application, you would want the edit form to always retrieve the current values of the database, not what happened to be on the screen when a particular person ran a certain report.
Change the Target type to URL.
Apex will format what to already have into a URL text field which magically appears between Tem3 and Page Checksum.
All you need to do is to add your new items and values in the appropriate places in the URL.
I found a workaround, at least it was useful to my scenario.
I have an IR page, query returns 4 columns, lets say: ID, DESCRIPTION, SOME_NUMBER,SOME_NUMBER2.
ID NUMBER(9), DESCRIPTION VARCHAR2(30), SOME_NUMBER NUMBER(1), SOME_NUMBER2 NUMBER(3).
What I did was, to setup items this way:
P11_ITEM1-->#ID#
P11_ITEM2-->#DESCRIPTION#
P11_ITEM3-->#SOME_NUMBER##SOME_NUMBER2#
Previous data have been sent to page 11.
In page 11, all items are display only items.
And P11_ITEM3 actually received two concatenated values.
For example, the calling page has columns SOME_NUMER=4 and SOME_NUMBER2=150
so, in pag1 11, P11_ITEM3 shows 4150
In page 11 I created a Before Footer process (pl/sql expression)
to set up new items, for example P11_N1 as source SUBSTR(P11_ITEM3,1,1)
and item P11_N2 as source SUBSTR(P11_ITEM3,2,3)
So, I had those items with corresponding values from the calling IR page.
The reason I did not pass the primary key only for new lookup access, is because i do not want to stress database performing new queries since all data are already loaded into page items. I've been an oracle DBA for twenty years and I know there is no need to re execute queries if you already have the information somewhere else.
These workarounds are not very useful for a product that bills itself as a RAD tool.
Just include a single quoted word in the select statement (Select col1, 'Randomword', col2 from table 1;)
Then define that column as a link and bingo! More items than 3 to select.

Resources