Insert records based on "Row Selector" in Oracle APEX - oracle-apex-5.1

I have created a report and form on top of a table. The form page is "Tabular Form", in which all columns are editable. In the "Form" page, i have a Lookup button. On clicking this button it will navigate to new page which has a report on top of view with "Row selector".
When user can select list of rows and clicks submit, then the selected rows should get insert in to Tabular Form page.
Can you please explain how I can achieve this.

As noone replied to your question (yet), let me say a few words, based on my current knowledge & experience. Note that someone might have another, better idea and opinion.
A tabular form is created on a table, its source is a SELECT statement. Saying that you want to check row selector checkboxes on some report page and those values will then be transferred into a tabular form on another page is make-a-wish statement. I'd say that those values should be INSERTED into a table (on which that tabular form is created upon), and tabular form should then perform re-query in order to fetch those rows.
As of "checking row selector checkboxes" in a report and doing "something" with those rows: boy, I don't know how to do that. Yes, I have manipulated with rows selected by my own checkbox items in a tabular form (note the difference: not in a report, but in a tabular form) and it was much more a pain than a joy.
I'd suggest you to read the following Patrick Wolf's article: Which Tabular Form Column is mapped to which Apex_Application.g_fxx array?. Why? Because it explains what to do with g_fxx array. It is a mean to manipulate values in a tabular form. Just to show an example I used in one of 4.x Apex versions (no, I don't have any more recent code) so that you'd get the idea of how it is supposed to be done; this is a page process which fires on Submit.
"01 - ID" represents "apex_application.g_f01"
"02 - CB_NEDOSTATAK" represents "apex_application.g_f02"
and so forth; those are items in a tabular form
/* 01 - ID
02 - CB_NEDOSTATAK
03 - CB_HITNOST
04 - CB_OTKLONJEN
05 - NAPOMENA
*/
begin
for i in 1 .. apex_application.g_f01.count loop
update dg_pregled set
cb_nedostatak = case when apex_application.g_f02(i) = 1 or
apex_application.g_f03(i) = 1 then 1
else 0
end,
cb_hitnost = decode(apex_application.g_f03(i), 1, 1, 0),
cb_otklonjen = case when apex_application.g_f02(i) = 1 and
apex_application.g_f04(i) = 1 then 1
else 0
end,
napomena = apex_application.g_f05(i)
where id = apex_application.g_f01(i);
end loop;
end;
Basically, you'd do something like that; instead of UPDATE, you'd do INSERT.
As I said: this doesn't have to be an optimal solution to your problem, but that's what I can say about it. Good luck!

Related

In oracle apex how to navigate to different pages from link column depending on another column data

I have a table with multiple columns in that one column have data like text field in that data is either A or B and another column is of link type link is getting fetched by id column, Now I have a situation by comparing the data in column1 if it's 'A' I want to navigate to page 3 and If it's 'B' I want to navigate to page 4 by click of link column. How to achieve this?
It would probably be easier for us if you actually shared table and its contents instead of describing it; moreover, as you wrote it as a single sentence with no punctuation, it is difficult to understand what you want to say.
The way I understood it, table is used as a source for some kind of a report (interactive or classic?). One of its (reports) columns is used as a link to another page. As link depends on column's value, I suggest you use a case expression and compose link to target page.
I don't know how you are creating the link now, but - if you already don't use it - have a look at GET_URL function which does most of the dirty job for you. In its simplest appearance, you'd just
select id,
apex_page_get_url(p_page => case when column1 = 'A' then 1
when column2 = 'B' then 2
end) as link
from ...
You need to create Dynamic action on Button.
Button -> True -> Action := Execute server-side-code
Settings -> language := PLSQL
FOR PLSQL QUERY
3)Items to Submit = P7_NEW,P7_NEW_1
4) Items to Return = P31_URL
This will create URL and Trigger the URL to next page

Oracle Apex Interactive Grid - Incorrect Records Saving Using Read Only

I have an interactive grid with 7 columns. Pertinent to this question are the columns: Fund_Title and Need_Ind. Fund_Title is type Display Only. Need_Ind is type Select List. Need_Ind also has a property setting on Read Only of Type = Value, Item = Fund_Title, Value = Reporting Only, Execute = For Each Row. The page displays appropriately. I am able to utilize the select list in Need_Ind on all rows that do not have a value of Reporting Only as the Fund_Title. Only those rows where column Fund_Title = Reporting Only have the cell Need_Ind disabled. It is actually grayed out. The problem is with the save. Any rows I have modified are being correctly saved. However, any rows with the value Reporting Only in Fund_Title are also being saved, which are the exact rows I do not want to be editable. Thanks for your help.

i've created a interactive report in oracle apex and i want to connect different links to different rows of the same column

this is my oracle apex report page i'm having a problem in. It has a interactive report which has 2 columns but both the rows of the same column refer to the same page in the application or for the matter to same url. i want to give different link to different rows of the same column.
You'll have to create links manually for each row. For example (taken from one of my IRs):
SELECT
'f?p=&APP_ID.:' || case when r.id_obr = 6 then 217
when r.id_obr = 7 then 221
end ||
':&APP_SESSION.::NO::' || case when r.id_obr = 6 then 'P217_ID_OBR6'
when r.id_obr = 7 then 'P221_ID_OBR7'
end ||
':' || r.id_obr67
as link, ...
Created in such a way, it'll take you wherever you want, passing any values you want to any page you want.
We dont know what version of apex you are on, but I will just give you the answer that works for me.
Create the links on each column and then create hidden page items on the page you are linking to, then using the links, have them set a value to those page items based on what was clicked.
Then you can just use those page items in your SQL query on the page you are linking to.
Or you could even use those items to create filters, but those a pain in the ass to set up, so I would suggest adding the items to your query for simplicity.

Can I use a list to repeat two tablixes on a report page?

See image below. Warehouse and Customer are dropdown lists populated via query. Year is a text field. The two tables display data from datasets driven by the report parameters. Is there a way to repeat the two tables based on each member of the Customer dropdown? Preferbly with a pagebreak after the 2nd table.
I normally do this using subreports. You could either create a single subreport that contains both tables or individual subreports. The individual approach might help with page breaks etc so that's the way I'd go.
Step 1: Create a report for your first table.
As you don't state what each table does, I'll make some up for the sake of illustration.
The key is to create a subreport that displays just the info you need in a single table. So in your case this might mean we only need to pass in a single parameter, CustomerID. You might need to pass in more such as Warehouse but I don't know...
In my made up scenario, let's assume the report shows customer contacts so we create a subreport (let's call it subCustomerConacts). It has a single parameter pCustomerID and a single dataset dsCustomerContacts. The query might looks something like SELECT * FROM CustomerContacts WHERE CustomerID = #pCustomerID. Add whatever tables/textbox etc you need to display your data.
Test this subreport works by manually typing in a CustomerID
Step 2: Create a report for your second table.
Do exactly the same again, creating a new subreport. Let call this subCustomerOrders. Repeat as above until you end up with another report that can display order details (or whatever you need).
Finally, create you main report.
This is basically what you have described in you question in terms of parameters etc.
Now to add this bit that will call you subreports.
Create a dataset (let's call it dsCustomerLoop) that contains each customer from your parameter something like SELECT DISTINCT CustomerID FROM myCustomers WHERE CustomerID IN (#myCustomerParameter)
Add a table to your report, 1 column wide and stretch it so it's wide enough to accommodate you subreports.
Set the dataset to point to dsCustomerLoop
Right-Click the cell in the detail row and do "Insert Row -> Inside Group - Below". You should not have two detail rows.
Next, right click the top detail row and do "Insert -> Subreport"
Right-Click the newly inserted subreport control and choose "properties".
Choose your first SubReport form the drop-down list
Click parameters on the left,
Click "Add" and select the CusomterID parmeter, set it's value to the CustomerID field.
Repeat this process on the seconds row, choosing your seconds subreport.
You may want to also add a 3rd row to the table, you could insert a rectangle into this with page breaks set to force a new page after each seconds subreport.
That's It. When the report runs it will produce two rows per customer, each row containing a subreport.
I hope this is clear enough, I've rushed through it a bit but if anything is unclear, let me know and I'll provide a clearer solution.

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