Bonjour,
J'ai besoin de extraire un fichier BLOB stocké dans ma base. Le schéma de ma table est TB_EDITION(ID vrachar(10), CONTENU Blob).
mon objectif est d'extraire avec PL/SQL le contenu de ce BLOB.
j'ai essayé le code suivant
mais l'erreur suivant s'affiche.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38 DECLARE l_file UTL_FILE.FILE_TYPE; l_buffer RAW(32767); l_amount BINARY_INTEGER := 32767; l_pos INTEGER := 1; l_blob BLOB; l_blob_len INTEGER; BEGIN -- Get LOB locator SELECT CONTENU INTO l_blob FROM PFI.TB_EDITION WHERE ID=21189 l_blob_len := DBMS_BLOB.getlength(l_blob); -- Open the destination file. l_file := UTL_FILE.fopen('/home/x014340/EXPORT_HIST/','test.pdf','w', 32767); -- Read chunks of the BLOB and write them to the file -- until complete. WHILE l_pos < l_blob_len LOOP DBMS_LOB.read(l_blob, l_amount, l_pos, l_buffer); UTL_FILE.put_raw(l_file, l_buffer, TRUE); l_pos := l_pos + l_amount; END LOOP; -- Close the file. UTL_FILE.fclose(l_file); EXCEPTION WHEN OTHERS THEN -- Close the file if something goes wrong. IF UTL_FILE.is_open(l_file) THEN UTL_FILE.fclose(l_file); END IF; RAISE; END;la version oracle est : 10
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7 l_blob_len := DBMS_BLOB.getlength(l_blob); * ERREUR à la ligne 15 : ORA-06550: Ligne 15, colonne 3 : PL/SQL: ORA-00933: la commande SQL ne se termine pas correctement ORA-06550: Ligne 10, colonne 3 : PL/SQL: SQL Statement ignored
Merci d'avance
Partager