Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: Oracle

sql>CREATE TABLE lob_table (id NUMBER, doc BLOB);
 
Table created
sql>INSERT INTO lob_table VALUES (1, EMPTY_BLOB());
 
1 row created
 
sql>DECLARE
2 src_lob BFILE := BFILENAME('image_dir', 'D:\image_dir\image1.jpeg');
3 dest_lob BLOB;
4 BEGIN
5 INSERT INTO lob_table VALUES(2, EMPTY_BLOB())
6 RETURNING doc INTO dest_lob;
7 DBMS_LOB.OPEN(src_lob, DBMS_LOB.LOB_READONLY);
8 DBMS_LOB.LoadFromFile( DEST_LOB => dest_lob,
9 SRC_LOB => src_lob,
10 AMOUNT => DBMS_LOB.GETLENGTH(src_lob) );
11 DBMS_LOB.CLOSE(src_lob);
12 COMMIT;
13 END;
14 /
 

dbms_lob.close(src_lob);
*
ERROR at line 11:
ORA-06550: line 11, column 1:
PLS-00103: Encountered the symbol "DBMS_LOB" when expecting one of the
following:
:= . ( % ;

 

This kind of error occurred in procedure
Please help
Posted 21-Jan-13 22:03pm
surkhi623
Comments
Kishor Deshpande at 22-Jan-13 3:06am
   
Are you using any front end to insert it? I mean Java or .NET?
cool_sari at 22-Jan-13 4:13am
   
Ya
It's VB6...........
I know it's really older but my project requirement is same....
Is there any easier way to insert pictures using blob??????????

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Below is the code to insert an image into the table.
Create a table to store the blob.
CREATE TABLE tabblobs
( 	id varchar2(255),
	blob_col blob
);
Create a logical directory in the database.
CREATE OR REPLACE directory MY_FILES AS 'd:\images';
Create a procedure to load the blob from the physical disk using the logical
directory. The gif "ORATEST.gif" must exist in d:\images.
CREATE OR REPLACE procedure insert_img AS
flob bfile;
blob blob;
BEGIN
	INSERT INTO tabblobs VALUES ( 'MyGif', empty_blob() )
	RETURN blob_col INTO blob;
 
	flob := bfilename( 'MY_FILES', 'ORATEST.gif' );
	dbms_lob.fileopen(flob, dbms_lob.file_readonly);
	dbms_lob.loadfromfile( blob, flob, dbms_lob.getlength(flob) );
	dbms_lob.fileclose(flob);
	COMMIT;
END;
/
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 6,569
1 Sergey Alexandrovich Kryukov 6,168
2 DamithSL 5,228
3 Manas Bhardwaj 4,717
4 Maciej Los 4,150


Advertise | Privacy | Mobile
Web04 | 2.8.1411022.1 | Last Updated 19 Mar 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100