Advertisement
Guest User

Untitled

a guest
Nov 21st, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PL/SQL 1.78 KB | None | 0 0
  1. --First, update properties table with new data
  2. UPDATE properties
  3. SET address_line_1 = :P3_address_line_1,
  4.     address_line_2 = :P3_address_line_2,
  5.     city = :P3_city,
  6.     postcode = :P3_postcode,
  7.     notes = :P3_notes
  8. WHERE p_id = :P3_p_id;
  9.  
  10. --Then insert image into properties_images table
  11. DECLARE
  12.  
  13.   l_upload_size INTEGER;
  14.   l_upload_blob BLOB;
  15.   l_image_id    NUMBER;
  16.   l_image       ORDSYS.ORDImage;
  17.  
  18. BEGIN
  19.  
  20.   --
  21.   -- Get the BLOB of the new image from the APEX_APPLICATION_TEMP_FILES (synonym for WWV_FLOW_TEMP_FILES)
  22.   -- APEX 5.0 change from APEX_APPLICATION_FILES which has been deprecated
  23.   -- APEX_APPLICATION_TEMP_FILES has fewer columns and is missing doc_size
  24.   --
  25.  
  26.   SELECT
  27.     blob_content
  28.   INTO
  29.     l_upload_blob
  30.   FROM
  31.     apex_application_temp_files
  32.   WHERE
  33.     name = :P3_image_filename;
  34.   --
  35.   -- Insert a new row into the table, initialising the image and
  36.   -- returning the newly allocated image_id for later use
  37.   --
  38.   INSERT
  39.   INTO
  40.     properties_images
  41.     (
  42.       p_i_id,
  43.       image_filename,
  44.       property_image
  45.     )
  46.     VALUES
  47.     (
  48.       seq_p_images_p_i_id.NEXTVAL,
  49.       :P3_image_filename,
  50.       ORDSYS.ORDImage()
  51.     )
  52.   RETURNING
  53.     p_i_id, property_image
  54.   INTO
  55.     l_image_id, l_image;
  56.    
  57.   -- find the size of BLOB (get doc_size)
  58.   l_upload_size := DBMS_LOB.getlength(l_upload_blob);
  59.   -- copy the blob into the ORDImage BLOB container
  60.   DBMS_LOB.COPY( l_image.SOURCE.localData, l_upload_blob, l_upload_size );
  61.  
  62.   -- set the image properties
  63.   l_image.setProperties();
  64.  
  65.   UPDATE
  66.     properties_images
  67.   SET
  68.     property_image     = l_image -- original ORDImage image
  69.   WHERE
  70.     p_i_id = l_image_id;
  71.  
  72.   -- generate the thumbnail image from the ORDImage
  73.   create_blob_thumbnail(l_image_id);
  74. END;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement