Monday, March 9, 2009

Test Data in Production Applications

Hi,

Well this isn't an APEX specific post but I thought it should be mentioned either way. It raises a good point about keeping test data out of production.

I got the following email from a colleague today:

"I’m a bit of a golf fan, and I like to read up on current events, standings, player profiles, etc. My favorite site to do this is www.pgatour.com

I was recently searching for a player with the surname of Fischer on the website. I had a good laugh when the search results came back. Take a look at the 6th name in the list in the attached image…
"

Here's the screenshot:



- Martin

Thursday, February 5, 2009

"Application ID Reserved" - Fix

When you upgrade an application do you ever get the following "Application ID Reserved" error message?




Even if you delete your application and try to re-import using the same application ID you'll get the message.

To view "reserved" application ids you can run the following query (please note you may need to be a dba user):

select *
from flows_030100.wwv_flows_reserved;

In order to fix this problem you just need to delete the application id from that table:

delete
from flows_030100.wwv_flows_reserved
where id = :p_app_id; -- Your application ID that is locked

Tuesday, January 20, 2009

APEX Report with checkboxes (advanced).

Note: This solution was updated to account for APEX's new features and APIs. See the updated post here: http://www.talkapex.com/2015/09/report-with-checkboxes-update.html

A colleague of mine wanted to build a report with check boxes. Once the user selected all the rows, they would click submit and the application would process the rows. Sounds pretty simple and straight forward however he did have some extra requirements:

- The report is an interactive report
- There may be up to 10,000 records in the report
- When the user "scrolls" through the report (i.e. uses pagination), if they checked off a box it should remain checked the entire time (i.e. if they check an row in the 1st 15 rows, then view rows 16~30, then go back to rows 1~15 it should remain checked)

So here's the example on how to do it. The working example can be found here: http://apex.oracle.com/pls/otn/f?p=20195:500

Create an application item F_EMPNO_LIST. Note you can use a page item as well...

Setup IR:
SELECT apex_item.checkbox (1,
                           empno,
                           'onchange="spCheckChange(this);"',
                           :f_empno_list,
                           ':'
                          ) checkbox,
       empno, ename, job
  FROM emp

Once the report is setup set the row display to 5 (you'll need it for this example)

- Add an HTML region and add the following code: (Note: the jQuery call is not needed... for now)


CHECKBOX List:

&F_EMPNO_LIST.

Now create an application process (on Demand) called: CHECKBOX_CHANGE
-- Application Process: CHECKBOX_CHANGE
-- On Demand...

DECLARE
  v_item_val NUMBER := apex_application.g_x01;
  v_checked_flag VARCHAR2 (1) := apex_application.g_x02;
BEGIN
  IF v_checked_flag = 'Y' THEN
    -- Add to the list
    IF :f_empno_list IS NULL THEN
      :f_empno_list := ':' || v_item_val || ':';
    ELSE
      :f_empno_list := :f_empno_list || v_item_val || ':';
    END IF;
  ELSE
    -- Remove from the list
    :f_empno_list := REPLACE (:f_empno_list, ':' || v_item_val || ':', ':');
  END IF;

  -- Just for testing
  HTP.p (:f_empno_list);
END;

- On the post page create a query to view data (you can process how you need/want)
select *
from emp
where instr(:F_EMPNO_LIST, ':' || empno || ':') > 0

Please note there may be better/faster ways to implement the SQL code etc.

Here are some links on the x01 code that I used:
http://carlback.blogspot.com/2008/03/new-stuff-2-x01-and-friends.html and http://carlback.blogspot.com/2008/04/new-stuff-q.html

Sunday, December 28, 2008

How to access images in APEX on Linux

Hi,

Dietmar has a great post on where the images are located in APEX using webdav: http://daust.blogspot.com/2006/03/where-are-images-of-application.html He also covers how to access them via FTP!

I recently switched from Windows to Linux and was looking for a quick way to access the files as I would with Windows.

Using KDE and Konqueror, you can access them very easily. Use the following in the URL: webdav://<url>

So it would be: webdav://127.0.0.1:8080/i

Log in with system and you should be able to access everything!

Martin

Sunday, December 14, 2008

jQuery Calendar and Application Date Format

Hi,

Last week Roel had a posting about jQuery's Date Picker: http://roelhartman.blogspot.com/2008/12/how-to-replace-default-apex-calendar.html Definitely a great example for people who are looking for an alternative to APEX's date picker.

We do use the jQuery calendar and have some interesting standards around it (I'll try to blog about this another day). The most important one, and easiest to implement, is the date format standards.

Javascript/jQuery and Oracle use different date formats. If you are going to use the jQuery date picker I strongly suggest that you standardize your date formats so that you won't have conflicting results down the road. Here's what we do:

We have 2 application level items:

F_DATE_FORMAT: is used for the application level date format
F_JQUERY_DATE_FORMAT: format to display the date the same as f_date_format

Both these items are set at login time and the values are defined in our database at the client level. You have to make sure that the date formats produce the same results.

In Roel's example he uses the jQuery on load function. For the date format just use &F_JQUERY_DATE_FORMAT. instead and this will load set the jQuery date formats accordingly.

Here's a listing of jQuery's date formats: http://docs.jquery.com/UI/Datepicker/%24.datepicker.formatDate

And Oracle's date formats: http://www.techonthenet.com/oracle/functions/to_date.php

Hope this helps,

M