Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --First, insert image into properties_images table
- DECLARE
- l_upload_size INTEGER;
- l_upload_blob BLOB;
- l_image_id NUMBER;
- l_image ORDSYS.ORDImage;
- BEGIN
- --
- -- Get the BLOB of the new image from the APEX_APPLICATION_TEMP_FILES (synonym for WWV_FLOW_TEMP_FILES)
- -- APEX 5.0 change from APEX_APPLICATION_FILES which has been deprecated
- -- APEX_APPLICATION_TEMP_FILES has fewer columns and is missing doc_size
- --
- SELECT
- blob_content
- INTO
- l_upload_blob
- FROM
- apex_application_temp_files
- WHERE
- name = :P6_image_filename;
- --
- -- Insert a new row into the table, initialising the image and
- -- returning the newly allocated image_id for later use
- --
- INSERT
- INTO
- properties_images
- (
- p_i_id,
- image_filename,
- property_image
- )
- VALUES
- (
- seq_p_images_p_i_id.NEXTVAL,
- :P6_image_filename,
- ORDSYS.ORDImage()
- )
- RETURNING
- p_i_id, property_image
- INTO
- l_image_id, l_image;
- -- find the size of BLOB (get doc_size)
- l_upload_size := DBMS_LOB.getlength(l_upload_blob);
- -- copy the blob into the ORDImage BLOB container
- DBMS_LOB.COPY( l_image.SOURCE.localData, l_upload_blob, l_upload_size );
- -- set the image properties
- l_image.setProperties();
- UPDATE
- properties_images
- SET
- property_image = l_image -- original ORDImage image
- WHERE
- p_i_id = l_image_id;
- -- generate the thumbnail image from the ORDImage
- create_blob_thumbnail(l_image_id);
- --Then update properties table with new data (including image id)
- UPDATE properties
- SET a_id = :P6_a_id,
- p_i_id = l_image_id,
- address_line_1 = :P6_address_line_1,
- address_line_2 = :P6_address_line_2,
- city = :P6_city,
- postcode = :P6_postcode,
- notes = :P6_notes
- WHERE p_id = :P6_p_id;
- END;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement