Read and Write BLOB Data to a Database Table with ODP.NET
page 2 of 7
by Steven Swafford
Average Rating: 
Views (Total / Last 10 Days): 68370/ 164

Establish Your Database Schema

[ Download Code ]

I am a fan of utilizing any tool that makes my life easier as a developer and one such tool that I love when working with and Oracle database is PL/SQL Developer and you can find out more on this product at AllRoundAutomations.

Just to give you idea of this product take a look at this screenshot.

To establish the table which will hold the necessary data this article covers run the following:

-- Author:        Steven M. Swafford
-- Date Created:  23-NOV-2004
-- Create Table(s)
 id number,
 photo BLOB,
 author varchar2(100),
 description varchar2(500)

Now that we have our table established the next step is to create your primary/foreign keys. To accomplish this step run the following SQL statement:

-- Author:        Steven M. Swafford
-- Date Created:  23-NOV-2004
-- Create/Recreate primary, unique and foreign key constraints
alter table SMSTESTBLOB
  add constraint PK_SMSTESTBLOB_ID primary key (ID);

Finally the sequence.

-- Author:        Steven M. Swafford
-- Date Created:  01-DEC-2004
-- Create sequence 
create sequence smstestblobid_seq
minvalue 1
maxvalue 999999999999
start with 1
increment by 1
cache 20

Once you have established your table you will have a schema such as the following.


Now that the database is ready it is now time to transition to the code which will perform the necessary steps to insert our records. The code of choice is C# so sit back and prepare yourself.

View Entire Article

User Comments

Title: Read/Write BLOB data when file > 32K   
Name: Roger Rowe
Date: 2005-03-07 1:03:00 PM
Go see this article:;en-us;322796
This shows you how to insert larger data - your version will die for data larger than 32K - a PLSQL limitation).

Community Advice: ASP | SQL | XML | Regular Expressions | Windows

©Copyright 1998-2019  |  Page Processed at 2019-06-19 7:07:01 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search