3
votes

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.

2

2 Answers

5
votes

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

3
votes

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?