User Image
Create Directory and Grant in Oracle apex

Create Directory and Grant in Oracle apex

GooAdmin Team

Creating DateApril 4, 2023

Pl/SqlOracleOracle apex

Oracle apex Create Directory and and Grant :

1CREATE OR REPLACE DIRECTORY DIRECTORY_NAME AS 'C:\FOLDER_LOCATION';
2 
3GRANT read, write ON DIRECTORY DIRECTORY_NAME TO USERNAME;

Create Procedure In Database :

1CREATE OR REPLACE PROCEDURE blob_to_file (p_blob      IN OUT NOCOPY BLOB,
2                                          p_dir       IN  VARCHAR2,
3                                          p_filename  IN  VARCHAR2)
4AS
5  l_file      UTL_FILE.FILE_TYPE;
6  l_buffer    RAW(32767);
7  l_amount    BINARY_INTEGER := 32767;
8  l_pos       INTEGER := 1;
9  l_blob_len  INTEGER;
10BEGIN
11  l_blob_len := DBMS_LOB.getlength(p_blob);
12  
13  -- Open the destination file.
14  l_file := UTL_FILE.fopen(p_dir, p_filename,'WB', 32767);
15
16  -- Read chunks of the BLOB and write them to the file until complete.
17  WHILE l_pos <= l_blob_len LOOP
18    DBMS_LOB.read(p_blob, l_amount, l_pos, l_buffer);
19    UTL_FILE.put_raw(l_file, l_buffer, TRUE);
20    l_pos := l_pos + l_amount;
21  END LOOP;
22  
23  -- Close the file.
24  UTL_FILE.fclose(l_file);
25  
26EXCEPTION
27  WHEN OTHERS THEN
28   -- Close the file if something goes wrong.
29    IF UTL_FILE.is_open(l_file) THEN
30      UTL_FILE.fclose(l_file);
31    END IF;
32    RAISE;
33/* WHEN UTL_FILE.invalid_operation THEN dbms_output.PUT_LINE('cannot open file invalid name');
34WHEN UTL_FILE.read_error THEN dbms_output.PUT_LINE('cannot be read');
35WHEN no_data_found THEN dbms_output.PUT_LINE('end of file');
36
37UTL_FILE.fclose(l_file);
38 RAISE;*/
39END blob_to_file;
40/

Insert image in directory from APEX Application

1DECLARE
2 l_blob  BLOB;
3BEGIN
4
5 select  BLOB_CONTENT INTO   l_blob  FROM apex_application_temp_files
6         where NAME= :P1_IMAGE ;
7  
8  blob_to_file(p_blob     => l_blob,
9               p_dir      => 'DIRECTORY_NAME',
10               p_filename => PARAMETER||'.png');
11
12  
13END;

 Query

1select prod_id,prod_name,unit,rate,'<img src="http://localhost:8080/i/DIRECTORY_NAME/'||Parameter||'.png" width=100px height=100px </img>' imagefrom PRODUCT_INFO

May you like Heart Icon

No posts found in the category "Pl/Sql"

Comments