May 10 2011

The Developer Toolbar in APEX Application Disappeared

Category: APEXittichai @ 7:57 am

If the Developer Toolbar (shown below) in your Oracle APEX application is not displayed, you can control its display by changing the Status attribute on the application’s Edit Definition page.

I’ve learned about this when somehow one of our applications suddenly did not display the Developer Toolbar. We found out later that during environment refresh, the deployment team switched the Application’s Availability Status to Unavailable before the refresh and then back to Available after it’s done – not realizing that it was initially Available with Edit Links.

No harm done – just temporary inconvenience from Developer’s standpoint. :-)

Related Topic:

Tags: , , , , , ,


Mar 16 2011

File Browser in APEX 4 with BLOB column specified in item source attribute

Category: APEXittichai @ 12:45 pm

In APEX 4, we now have the option to place where the uploaded file will be stored within the development workspace interface. The Storage Type setting of the File Browser item has two options:

File Browser Settings

  • Table WWV_FLOW_FILES stores the uploaded file in the table wwv_flow_files (or APEX_APPLICATION_FILES).  This is the default way in the previous versions of APEX. Note that if you still decide to store the uploaded files this way, it is suggested to move record to another custom table after upload, and then clean it up in this table because this is the shared default area (table) where every application will upload files to.
  • BLOB column specified in item source attribute will store the uploaded file in a custom table identified in the Automatic Row Processing (DML) process and the column specified in the item source attribute. This column has to be of data type BLOB.

To configure the File Browser with the BLOB column specified in item source attribute.

1. Create a table for storing uploaded files. One of the columns must be BLOB data type.

CREATE TABLE tbl_attach_file
(
  attach_id          NUMBER PRIMARY KEY,
  attach_data        BLOB,
  attach_mimetype    VARCHAR2(255),
  attach_filename    VARCHAR2(255),
  attach_last_update DATE ,
  attach_charset     VARCHAR2(128),
  attach_user        VARCHAR(10)
);

CREATE SEQUENCE SQ_ATTACH_FILE start with 1;

CREATE OR REPLACE TRIGGER tr_attach_file_BI
   BEFORE INSERT
   ON tbl_attach_file
   FOR EACH ROW
BEGIN
   SELECT SQ_ATTACH_FILE.NEXTVAL
     INTO :NEW.attach_id
     FROM DUAL;
END;
/

2. Create a File Browser item with the following settings.

If this is just simply for file upload, select No on Display Download Link. Otherwise, it will require additional Automated Row Fetch (DML). See note and comment below.

File Browser Settings

3.  The item’s source points to the BLOB column.

File Browser Source

4. Create an Automatic Row Processing  (DML) process.

DML

5. Create a button called Upload with Database Action – SQL Insert Action.

Initially I thought this should be sufficient, but when I ran the page, I got this error.

No DML Error

Apparently I got this error because I checked Yes to Display Download Link thus it requires a DML to fetch data. If this is set to No, it should be okay without the following Automated Row Fetch (DML). Thanks Patrick for pointing that out.

To workaround this, I created another DML but for Automated Row Fetch.

DML Fecth

For a purpose of blogging, we’re not going to run any row fetch, so the DML Fetch will have it disabled (its condition to Never). I’m still not sure why the Automated Row Fetch (DML) is needed (even being disabled) if we just want to upload files. But if it is not there, I got the ORA-2001: No Corresponding DML process shown in step 5.

A quick test shows that the file is uploaded to our custom table.

Upload Test

According to Oracle APEX document, the character set of the BLOB is not automatically set on upload. We will have to create an additional page item which is bound to the character set column. This will be where users can specify the character set for the file they are uploading.

Tags: , , , , ,


Nov 05 2010

Upgrade APEX to 4.0.1 encounters “ORA-20011: Approximate NDV failed: ORA-08103: object no longer exists”

Category: APEX,Installationittichai @ 3:03 pm

Few weeks back, we’ve upgraded multiple APEX installations (development, test and production) to new version 4.0.1 from the default version 3.0.1.00.12 in Oracle 11g R1. The upgrade (just running the apexins.sql) went well for all except one. We got a strange error during the last stage of installation.

Performing Application Express component validation - please wait...

Completing registration process. 23:02:26
declare
*
ERROR at line 1:
ORA-20011: Approximate NDV failed: ORA-08103: object no longer exists
ORA-06512: at "SYS.DBMS_STATS", line 18566
ORA-06512: at "SYS.DBMS_STATS", line 19015
ORA-06512: at "SYS.DBMS_STATS", line 21374
ORA-06512: at "SYS.DBMS_STATS", line 21417
ORA-06512: at "SYS.DBMS_REGISTRY_SYS", line 1067
ORA-06512: at "SYS.DBMS_REGISTRY", line 578
ORA-06512: at line 7

The status of the APEX component in the DBA_REGISTRY is set to LOADED.

SYS@DB11G AS SYSDBA> select comp_name, version, status from dba_registry
where comp_name like '%Application Express';

COMP_NAME                             VERSION              STATUS
-----------------------------------   -------------------- -----------
Oracle Application Express            4.0.1.00.03          LOADED

Many attempts to uninstall (using apxremov.sql) and reinstall still encountered the same error.

Initial thought was with the version conflict. I even cleaned up the version coming with database by following the instructions from the MOS note ID 558340.1 – How to Uninstall Oracle HTML DB / Application Express from the Database?  This includes drop all APEX* and FLOWS* schemas as well as public synonyms.

All did not help.

Tracing from the installation script – apexins.sql, the installation portion calls the coreins.sql. All scripts within it run fine until the last one – endins.sql, which according to the description note in the script is to perform the component validation at the end of the installation. The only main operation in the endins.sql is a call to the procedure validate_apex which is owned by SYS. This is just to confirm that actually all installations went fine but failed only when validation.

So I’ve decided to run just it. Surprisingly, it came out with no errors. And more importantly, the APEX registry is now VALID :-)

SYS@DB11G AS SYSDBA> exec sys.validate_apex;

PL/SQL procedure successfully completed.

SYS@DB11G AS SYSDBA> select comp_name, version, status from dba_registry
where comp_name like '%Application Express';

COMP_NAME                             VERSION STATUS
-----------------------------------   ------------------------------ -----------
Oracle Application Express            4.0.1.00.03                    VALID

I still don’t know why the validation failed during the installation. Interesting thing is that this issue happened only on one system.

Tags: , , , , , , , , , ,


Oct 22 2009

Oracle Application Express (APEX) Certification Exam

Category: APEXittichai @ 7:24 am

Oracle is working toward having the first certification exam for Oracle APEX. This “Oracle Application Express Developer Certified Expert” pilot program is intended for intermediate and advanced APEX developers. You will have to indicate the relevant APEX trainings you’ve completed, years of APEX experiences and, of course, the agreement to provide feedback in order to participate. You can see details about this from Joel Kallman’s blog.

I think this is a good thing for APEX community because it shows Oracle’s commitment to this tool.

BTW, I’m very curious about how the tests will be conducted. Personally I think there should be more of actual development hands-on works rather than doing multiple choices.

Tags: , , ,


Oct 18 2008

APEX – Requests to execute DML operations through "Automatic Row Processing (DML)" process

Category: APEXittichai @ 11:59 pm

As a part of the button’s properties, an execution of “Automatic Row Processing (DML)” process either INSERT, UPDATE or DELETE (assuming those operations are allowed) can be controlled by selecting an appropriate Database Action as shown below.

1

Many times, instead through a use of button, page submission is done by calling JavaScript “onSubmit” function. How will we select a DML’s database actions through this approach?

APEX provides a way. The DML process will execute a requested database’s action based on the request value containing one of the listed values here -

2

By default, the request value of a button is the button name itself. But for onSubmit function, the request value is what in the passing value. For example, onSubmit(‘SAVE’) or onSubmit(‘APPLY CHANGES’) will execute database’s UPDATE operation.

The one I found the most useful is APPLY%CHANGES%. The wildcard allows the request value to be flexible.

I could use doSubmit(‘APPLY_CHANGES_D1′) and doSubmit(‘APPLY_CHANGES_U1′) to cause the update operation of all items of the current page. At the same time, it allows me to perform other different operations based on request values from using conditional processing.

The application I’m working on has two created-on-the-fly buttons in the “Display Only” item. The VIEW FILE link and Delete button are visible when file is stored in table. If not, only Upload button is visible.

declare
   v_link  varchar2(300);
begin
   if :P 8_UPLOAD_DOC_ID <> '0' then
	select '<td><a href="#OWNER#.pr_download_file?p_file=' || :P 8_UPLOAD_DOC_ID || '">VIEW FILE</a></td> <td><a href="javascript:confirmDelete(htmldb_delete_message,''APPLY_CHANGES_D1'');"> <img border="0" src="#WORKSPACE_IMAGES#delete.jpg" id="img_delete1"</a/></a></td>'
        into v_link
        from PRODUCT
	   where ID = :P 8_PRODUCT_ID;

   else
        v_link := '<td></td> <td><a href="javascript:doSubmit(''APPLY_CHANGES_U1'')"><img border="0" src="#WORKSPACE_IMAGES#upload.jpg" id="img_upload1"/></a></td>';

   end if;

   return v_link;

end;

When either button is clicked, all item information on the form will be saved (through DML’s update process). If Upload button is pressed, then page will be re-directed to the upload page. If Delete button is pressed, after confirmation, it will remove the actual file which is stored in a different table.

Tags: ,


Nov 14 2007

Oracle APEX in 11g Installation

Category: 11g,APEX,SQL Developerittichai @ 8:55 pm

Today I installed Oracle 11g (11.1.0.6) on my machine. I did not realize that Oracle APEX is a part of the standard database components.

So after the 11g installation, I just follow simple steps (shown later below) for the post-installation. In order to access the APEX application, either the embedded PL/SQL gateway or Oracle HTTP server with mod_plsql is needed. For simplicity, I’ve decided to go with the former. By using the embedded PL/SQL gateway, it will run using the Oracle XML DB HTTP server which is already in Oracle database, so there is no need to install a separate HTTP server. The Oracle’s document here explains about this as well as provides the detailed information on the post-installation.

To configure the embedded PL/SQL gateway:

1. Go to the $ORACLE_HOME/apex directory.

2. Use SQL/Plus to connect as SYS to 11g database where APEX is installed.

SYS AS SYSDBA@db11r1> @apxconf

PORT
----------8080

Enter values below for the XDB HTTP listener port and the password for the Application Express ADMIN user.
Default values are in brackets [ ].
Press Enter to accept the default value.

Enter a password for the ADMIN user              []admin_password
Enter a port for the XDB HTTP listener [      8080]
...changing HTTP Port

PL/SQL procedure successfully completed.

PL/SQL procedure successfully completed.

Session altered.

...changing password for ADMIN

PL/SQL procedure successfully completed.

Commit complete.

3. Unlock the ANONYMOUS account.

SYS AS SYSDBA@db11r1> ALTER USER ANONYMOUS ACCOUNT UNLOCK;

User altered.

4. Enable Oracle XML DB HTTP server

SYS AS SYSDBA@db11r1> EXEC DBMS_XDB.SETHTTPPORT(8080);

PL/SQL procedure successfully completed.

SYS AS SYSDBA@db11r1> COMMIT;

Commit complete.

5. We’re now ready to access APEX.

http://host:port/apex

http://host:port/apex/apex_admin — for admin page

Port in this case is 8080 which is the default.

Note that the format of URL is a little bit different from when using HTTP server with mod_plsql -

http://host:port/pls/apex

http://host:port/pls/apex/apex_admin — for admin page

Also the SQL Developer 1.1.3 is included under “sqldeveloper” directory of ORACLE HOME. So just double-click at sqldeveloper.exe to launch application.


Tags: ,