[Oracle] display connect by, oracleconnect

Source: Internet
Author: User

[Oracle] display connect by, oracleconnect

 

1. Display by organizational structure relationship

Create or replace view v_vieworg
Select -- v. OBJID, v. OBJNAME
Level as levelid,
Lpad ('', 2 * level-2) | v. OBJNAME as OBJNAME, v. OBJID, v. OBJCODE, v. ISDEPT, v. PARENTAREAID, v. PARENTDEPTID, v. parentID, v. canceled
From v_organddept v
Start with v. OBJID = 100001
Connect by prior v. OBJID = v. ParentID;

 


Usage of oracle connect by and start

Recursive query, which is very effective when the data structure is tree and linked list.
For example, menus and organizations.

Why does the connect by Loop Error in user data prompt during oracle SQL query?

It is estimated that your data is like
The parent of 1 is 2, and the parent of 2 points to 1 again, resulting in an endless loop.

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.