Advertisement
Guest User

Untitled

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