Search code examples
oracle-databaseplsqloracle-ords

File uploads in a non-Apex PL/SQL application migrated to ORDS


The official Oracle document 1982130.1 describes the missing feature that currently prevents us from migrating from mod_plsql to ORDS:

Migrate a Non-Apex PL/SQL application from Oracle HTTP Server to Oracle REST Data Services (ORDS) 2.0.9. When running the PL/SQL application with Oracle REST Data Services, got the following error message: "ORA-20888: p_application_id must be provided" error in catalina.out regardless of the value of that parameter.

What are others doing to migrate a non-Apex application from mod-plsql to ORDS?


Solution

  • ORDS 18.3+ the logic changed to make it easier for non-apex. Here's the new logic in a flow chart hopefully make it easy to follow.

    enter image description here

    In Previous to 18.3 and below here's how to accomplish the same >

    The catch is right now is there's a hacky workaround to getting this to work and that's to pretend apex is too old to use that code path. ( yeah yeah I'll fix this )

    In the db user that is configured in the connection pool file, create this view. The code checks that if apex 4+ is installed to use that. This view is how that is checked so forcing ords to thing apex is old will make the plain 'ol DOC Table path be used.

    create view apex_release as
      select '1.0.0.0' VERSION_NO from dual;
    

    url-mapping.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <pool-config xmlns="http://xmlns.oracle.com/apex/pool-config">
       <pool base-path="/klrice" name="klrice" />
    </pool-config>
    

    conf/klrice.xml

    The parameter is named apex.docTable and this will default to "FLOWS_FILES.WWV_FLOW_FILE_OBJECTS$"

    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
    <properties>
      <entry key="db.username">klrice</entry>
      <entry key="db.password">klrice</entry>
      <entry key="apex.docTable">klrice.MYDOCTABLE</entry>
    </properties>
    

    My Table

    KLRICE@xe🍻🍺 >CREATE TABLE MYDOCTABLE (
      2    NAME               VARCHAR(256)   UNIQUE NOT NULL, 
      3    MIME_TYPE          VARCHAR(128), 
      4    DOC_SIZE           NUMBER, 
      5    DAD_CHARSET        VARCHAR(128), 
      6    LAST_UPDATED       DATE, 
      7    CONTENT_TYPE       VARCHAR(128), 
      8    CONTENT            LONG RAW, 
      9*   BLOB_CONTENT       BLOB );
    

    After being called:

      1* select BLOB_CONTENT from MYDOCTABLE
    KLRICE@xe🍻🍺 >/
    
    BLOB_CONTENT                                                                    
    --------------------------------------------------------------------------------
    89504E470D0A1A0A0000000D49484452000000C8000000C80806000000AD58AE9E00000001735247