Processing of the in clause in PreparedStatement

Source: Internet
Author: User

Testing environment for processing the in clause in PreparedStatement: Oracle 10g 1. principle 1 select * from table (split ('a, B, C') Result: 1a2b3c2. conclusion For example: 1 select * from xxx_table where xxx_column in ('xxa', 'xxb', 'xxc ') you can dynamically input the in Clause parameter 1 select * from xxx_table where xxx_column in (select * from table (split (?))) 1 PreparedStatement stmt = conn. prepareStatement (SQL); 2stmt. setObject (1, "xxa, xxb, xxc"); attached split function: 01 create or replace type split_tbl as table of varchar (32767 ); 02/03 04 create or replace function split05 (06 p_list varchar2, 07 p_del varchar2: = ', '08) return split_tbl pipelined09is10 l_idx pls_integer; 11 l_list varchar2 (32767): = p_list; 12 l_value varchar2 (32767); 13begin14 loop15 l_idx: = instr (l_list, p_del); 16 if l_idx> 0 then17 pipe row (substr (l_list, 1, l_idx-1 )); 18 l_list: = substr (l_list, l_idx + length (p_del); 19 else20 pipe row (l_list); 21 exit; 22 end if; 23 end loop; 24 return; 25end split; 26/

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.