Oracle String concatenation

Source: Internet
Author: User
Createorreplaceprocedureproc_query_prior_departmentisCursordepartment_list_nosubisselectdep.id, dep. name, dep. paren

Create or replace procedure proc_query_prior_departmentisCursor department_list_nosub isselect dep. id, dep. name, dep. paren

Create or replace procedure proc_query_prior_department
Is

Cursor department_list_nosub is
Select dep. id, dep. name, dep. parent from department dep where org_id = 7;
Union_mc varchar2 (200 );

Begin

Delete from ma_department_role;
Commit;
For varDep in department_list_nosub loop

For cur in (select t. parent, t. name from department t start with t. id = varDep. id connect by prior t. parent = t. id order by t. id asc) loop
If cur. parent is not null then

If (union_mc is null) then
Union_mc: = cur. name;
Else
Union_mc: = union_mc | '/' | cur. name;
End if;
End if;
End loop;
Insert into ma_department_role (id, name) values (varDep. id, union_mc );
Union_mc: = null;
End loop;
Commit;

End;

,

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.