Storing picture files to Oracle stored procedures

Source: Internet
Author: User
Tags windows 5

The process of storing a picture file, any development tool can store the picture text in the database by calling the procedure.

Detailed steps:

Microsoft Windows 5.00.2195 [Version]

(C) Copyright 1985-2000 Microsoft Corp.

C:\Documents and SETTINGS\CHANET>CD

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,

Ten 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.

Related Article

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.