Search code examples
oracle-databaseoracle-sqldeveloperoracle-apexoracle-apex-5oracle-apex-5.1

Oracle Apex 5 File Browser Blob Creation


I'm using APEX 5 for the first time and having issue trying to insert items into my blob table.

I searched for many guides about creating File Browse's storage type to BLOB columns, which allows me to add MIME_TYPE, FILENAME, and CHARSET etc into my table. I am trying to create both upload and download feature.

But one thing that's been really confusing is creating DML processes, I could not understand where they getting their primary key item from, I somewhat understand that the DML primary key column are supposed to be my table's primary key?Errors keep coming up when I try to upload. : https://i.sstatic.net/pj0G0.png

Any kind of help or tips would be greatly appreciated!

Below is my table to store blob

CREATE TABLE  "MATERIALS" 
   (    "ID" NUMBER NOT NULL ENABLE, 
    "MATERIAL_NAME" VARCHAR2(400), 
    "FILENAME" VARCHAR2(350), 
    "M_COURSE_ID" VARCHAR2(68), 
    "MIME_TYPE" VARCHAR2(255), 
    "DOC_SIZE" NUMBER, 
    "CHARSET" VARCHAR2(128), 
    "LAST_UPDATE_DATE" DATE, 
    "CONTENT" BLOB, 
     CONSTRAINT "MATERIALS_PK" PRIMARY KEY ("ID")
  USING INDEX  ENABLE
   )   NO INMEMORY

Solution

  • You'll need a item on your page to hold the id field. Your first process will populate it. I'm guessing you have a sequence?

    1. Create a Hidden item, I'll call it P1_ID.
    2. Your first process will populate it if it's empty. Create a process at the Processing step with a body of:

      apex_util.set_session_state( 'P1_ID', mysequence.NEXTVAL );

    3. Your DML process must run after this step, so drag them around or change the sequence if necessary.

    4. Now set the Primary Key Item value to P1_ID in your DML process.