I have the following select statement that I am using as a standard report:
select id,
name,
telephone,
apex_item.checkbox2(10,id) as "Tick when Contacted",
apex_item.text(20,:P2_DATE) as "Date Contacted",
apex_item.textarea(30,:P2_COMMENT,5,80) as "Comment"
from my_table
My question is and the area that I am not sure if I am doing this correctly is that if this statement returns 10 rows and out of those 10 rows, I only select/check 5 records and then press the submit button, why is it that my PL/SQL page process that inserts the selected records into another table is not picking up :P2_DATE and :P2_COMMENT which are hidden items on the page and purely just used as placeholders and not actual columns within my_table?
Am I doing this correctly or do I need to use an apex collection?
Here is what my page process looks like; is this correct?
DECLARE
v_row BINARY_INTEGER;
BEGIN
FOR i IN 1..APEX_APPLICATION.G_F10.COUNT LOOP
v_row := APEX_APPLICATION.G_F10(i);
INSERT INTO MY_OTHER_TABLE
( DATE_CONTACTED,
COMMENTS
)
VALUES ( APEX_APPLICATION.G_F20(v_row),
APEX_APPLICATION.G_F30(v_row)
);
END LOOP;
COMMIT;
END;
Example of report with user input is as follows:
ID/CHECKBOX DATE CONTACTED COMMENTS
=====================================================
1 21/08/2012 Comment 1
2 21/08/2012 Comment 2
3 21/08/2012 Comment 3
4 21/08/2012 Comment 4
5 21/08/2012 Comment 5
Based on this report where user has manually entered these 5 comments, I expect these 5 records get inserted into MY_OTHER_TABLE, as they have been checked.
Unfortunately MY_OTHER_TABLE never gets populated for the 5 records that I have checked.
I am unsure what I have missed out on something, or if I have completely got my original select wrong with regards to using these two placeholder items?
In your comment you say
can I user apex_item.text api where the source is not coming from an underlying oracle table?
Now i read that as:
can i generate this report and have the default value for my apex_item fields set to that of my 2 page items.
Yes. You can. That is what i thought you meant originallyn and it makes sense since the items are hidden anyway. Just make sure of the below:
if you meant that the value is not put in the report items at page load:
if the region with the hidden items is BELOW the region with your report, move your region with the items or create a new region ABOVE the region with your report.
With above and below i'm talking about their position in the form structure. Switch over to tree view if you use component view to easily see this.
My guess is that the item (and its source) is processed before, and thus has a valid session state before the rendering of the report starts.
Related
I have the following SQL query which I am loading in to a DataSet:
SELECT i1.* , i2.* From tblMMLettersImportTable i1 Join tblMMLettersImportTable i2 on i1.SectionID + 1 = i2.SectionID Where i2.startpage - i1.endpage <> 1
Idea is to check that the index for various sections of a document lead one page on to the other with no gaps. I.e section 2 ends on page 5 and section 3 starts on page 6.
I'm happy that the SQL works, however by joining on itself the field "SectionID" is duplicated. In SQL easy enough, just use i1. or i2. to reference the correct one.
The issue comes when I load this in to a VB.net Dataset. I need to raise an error message with something like:
MessageBox.Show("There is a page gap between sections " & row.item("i1.sectionID") & " and " & row.item("i2.sectionID")
I get the error message Column 'i1.intline' does not belong to table Table. Makes sense as that is not its name in the dataset. I've considered using the column number to reference the item to pull out, however the SQL Table tblMMLettersImportTable is deleted, created and populated dynamically depending on the type of Letter/document being produced so I cannot always guarantee that the columns will always numbered the same. This is also why i1.* and i2.* is used instead of listing each column.
Is there a way that I can reference 2 items in a DataSet that have the same item name with VB.Net?
Basically I am using MS Access 2013 to import all active work items that are assigned to a specific group from an API and select the data into 2 new tables (Requests & Request_Tasks).
I then have a form sourced from a query to select specific fields from the 2 tables.
Until yesterday it was working with no problems and nothing has changed.
All of the data appears in the 2 tables so the import from the API works fine.
When it comes to the query selecting the data from the 2 tables (Which are already populated with the correct data) the query returns only data from Requests table with blank fields instead of data from Request_Tasks.
The strange part is that out of 28 active work items it returns 24 correctly and the last 4 are having the problem.
Every new task added to the group has the problem also.
Query is below.
SELECT
Request_Tasks.RQTASK_Number,
Request_Tasks.Request_Number,
Requests.Task, Requests.Entity,
Request_Tasks.Description,
Request_Tasks.Request_Status,
Requests.Requested_for_date,
Request_Tasks.Work_On_Date,
Request_Tasks.Estimated_Time,
Request_Tasks.Actual_Time_Analysis,
Request_Tasks.Offers_Built,
Request_Tasks.Number_of_links_Opened,
Request_Tasks.Number_of_Links_Extended,
Request_Tasks.Number_Of_links_closed,
Request_Tasks.Build_Allocated_to,
Request_Tasks.Buld_Review_Allocated_to,
Request_Tasks.Keying_Allocated_to,
Request_Tasks.Keying_Approval_allocated_to,
Request_Tasks.Actual_Build_Time,
Request_Tasks.Actual_Stakeholder_Support,
Request_Tasks.Task_Completed_Date
FROM Request_Tasks
RIGHT JOIN Requests
ON Request_Tasks.Request_Number = Requests.Request_Number
WHERE (((Request_Tasks.Task_Completed_Date)>=Date()
Or (Request_Tasks.Task_Completed_Date) Is Null)
AND ((Requests.Task)<>"7"
And (Requests.Task)<>"8" And (Requests.Task)<>"9"))
OR (((Request_Tasks.Task_Completed_Date)>=Date()
Or (Request_Tasks.Task_Completed_Date) Is Null)
AND ((Requests.Task)<>"7"
And (Requests.Task)<>"8"
And (Requests.Task)<>"9"))
ORDER BY Request_Tasks.Work_On_Date Is Null DESC , Request_Tasks.Work_On_Date, Requests.Entity Is Null DESC , Requests.Task;
Any help would be great.
Thanks.
The query is using RIGHT JOIN, which means rows from Requests table is always reported even if there is no corresponding entry in Request_tasks table.
A full example is here http://www.w3schools.com/Sql/sql_join_right.asp
In your case, most likely somechange might have happened during data load/API and Request_tasks table is not being populated. That is the reason you see blank data for fields from that table.
Solution
Manually check data for 4 faulty records in Request_tasks table.
Ensure keys in both table request_number are matching including data type and any leading space/non printable characters (if they are string type of data) for faulty records.
Query seems fine, its more of issue with data based on problem statement.
I have a main report which has three sub-reports. I am trying to grey out one of the parameter option when a certain report is selected. The reason I want to do that is because one of the sub report does not use this parameter.
Here's the code I am using now. The parameter displaying the query result is #device.
--When user select report 2, the parameter displays the device list from table2.
IF #selectReport = 2
BEGIN
SELECT DISTINCT type
FROM table2
END
--When user select report 3, the parameter displays the device list from table3.
IF #selectReport = 3
BEGIN
SELECT DISTINCT type
FROM table3
END
--When user select report 1. I want to grey out the parameter, but I could not do it.
--So I created the table contains NULL value.
--So, when the user select the report 1, the parameter will show only null value.
IF #selectReport = 1
BEGIN
SELECT DISTINCT type
FROM nullValueTable1
END
I want it to be grey out when the report 1 is selected instead of show NULL on drop down list. Any idea???
You can't grey out the parameter. Unfortunately you can't hide the parameter either as the hidden property only takes True and False. What you are doing now might be the best you can do. However, you could try looking at cascading parameters, maybe you might be able to provide a slightly more user friendly value like "None" to the dropdown.
I am quite confused with how Oracle apex_application.gfnn works and whether it only works for standard SQL reports in Oracle ApEx or only with SQL (Updateable reports, i.e. tabular forms).
Basically I am trying to achieve the following using this sample SQL, which is just a Standard SQL Report but I'm unsure if what I am trying to achieve is possible with this type or report, i.e.:
select id,
name,
telephone,
apex_item.checkbox2(10,id) as "Tick when Contacted",
apex_item.text(20,my_date) as "Date Contacted",
apex_item.textarea(30,my_comment,5,80) as "Comment"
from my_table
Based on the above SQL, assume this SQL query returns 10 rows. Now using checkbox as my driving id, I tick the checkbox of all odd records/rows, i.e. rows 1,3,5,7,9 and for each of these rows, I also enter a date value (f20) together with a comment (f30)
Keeping this in mind, I then want to created a page process that is called when the user presses the "Save" button that will iterate through these checked rows and store for each record, my date and my comment but only for the rows that I have selected.
So based on the above, I would expect to have 5 news rows in my table with the following columns:
ID MY_DATE MY_COMMENT
1 26/08/2012 Comment A
3 27/08/2012 Comment B
5 28/08/2012 Comment C
7 29/08/2012 Comment D
9 30/08/2012 Comment E
Unfortunately I am unsure how to achieve this using apex_application.G_F10.COUNT.
I want to be able to access the content of each of these array elements (f20) and f(f30) for each row that I have ticked the checkbox with.
Is this possible or have I misunderstood how apex_application.G_Fnn works? If this is not possible, how I can achieve this? Do I need a tabular report?
You're very close.
select apex_item.checkbox2(10, empno) select_me,
apex_item.text(20, empno) empno,
apex_item.text(30, ename)||apex_item.hidden(50, empno) ename
from emp
I'm concatenating the hidden item since i don't want it in its own column. Messes with the layout.
Also, the hidden item is there because of how checkboxes work. Checkboxes only submit their values for checked items. This would mean that array 10 has 3 values. The other arrays would still contain the values for all rows.
This is why i added the hidden empno again: so we can match the checked values to the other rows.
On submit process:
DECLARE
v_empno emp.empno%TYPE;
v_ename emp.ename%TYPE;
BEGIN
--f10: checkbox
--f20: empno
--f30: ename
--f50: empno again
for i in 1..apex_application.g_f10.count
loop
for j in 1..apex_application.g_f50.count loop
if apex_application.g_f10(i) = apex_application.g_f50(j)
then
-- access values for the selected rows in the other arrays
v_empno := apex_application.g_f20(j);
v_ename := apex_application.g_f30(j);
apex_debug_message.log_message('Employee: '||v_empno||' - '||v_ename);
end if;
end loop;
end loop;
END;
Run page, enable debug, select records 2, 4 and 6, submit.
Debug output:
All you now need to do is put your processing in that loop.
How can I fill the page with empty table rows? For example; I have 2 records in the dataset but I want to the page with empty rows (draw the table borders until the end of page)
I have;
I want;
Are you getting your report data from a database? If so you might look at returning empty rows from your database call.
If you can describe your data source and query that you are using for this report, we might be able to suggest changes to the query to return blank rows.
UPDATE:
OK, Based on how you describe the data you are getting, perhaps you can change your database call to do something like this:
select * from Subeler where Subeler.FirmaId = 10
UNION ALL
select TOP 5 ' ' from Subeler where 1 = 1
That will give you your original data, plus 5 "blank" rows to help pad your report. Of course you would have to make sure the second query has the same number and type of columns as your first, but hopefully this will point you in the right direction.