I am currently using Oracle Apex version 18.2.0.00.12 on Internet Explorer on a computer running Windows 10.
I am having a problem with downloading an Interactive Grid as a CSV file.
On my Apex page I have an interactive grid and three page items. Two of the page items, P200_DATE_FROM and P200_DATE_TO, are Date Picker items. The other item is a button named "Submit" and its action is "Submit Page".
This is the query for my interactive grid:
select * from kat_test
where repairdate between :P200_DATE_FROM and :P200_DATE_TO;
There are four columns in the Interactive Grid:
Issue - Varchar2
Month - Number
Week - Number
Repairdate - Date
The only settings I changed in the Interactive Grid are the title and the SQL query.
I changed the Source of P200_DATE_FROM to PL/SQL Expression that returns the first day of the current month. It is set to be used "Only when the current value in session state is null". The expression is:
trunc(last_day(sysdate)-1, 'mm')
I changed the Source of P200_DATE_TO PL/SQL Expression that returns the current date. It is also set to be used "Only when the current value in session state is null". The expression is:
sysdate
When I run the page, it loads exactly as expected in the sense that the P200_DATE_FROM page item is populated with the first date of the current month, the P200_DATE_TO item is populated with the current date, and the interactive grid displays the correct data.
The problem: When I select Actions -> Download -> CSV, the CSV file downloads and opens as an Excel file, BUT only the header names are displayed. The cells underneath the headers are all empty. However, if I change one of the dates (or both) in the P200_DATE_FROM page item and/or the P200_DATE_TO page item and then press the submit button, the page is submitted and then when I click Actions -> Download -> CSV, the Excel file opens and all of the data is displayed perfectly (both the column headers and the data underneath the headers).
I don't understand why when I initially load the page, the CSV file for the Interactive Grid does not download correctly, but after I click the submit button the CSV file does download correctly.
Does anyone have any ideas?
Thank you in advance.
I think you just need to put the name of these items in the field "Items to submit" next to your SQL. When it downloads, I think it reprocesses SQL using the values of the items that are in the session. If you do not put those items there, the values do not go to the session. Enter the item names separated by a comma. After that, I think any changes is necessary in your SQL
Report's query, probably, contains a WHERE clause which looks like this:
where some_date between :P200_DATE_FROM and :P200_DATE_TO
Modify it so that includes NVL function whose second parameter reflects items' default values, i.e.
where some_date between nvl(:P200_DATE_FROM, trunc(last_day(sysdate)-1, 'mm'))
and nvl(:P200_DATE_TO, sysdate)
Run the page, download CSV; any improvement?
Related
I have a very simple Oracle Apex app. I created a button on the home page. I also created a second page using the "Form" template, and the source for this form is a table in the local database.
I set the button to open the form, and I passed the value of the primary key of this form (it's a column called ID) from the home page to the form page, as this screenshot of the button's behavior shows (3 is the page number of the form, P3_ID is the page item in the form associated with the primary column "ID", and 1 is the value that I passed for P3_ID):
The table that the form references is empty, i.e. there is no row with ID equal to 1. Meaning I want to pass the value of 1 to this form so that it automatically create a row with ID of 1 after the user fills out the rest of the form. Here is the form page:
Now the error. When I run the app and press the button, I get this error:
The error says it's from the process called "Initialize form Warcraft Particulars". I searched everywhere and I couldn't find a process by that name anywhere in the app. What am I doing wrong?
Pre-rendering process (in a form) will try to execute query and fetch a row whose ID = 1; as it doesn't exist, Apex raises the no_data_found error. That's why you got it (the error).
Moreover, you're doing it wrong - don't pass ID you'd want to create, fill it in form's process (or use a database trigger which will put a sequence number into the ID column, or use an identity column if your Oracle database supports it (12c onward)).
Furthermore, I'd suggest a slightly different approach: don't create a form that's alone in the Universe. Approach that lets you both view existing data, update (or delete) it and insert new rows is to use a Wizard and choose a report with a form. Exact naming is different from one Apex version to another; for example, current apex.oracle.com Apex version is 22.2 and it offers "Interactive report", while the 1st Wizard page lets you choose whether you want (or not) to include a form page (you'd say "Yes").
Anyway: once you find the correct option, choose it and wizard will then create an interactive report page you'd use to
view current data
it has an edit icon at the beginning of each row which - when pressed - navigates to the form page where you can edit values or delete entire row
create new row (by pressing the "Create" button)
and a form page which does what I described a moment ago.
I have an Interactive Grid with a really simple select list (two values only):
No
Submitted
This is an editable IG, when I click on my select list column the value automatically changes to 'No' (which is the one displayed first out of the two options) regardless of what I have on that row.
E.g.
This is row 1:
It had 'Submitted' as its value, but when I double clicked to edit, it automatically changed to 'No'.
Does anybody know how to fix this?
Thanks
(using Apex 22.1.3)
I have 2 Item from date and to date and one submit button in a page..
:p1_enter_start_date and :p1_enter_end_date and one Submit button
In that user have to enter the from and to dates to get the output report region as intractive report.
Now i want to show the from and two dates in that page header which user have selected, that will be captured in items
please suggest how to set the item values to page header in oracle apex page
You can display the value of an item as html using the &ITEM. notation. So in your case that would be &P1_ENTER_START_DATE. and &P1_ENTER_END_DATE. (Don't forget the trailing .). You can check the documentation here: https://docs.oracle.com/en/database/oracle/application-express/19.1/htmdb/understanding-page-level-items.html
I have a blank page with a static content region (Template = Form Region). I select a project via a select list (there is only one project, so it automatically selects it). I then have a key popup lov (a popup lov that displays the description not the returned number value) from which I select a person to be in this project. I am trying to get the form to display the person I selected and saved previously when the form launches for the first time (since the project is chosen due to there being one). This works when you refresh the page, but it doesn't work if you log out and log back into the form. I tried using the default value with a sql query. I tried using a dynamic action that fires when the project changes; but neither approaches work. I fiddled with all the settings, but couldn't get anything to work. Does anyone know how to accomplish this in Oracle APEX?
I even added a refresh of the cascading popup lov to the dynamic action. I can see the hidden input item showing my defaulted value, but the popup lov does not display it on screen. Is this an Oracle bug?
Also in Javascript from the console
$s("P51_LINE_MANAGER1", "7104");
sets the hidden value, but doesn't display on screen.
$v("P51_LINE_MANAGER1");
does however return 7104.
I am a relative APEX noob.
I'm running APEX 4.0 against a 10gR2 database.
I've written a query that takes a few inputs (two date fields, for start and end, and a text field for further filtering) and created a dynamic report out of it that works when I pull the input variables (:START_DATE, :END_DATE, :OFFICE) out of it or replace them with static values.
I want to create a form on a page that submits those values to the dynamic report page for use in the query to filter the results the user sees when he or she hits the report.
I'm not having much luck finding a good step-by-step example of this. I created a blank page with two Date Pickers and a LOV select dropdown, but am unsure how to best translate those values into the dynamic report.
Can somebody point me at the right documentation for this?
The following was developed using Apex 4.1 but apart from some cosmetic changes the principles should be the same.
The data comes from the standard scott.emp schema.
Overview
This is page 1, the user can enter an empno and\or a hiredate.
When submit is pressed the following report on a different page is displayed:
How it works
On page 1 I have created the three items shown. The text items are called them P1_EMPNO, and P1_HIREDATE. The action for the button is "Submit Page"
Still on page 1, create a branch with the following values:
This branch navigates to page 2 (which is yet to be developed) and sets the values of items on page 2 with the values from page 1.
Create a new page, in this example this will be referred to page 2.
On page 2 create a new interactive report using the following query:
select e.*
from emp e
Next create two text items in the same region as the report and call these :P2_EMPNO and :P2_HIREDATE. I have found it useful to show these items during development so you can see that the correct values are being passed through to the page. You can always set them as hidden once you happy with the report.
Finally amend the query used by the interactive report to use the values supplied by page 1
Run the application.
You want to reference your page items in your query, which means you'll have to submit your page before your query will pick up the session state of them. What I do when I provide a small parameter form, is to put a button up there as well (i.e. labeled 'Query'), which does a submit.
In your report you can then reference your items. If for example you have 2 items P1_DATE_START and P1_DATE_END, your query could look like:
SELECT firstname, lastname, job
FROM employees
WHERE employment_start BETWEEN to_date(:P1_DATE_START) AND to_date(:P1_DATE_END);