Skip to Main Content

APEX

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to insert a BLOB in a table from File browse item

LauryJan 8 2018 — edited Jan 11 2018

Hi,

I am working with APEX 5.1.

From a form interface, I wish to insert a serie of values, and above all an image defined as a "browse file", with its corresponding file name and mimetype.

After filling that form, I press a button and a PL/SQL block performs the insert.

It works fine if I do not deal with LOB/browse file items.

My target table is defining like this for the file to be inserted:

CUSTOMER_IMAGE as BLOB => this the file that needs to be uploaded as "browse file" through the APEX form.

MIMETYPE as VARCHAR2(50) => this is the mimetype for the file to be uploaded.

IMAGE_LAST_UPDATE as DATE => this is the date the file is uploaded.

CUSTOMER_IMAGE_FILENAME as VARCHAR2(200) => this is the file name of the "browse file" item, that appear just on the right side after the file is selected.

My "browse file" is defined as follow:

Name: P46_CUSTOMER_IMAGE

Display as: File browse...

Storage type: BLOB column specified in the Item attribute

MIME type column: MIMETYPE

Filename column: CUSTOMER_IMAGE_FILENAME

Display download link: Yes

BLOB last updated column: IMAGE_LAST_UPDATE

After I press the "submit" button, a PL/SQL block is executed:

declare

    v_blob                blob;

begin

    insert into demo_customers

    (

    customer_id,

    cust_first_name,

    cust_last_name,

    cust_street_address1,

    cust_street_address2,

    cust_city,

    county,

    cust_state,

    cust_postal_code,

    phone_number1,

    phone_number2,

    credit_limit,

    cust_email,

    -- customer_image,

    -- mimetype

    -- image_last_update

    -- customer_image_filename

    -- (always) image_name

    company_profile_filename,

    company_profile

    )

    values

    (

    :P46_CUSTOMER_ID,

    :P46_CUST_FIRST_NAME,

    :P46_CUST_LAST_NAME,

    :P46_CUST_STREET_ADDRESS1,

    :P46_CUST_STREET_ADDRESS2,

    :P46_CUST_CITY,

    :P46_COUNTY,

    :P46_CUST_STATE,

    :P46_CUST_POSTAL_CODE,

    :P46_PHONE_NUMBER1,

    :P46_PHONE_NUMBER2,

    :P46_CREDIT_LIMIT,

    :P46_CUST_EMAIL,

    ('profile_' || lower(:P46_CUST_FIRST_NAME) || '_' || :P46_CUST_LAST_NAME || '.txt'),

    :P46_COMPANY_PROFILE

    );

end;

Can someone explain me how I can insert the "browse file" content as CUSTOMER_IMAGE (BLOB), as well as with the corresponding values for MIMETYPE, CUSTOMER_IMAGE_FILENAME, and IMAGE_LAST_UPDATE?

Thanks by advance for any tip(s).

Kind Regards

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 8 2018
Added on Jan 8 2018
25 comments
13,243 views