Oracle store picture's stored procedures [turn]

Source: Internet
Author: User

C:/>sqlplus/nolog
Sql*plus:release 9.2.0.1.0-production on Wednesday January 19 14:46:21 2005
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
Sql> Connect chanet/chanet@oradb;
is connected.
Sql> CREATE TABLE Image_lob (t_id VARCHAR2 (5) Not null,t_image BLOB not NULL);
Table has been created.
sql> CREATE OR REPLACE DIRECTORY IMAGES as ' c:/oracle '; --Photo Catalogue
The directory has been created.
sql> CREATE OR REPLACE PROCEDURE img_insert (TID varchar2,filename VARCHAR2) as
2 F_lob BFILE;
3 B_lob BLOB;
4 BEGIN
5 INSERT into Image_lob (t_id, T_image)
6 VALUES (Tid,empty_blob ()) return t_image into B_lob;
7 f_lob:= bfilename (' IMAGES ', FILENAME);
8 Dbms_lob. FILEOPEN (F_lob, Dbms_lob. FILE_READONLY);
9 Dbms_lob. LoadFromFile (B_lob, F_lob, Dbms_lob. GetLength (F_lob));
One by one dbms_lob. FileClose (F_LOB);
COMMIT;
The end;
14/
Procedure has been created.
sql>--sample
sql> EXEC Img_insert (' 1 ', ' f_test.jpg ');
The PL/SQL process has completed successfully.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.