SQL & PL/SQL :: Hierarchical Query For Chart Of Account

Aug 19, 2013

I want Hierarchical Query..I have Table of chart of account

CREATE TABLE COA
(
ACCOUNT_CODE CHAR(19),
ACCOUNT_TITLE VARCHAR2(70),
ACC_TYPE Char(1),
PARENT_CODE CHAR(19)
)
[code]....

View 2 Replies


ADVERTISEMENT

SQL & PL/SQL :: Hierarchical Query To Display Chart Of Account?

Apr 25, 2013

I want Hierarical query to display my Chart_Of_Account. I want to make a tree Form in 6i error i am getting is connect by nocycle prior account_code=parent_code
*
ERROR at line 4:
ORA-00920: invalid relational operator

Table

Create Table Chart_Of_Account (Account_Code Char(19), Account_Title varchar2(70), Parent_Code Char(19))
insert into Chart_Of_Account ('DGHOA01010101000001','TEST','DGHOA01010100000000')
insert into Chart_Of_Account ('DGHOA01010101000002','TEST1','DGHOA01010100000000')
insert into Chart_Of_Account ('DGHOA01010101000003','TEST2','DGHOA01010100000000')

select -1,level,account_code||' - '||ACCOUNT_Title,'NULL',to_char(ACCOUNT_CODE)
connect_by_iscycle from chart_of_account
start with Substr(account_code,13,7)='0000000'
connect by nocycle prior account_code=parent_code

View 3 Replies View Related

Get Different Level Using Hierarchical Query In Sql?

Jan 27, 2009

I'm trying to get different level using hierarchical query in sql.my table is

item_id child_item_id
------------------------------
p21 p25
p21 p22
p22 p23
p22 p24
p25 p27
p25 p26
p27 p28
p27 p29
p30 p31
p30 p32

I want to display result with respective levels.
for example p21 ,p30 are coming under first level .
p22,p25 ,P31,P32are 2nd level.
p23,p24,p26,p27 are 3rd level
p28,p29 are FOURTH level item_id's.

Already I 'VE tried using CONNECT BY PRIOR clause.BUT STILL I COULDN'T GET THE RESULT.

View 2 Replies View Related

SQL & PL/SQL :: Hierarchical Query With Many-to-many Dependencies?

Apr 22, 2010

I have a hierarchical data structure where a child can have many parents, and a parent can have many childs.See the attached file hierarchy_iliustration.jpg. This example has 4 hierarchy levels, in real problem there can be unlimited number of levels.I want to write a SQL query that lists all indirectly dependent child nodes for a given parent node.

Test structure for example attached:

CREATE TABLE TEST.NODE_T
(
ID NUMBER PRIMARY KEY,
TEXTAS VARCHAR2(254)
);

[code]....

View 5 Replies View Related

How To Count Siblings In A Hierarchical Query

Sep 24, 2012

How to count siblings in a hierarchical query? I'm trying to get a listing of employees

SELECT LEVEL, last_name||', '||first_name AS Manager, count(employee_id)
FROM employees
START WITH manager_id IS NULL
CONNECT BY PRIOR employee_id = manager_id
GROUP BY level

This returns 4 levels. I'm wanting to add up the number of siblings under the level 2 instead of listing them all.

View 1 Replies View Related

SQL & PL/SQL :: Hierarchical Query To Get Metadata Information?

Mar 5, 2010

i'm trying to display the heirarichal relationship between the tables (parents-child-subchild).

[b]table structure[/b]
DEPT
|PK-DEPT_ID
|
EMP
|pk-EMP_ID

[code]....

Expected output

table_name path
DEPT DEPT
EMP DEPT/EMP
EMP_AUTHORIZATION DEPT/EMP/EMP_AUTHORIZATION
EMP_AUTHRIZATION_CARD DEPT/EMP/EMP_AUTHORIZATION/EMP_AUTHRIZATION_CARD
EMP_AUTHRIZATION_DUP DEPT/EMP/EMP_AUTHORIZATION/EMP_AUTHRIZATION_CARD/EMP_AUTHRIZATION_DUP

but by using below query i am getting complete heirarichy.

SELECT LEVEL,
Table_Name,
Constraint_Name,
R_Constraint_Name ,
SYS_CONNECT_BY_PATH(Table_Name, '/') Path

[code]....

View 6 Replies View Related

SQL & PL/SQL :: Create Table Hierarchical Query?

Apr 24, 2010

Below query. Below is the DDL , DML and expected output.

create table tab_1 (col1 varchar2(10), col2 varchar2(10));
select * from tab_1

Output of query
col1 col2
12
23
34

[code]...

The above query is not giving below expected output.

Output:
4 4/3/2/1
3 3/2/1
7 7/6/5
8 8/7/6/5
11 11/10/9

View 6 Replies View Related

PL/SQL Hierarchical Query - Select Data In Specific Way

Apr 19, 2013

I have a table that has hierarchical data within it. I need to select this data in a specific way, showing the hierarchy.

E.g. Data in table (Key is unique)

Lvl KeyParKey HasChild
1k101
1k200
1k301
1k401
2k34k10
2k22k11
2k24k10
2k13k30
2k52k30
2k35k30
2k13k30
2k11k40
3k56k220
3k109k221
3k67k220
4k61 k1090
Etc etc....

That�s generally the format the values would appear in the table if I just did a standard select. I want it displayed in a more hierarchical Parent � child way.

The format I need to get out is as follows:
Lvl KeyParKey hasCh
1k101
2k34k10
2k22k11
3k56k220
3k109k221
4k61 k1090
3k67k220
2k24k10
1k200
1k301
2k13k30
2k52k30
2k35k30
2k13k30
1k401
2k11k40

View 1 Replies View Related

PL/SQL :: Hierarchical Query To Select Data From One Table?

Sep 7, 2012

Here is my case,

create table t (id number,row_id number primary key ,value number);ID   row_id value
1     1     10
1     2     11
1     3     1
2     4     11
3     5     11
3     6     12
4     7     12
4     8     12
4     9     13
4     10     11
4     11     10Requirement is

1) To get all the ID that have the value 10

2) The row_ids for the ID I got in I

Can I do this with Hierarchical query. If not which one of below will be fast?

select * from t where id  in (select id from t where value=10);

or

select T2.* from t T1, t T2 where T1.ID=t2.id and T1.VALUE=10;

I have billion of rows so I am looking for either Hierarchical query to solve it or some other way . All the three column the index.

View 5 Replies View Related

Optimizer Behavior With Hierarchical Query And A Join?

Jul 23, 2013

The full statement is:

SELECT v.key$ FROM VERSION_TABLE v, DOCUMENT_TABLE d, CLASS_TABLE z WHERE
v.documentKey = d.key$ AND
d.classKey = z.key$ AND
z.key$ IN (SELECT zz.key$ FROM CLASS_TABLE zz
START WITH zz.name = 'esDTTemplate'
CONNECT BY PRIOR zz.key$ = zz.parentKey) AND
v.ESGROUP = 'SearchOperatorsMapping' ORDER BY d.name

Now I noticed that the subquery is never used to seed the join: indexes - if any - are used. Otherwise a full table scan is performed.In the example - if ESGROUP is indexed, then it's chosen to start the join evaluation. If not, a full table scan is performed.Is there any way to suggest to the optimizer to use the subquery in case there are no indexes - as a fallback ?

In the above example where VERSION_TABLE contains nearly two million records, the no index solution takes 60 secs. vs. less than 1 sec. in the index case.Wrapping the hierarchical query in a inline view leads to same result.


PS: the execution plan (without index) is:
-------------------------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time
-------------------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | | | 9 (100)| |
| 1 | SORT ORDER BY | | 1 | 171 | 9 (23)| 00:00:01 |
|* 2 | HASH JOIN SEMI | | 1 | 171 | 8 (13)| 00:00:01 |

[code]...

View 3 Replies View Related

Sys Account Locked And System Account Is Already Deleted

Jun 5, 2013

In event of sys account locked and system account is already deleted also no other user is having dba privilege, how to unlock the sys user??

View 5 Replies View Related

Application Express :: Separate Link For Each Series On Multiple Series Bar Chart From One Query

May 13, 2013

I have a query that selects multiple series for a bar chart (I have defined only one chart series, and have 3 columns selected to represent 3 series). The series display on Bar Chart is fine. Now I want to create a separate link target depending on which series is clicked on the chart. I am not able to do this.

View 1 Replies View Related

SQL & PL/SQL :: Hierarchical Query - Connect NON-NULL Rows To Preceding NULL Row

Aug 29, 2012

I have the following query:

select col_1,col_9 from
book_temp b
where b.col_1 is not null
order by to_number(b.col_16)
;

What I want to add is the following:

COL_9
=====
NULL
A
B
NULL
C
D
E
F
NULL
G

I need to connect the NON-NULL rows to the preceding NULL row.

View 15 Replies View Related

SQL & PL/SQL :: Hierarchical And With Clause

Jul 31, 2013

>select level ,empno,ename,mgr
from emp
connect by prior empno=mgr
start with mgr is null;

Output:-
>
LEVEL EMPNO ENAME MGR
----- ---------- ---------- ----------
1 7839 KING
2 7566 JONES 7839
3 7788 SCOTT 7566
4 7876 ADAMS 7788
3 7902 FORD 7566
2 7698 BLAKE 7839
3 7499 ALLEN 7698
3 7521 WARD 7698
3 7654 MARTIN 7698
3 7844 TURNER 7698
3 7900 JAMES 7698

LEVEL EMPNO ENAME MGR
----- ---------- ---------- ----------
2 7782 CLARK 7839
3 7934 MILLER 7782

Note:- I got only this that this query is alternative of self join and it is giving manager name along with mgr id for each employee but when it gives output i couldn't able to understand how to identify who is manager of whom. Tell and explain with clause in oracle , i only know it is alternative of inline view but i want to know how does it work and how to use 'WITH' in oracle query if possible.

View 4 Replies View Related

PL/SQL :: Tables Of Hr Account

Jun 1, 2013

here is my current Oracle version:

select * from v$version where banner like 'Oracle%'

BANNER                                                                         
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production   
1 row selected.

My need is to pass test cases based on Oracle XE tables (hr account). tell me where to get the structure of mentioned tables and its data (without downloading and installing Oracle XE if possible).

View 1 Replies View Related

Read Only Access Account For OEM?

Jun 3, 2013

What privilege needs to give the user for ready only access for OEM for limited instances not all instances.

Purpose: our application dba team just want monitor the specific databases that why they asked to create read only access account for OEM for limited databases.

View 2 Replies View Related

SQL & PL/SQL :: Hierarchical Retrieving With Cycles

Sep 29, 2011

first of all sample data;

create table test_circular_data(c1 varchar2(10),c2 varchar2(10));
insert into test_circular_data values ('c1','l2');
insert into test_circular_data values ('c1','l3');
insert into test_circular_data values ('c3','l3');
insert into test_circular_data values ('c4','l3');

commit;

There is a circular relation between columns c1 and c2, so what I'm trying to retrieve is something like that :

c1--> l2 --> l3 --> c3 --> c4

The steps to get that result is :

1.- c1 related to l2 : c1-->l2
2.- c1 related to l3 : c1-->l2-->l3
3.- l3 in the list and related to c3 : c1-->l2-->l3-->c3
4.- l3 in the list and related to c4 : c1-->l2-->l3-->c3-->c4

View -1 Replies View Related

Forms :: Hierarchical Tree In 6i

Dec 24, 2012

Hierarchical Tree in oracle form 6i .i am trying to build tree in form 6i but it give error

SELECT 1,
level,
job
,
'',
ename
FROM emp
START WITH mgr IS NULL
CONNECT BY PRIOR empno = mgr
order by level

i want to show job wise employees ...

View 4 Replies View Related

SQL & PL/SQL :: First Created Contact To Account?

Jun 3, 2011

I'm trying to write a query where I grab the first contact created of an account. I've tried everything but I can't get this to work.

Here is the normal query we used to get the contacts from an account:

select
con.row_id,
con.created,
con.fst_name,
con.last_name,
con.email_addr
from s_contact con
join s_org_ext org
on org.row_id = con.pr_dept_ou_id

I've tried different variation of aggregate functions, but its not working.

View 5 Replies View Related

SQL & PL/SQL :: Update Hierarchical Relation

Nov 13, 2011

I have a table which contains the connectivity details. It is telecom data. The table contains the relation between the point features(Ex: Terminal) and linear features(Ex: Cable)

Below is some sample data

drop table connectivity ;
create table connectivity
(
ftr_no number(5),
ftr_id number(5),

[Code]...

-- 2nd linear ftr

insert into connectivity values (30,10359,33, 9655, 2,NULL,NULL);
insert into connectivity values (30,10359,33, 9656, 1,NULL,NULL);
insert into connectivity values (30,10359,30, 10359,3,NULL,NULL);

[Code]...

In the connectivity table PARENT_FTR_NO and PARENT_FTR_ID needs to be updated based on these conditions.

1. Correspponding to each feature there are 3 entries in this table.

2. Each feature(Point orLinear) has 2 sides INcoming and OUTgoing

3. The possible values for the RELATION column are 1, 2 and 3 where

-> 1 indicates feature conncted at the OUTgoing end
->2 indicates features connected at the INcoming end
->3 indicates self connected

4. Always a linear feature is the parent of a point feature which are connected to the OUTgoing end of the linear feature (i.e where RELATION = 1)

There is another table which contains FEATURE_NO and FEATURE_TYPE.

create table ftr_catgry
(
ftr_no number(5),
ftr_type char(1)
);

[Code]...

FTR_NO F
---------- -
33 P
31 L
30 L

Where
'L' represents linear feature
'P' represents point feature

The relation should be updated as

Step 1. Start with a linear feature, for example FTR_NO = 31

SQL> select * from connectivity where ftr_no = 31 and ftr_id = 10354 and relation = 1;

FTR_NO FTR_ID CONNECTED_FTR_NO CONNECTED_FTR_ID RELATION PARENT_FTR_NO PARENT_FTR_ID
---------- ---------- ---------------- ---------------- ---------- ------------- -------------
31 10354 33 9651 1

The feature connected to the OUTend of the 10354 i 9651 with FTR_NO = 33 and it is a point feature so the parent for 9651 is 10354

Step 2.

SQL> select * from connectivity where ftr_no = 33 and ftr_id = 9651 and relation = 1;

FTR_NO FTR_ID CONNECTED_FTR_NO CONNECTED_FTR_ID RELATION PARENT_FTR_NO PARENT_FTR_ID
---------- ---------- ---------------- ---------------- ---------- ------------- -------------
33 9651 33 9652 1

9652 is connected to 9651 at the OUTend, since 9651 is point feature so the parent of 9651 which is a linear feature is also the parent for 9652

Likewise the all relations have to be updated

Expected result after update

SQL> select * from connectivity;

FTR_NO FTR_ID CONNECTED_FTR_NO CONNECTED_FTR_ID RELATION PARENT_FTR_NO PARENT_FTR_ID
---------- ---------- ---------------- ---------------- ---------- ------------- -------------
31 10354 33 9650 2
31 10354 33 9651 13110354
31 10354 33 10354 3
33 9651 31 10354 2
33 9651 33 9652 13110354
33 9651 33 9651 3
33 9652 33 9651 2

[Code]...

24 rows selected.

View 2 Replies View Related

SQL & PL/SQL :: Display All Account Code

Dec 8, 2012

I want to display all account Code but i required this account PFKHR01010101010001 to be fixed to have Credit_Amount.

My Structure is

Finance_TRansactions
------------------------------

D_No Char(12);
Account_Code Char(19);
D_Date Date;
DEbit_Amount Number;
Credit_Amount Number;
[code]...

ORA-01427: single-row subquery returns more than one row

View 5 Replies View Related

Hierarchical Retrieval Concept

Oct 20, 2010

Any links on hierarchical retrieval concepts?

View 3 Replies View Related

PL/SQL :: Hierarchical Data Maintenance

Aug 27, 2013

I have a table (Parent - Child).There is a requirement to maintain this table, thats the hierarchy of the oraganisation.So, every quater they will be updating the table. They will be importing the data through an excel and in that excel there are 3 action items,

=> Insert, Update and Delete (logical delete). 
CREATE TABLE PARENT_CHILD_TBL   ( "ID" VARCHAR2(6 BYTE) NOT NULL ENABLE, "ID_DESC" VARCHAR2(200 BYTE), "ID_LEVEL" VARCHAR2(200 BYTE), "PARENT_ID" VARCHAR2(200 BYTE)   )  

For Update:What all validation can come for an updation of an hierarchical data in general.Like = how to derive the level value at database side when the id is updated to some other level.= How to maintain the relation. A -> B -> D ( A is the grand parent here).A -> Ceg: if B is updated as parent node of A, then we should throw error (cyclic data). Any more validations for hierarchical data

View 6 Replies View Related

Get AccountItems That Has Max Revenue For Each Account

Aug 22, 2010

I been working on this for days but I just cannot get it working...I have 3 tables:

1- Account
2- AccountItems
3- AccountInfo

Account has many AccountItems and has only 1 AccountInfo.So the point is to get the Account tems that has the max revenue for each Account. The field for revenue is AccountItems.Revenue..So here's what I did

Select Account.Name, Account.Telno, AccountItems.Item, AccountInfo.FirstName, AccountInfo.LastName
where Account.ID = AccountItems.ID
AND AccountItems.ID = AccountInfo.ID
AND ????
From Account, AccountInfo, AccountItems;

This is where I'm stucked on...I don't know what to do in order to grab the AccountItems.Item that has the MAX AccountItems.Revenue.

View 2 Replies View Related

Oracle Linux Account

Oct 22, 2012

I have installed oracle enterprise linux 6.2 on my laptop, and I installed the database 11gR2 on it, know the user account I used to log in with (os level) is not accessible any more :

[URL].........

if I remove the account and recreate it does it will cause problems to the database?

View 5 Replies View Related

Application Express :: Tooltip For Pie Chart?

Oct 26, 2013

I have a 2D pie chart. The chart takes the column names as label and shows the results(3)  like passed--4, failed--3, on hold ---6.  Now I want to have tooltip  , if I point on passed--4, it should show  "number of students passed  last year"similarlyIf I point on failed--3, it should show  "number of students failed  last year"

View 1 Replies View Related

SQL & PL/SQL :: Table Instance Chart Not Working?

Oct 21, 2012

Whenever you're trying to create a table instance chart, and if theres 3 primary keys(composite keys). Do u put in the table instance chart as PK1, PK2, PK3 for the 3 primary keys?

And also if theres 2 foreign keys in the table, do u put in as FK1, FK2 on their key types?

View 7 Replies View Related

SQL & PL/SQL :: Retrieve Hierarchical Data From Same Table

Nov 10, 2011

Look into the below table:

TABLE :- EMPLOYEE
________________________
| ID | SUPERVISOR |
|_______________________|
| A101 | B102 |
|________|______________|
| | |
| B102 | C104 |
|________|______________|
| | |
| C104 | D108 |
|________|______________|
| | |
| D108 | E104 |
|________|______________|

Here B102 is supervisor of A101 and C104 is supervisor of B102 and so on. I want to get this data into new table in below format

TABLE :- Hierarchy
________________________________________________________________
| ID |SUPERVISOR_1 |SUPERVISOR_2 |SUPERVISOR_3 |SUPERVISOR_4|
|______________________|_____________|_____________|____________|
| A101 | B102 | C104 | D108 | E104 |
|________|_____________|_____________|_____________|____________|
| | | | | |
| B102 | C104 | D108 | E104 | NULL |
|________|_____________|_____________|_____________|____________|
| | | | | |
| C104 | D108 | E104 | NULL | NULL |
|________|_____________|_____________|_____________|____________|
| | | | | |
| D108 | E104 | NULL | NULL | NULL |
|________|_____________|_____________|_____________|____________|
| | |
| E104 | NULL | NULL NULL NULL
|________|_____________|_____________|_____________|____________|

I want to insert 1st two rows into Hierarchy table, then I would like to update Supervisor_2 to Supervisor_4. Here I don't want to use 'CONNECT BY PRIOR', as it take more time to execute (there are millions of records).SQL code for same.

View 7 Replies View Related

Server Administration :: DBMS_JOB Using Sys Account

Jun 17, 2010

I have to change the execution of a job, I have the sys access.The job is in another user, say scott.how to use dbms_change using sys account to change the execution of a job in Scott user..

View 9 Replies View Related

SQL & PL/SQL :: Display Hierarchical Relationship Between Tables?

Mar 5, 2010

i'm trying to display the hierarchical relationship between the tables (parents-child-subchild).

[b]table structure[/b]
DEPT
|PK-DEPT_ID
|
EMP
|pk-EMP_ID
|fK emp_DEPT_fK((FK column is dept_id references dept table dept_id column))

[code]....

but by using below query i am not getting complete heirarichy.

SELECT LEVEL,
Table_Name,
Constraint_Name,
R_Constraint_Name ,
SYS_CONNECT_BY_PATH(Table_Name, '/') Path

[code]....

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved