In oracle 11g (SQL or PL/SQL), for chart of accounts I want to generate numbers like: start from level 2: (level 1 a/c nos. are 1,2,3,4,5)
if it is in head 1 which is Asset then it will generate First number as 101 if it is in head 2 which is Liability then it will generate First number as 201
for level 3;
if parent is selected 101 then it will generate First a/c number as 10101 if parent is selected 102 then it will generate First a/c number as 10201
and so on....
for level 4:
if the parent is selected 10101 then it will generate First a/c number as 10101001 if the parent is selected 10201 then it will generate First a/c number as 10201001
and so on...
and same for all rest of head accounts ( 2=Liability, 3=Expense, 4=Revenue 5=Capital)
Please help.
The query below generates almost 4000 accounts using the account structure you defined. You can adjust the number of accounts generated by modifying
CONNECT BY LEVEL <= 5
and changing5
to a lower or higher number innum_accts_to_generate
.Query
Result