Connect by prior start)

Source: Internet
Author: User


Connect by prior start with is often used when a table has a recursive relationship. For example, we often store a complex directory tree in a table. You can also store some departments in a table, and these departments are affiliated with each other. In this case, you will use connect by prior start. The typical method is: www.2cto.com select * from table connect by prior cur_id = parent_id start with cur_id = ??? For example: a b1 02 13 14 25 3 if you want to search for all the data in a = 2 and below, then: select * from table connect by prior a = B start with a = 2a b2 14 2 these are just the basics. In fact, as long as you flexibly construct query statements. Unexpected results can be obtained. For example, every path in the tree is generated. However, the tree composed of these records must be normal. If there is a parent-child relationship, a loop error occurs! Select * from tb_cus_area_cde -- Obtain the parent select * from tb_cus_area_cde a connect by prior. c_snr_area =. c_area_cde start with. c_area_cde = '000000' -- the parent selects the sub-select * from tb_cus_area_cde a connect by prior. c_area_cde =. c_snr_area start with. c_snr_area is null Note: when using this function, the statement parameter must use ResultSet. TYPE_SCROLL_INSENSITIVE instead of ResultSet. TYPE_SCROLL_SENSITIVE: 1. TYPE_FORWORD_ONLY, which can be rolled forward only; 2.TY PE_SCROLL_INSENSITIVE, two-way scrolling, but not timely updating, is that if the data in the database has been modified, it is not reflected in the ResultSet. 3. TYPE_SCROLL_SENSITIVE, two-way scrolling, and timely tracking of database updates, in order to change the data in the ResultSet.

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.