Java ibatis transfers the stored procedure of Oracle passing in clob Parameters

Source: Internet
Author: User
Tags sendmsg

I tried a few and came to the conclusion:

Java program, you cannot directly use ibatis to mobilize Oracle to pass the stored procedure of the clob parameter, but you can only insert the clob parameter into the database table field, you can directly input the string parameter when inserting, so, the title should be resolved as follows:

1. Insert the clob field into the temporary table with the clob field in the database.

2. Retrieve and use the clob field from the table during the stored procedure.

My code is as follows:

Create an Oracle database table:

create table t_temp_sendbatchfj(rightcodes clob,errorcodes clob,clientid varchar2(20),mainid varchar2(20));

Java code (erroecodes and rightcodes are both clob fields to be used, and Oracle clob fields can be imported directly by passing the string type when passing in from ibatis ):

Map p_pro = new hashmap (); // Since Java cannot call the stored procedure of in_clob, insert clob into the table first, then, retrieve the clob from the table for the stored procedure to use p_pro.put ("errorcodes", errorcodes. tostring (); p_pro.put ("rightcodes", rightcodes. tostring (); p_pro.put ("clientid", (string) p. get ("clientid"); p_pro.put ("mainid", (string) p. get ("mainid"); Dao. getsqlmapclienttemplate (). insert ("sendmsg. sendbatchfj_insert ", p_pro); // call the table sharding Stored Procedure Dao. getsqlmapclienttemplate (). update ("sendmsg. proc_p_sendbatch1 ", p_pro );

<! -- Batch logistics version table sharding stored procedure: revoke public synonym pk_busi_core; grant execute on pk_busi_core to yxclient; Create public synonym pk_busi_core for example --> <insert id = "comment" parameterclass = "Java. util. map "> insert into t_temp_sendbatchfj (rightcodes, errorcodes, clientid, mainid) values (# rightcodes #, # errorcodes #, # clientid #, # mainid #) </Insert> <update id = "proc_p_sendbatch1" parameterclass = "Java. util. map "> {call p_sendbatch1 (# clientid #, # mainid #)} </update>

Clob usage in stored procedures:

Create or replace procedure p_sendbatch1 (in_clientid in varchar2, in_mainid in varchar2) -- clientid is used in the number of reverse entries, and mainid is used as in_right clob when checking the correct error ID; in_error clob; begin select errorcodes, rightcodes into in_error, in_right from t_temp_sendbatchfj where mainid = in_mainid ;.... -- delete clob Delete from t_temp_sendbatchfj where mainid = in_mainid; end;
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.