Let's take a look at system. Data. oracleclient to call the stored procedure with blob, clob, and other big field parameters!

Source: Internet
Author: User

System. Data. oracleclient has a 32 K size limit when inserting large fields. Some methods of network collection are as follows (Microsoft enterprise database example ):

The transaction must begin before obtaining the temporary lob. Otherwise,OracledatareaderThe following data cannot be obtained.

You can also call the dbms_lob.createtemporary system stored procedure and bind the lob output parameter to open the temporary lob in Oracle. On the client side, temporary lob acts like a table-based lob. For example, to update a temporary lob, it must be included in the transaction.

 
Dbms_lob.createtemporary (lob_loc in out nocopy {blob | clob Character Set any_cs}, cache in Boolean, duration in pls_integer: = dbms_lob.session)

Create a stored procedure and assume a full-time role in the system, it is responsible for converting the big text data submitted by the user to the big field storage (I don't know if this is the case !)

Create or replace procedure proc_create_tmp_clob (p_tmp_clob out clob)IsBeginDbms_lob.createtemporary (p_tmp_clob, false, 0 );End proc_create_tmp_clob;

In this way,ProgramThe Section transmits large text or HTML text snippets to the Oracle database!

Let's take a simple example-(add product details. The product details are HTML clips)

Create a sharing method for processing big field data first. Just do the following!

 Public     Static  Oraclelob tobyte ( Object  Tmplob,  String  Content)
{
Try
{
Oraclelob templob = (Oraclelob) tmplob;

System. Text. Encoding ENC = System. Text. encoding. Unicode;

Byte [] B = ENC. getbytes (content );

Templob. beginbatch (oraclelobopenmode. readwrite );
Templob. Write (B, 0 , B. Length );
Templob. endbatch ();

Return Templob;
}
Catch (Exception ex)
{
Throw Ex;
}
}
 

Public Static Oraclelob converttolob (dataaccess Da, String Content)
{
Try
{
If (Da. OC. State = Connectionstate. Closed)
{
Da. OC. open ();
}
Oracleparameter mtemplob = New Oracleparameter ( " P_tmp_clob " , Oracletype. clob );
Mtemplob. Direction = Parameterdirection. output;


Tools. oraclehelper. executenonquery (DA. oC,
Commandtype. storedprocedure,
" Proc_create_tmp_clob " ,
Mtemplob );


If (Content = Null | Content = "" )
Return (Oraclelob) mtemplob. value;
Return Tobyte (mtemplob. Value, content );
}
Catch (Exception ex)
{
Throw Ex;
}
}
}
 
Oracleparameter mdesc=New oracleparameter ("p_goods_desc", oracletype. clob );
Mdesc. Value=Data. Tools. oraclelobhandler. converttolob (DA, goods.Desc. Description );

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.