Hierarchical queries for subnets

I need to write a hierarchical query for quite a number of (contiguous groups of IP addresses) IP subnets. What I'm hoping to do, is let the database do the bulk of the work here and I will not need to write code to do this. I'll do that if I have to but I would really rather not.

General information may be in order for those who do not know subnets. IP subnets have unique characteristics, based on network management standards (caveat: I'm not a guru/subnet on the network, but I know enough to be dangerous). The first thing to know is that a subnet is a contiguous block of IP addresses that help define the IP network protocol. Another thing is that an IP address can be converted to a binary or decimal/numeric value. This is useful because it can take us out of the sphere of analysis of strings and comparing a group of text values, which will eventually be converted to numbers in order to make meaningful comparisons anyway.

The result is that subnets can be defined by digital upper and lower limits. And the trick here is that some of these blocks of IP addresses live in the other blocks. Look at the data below and I'll explain if you need. In addition, the network address is the lower limit of the subnet and dissemination is the upper limit. This is a create table and examples of data from my dataset where you can see the IP addresses and name of each subnet and numeric limits for each subnet.

CREATE TABLE "SUBNET_DECIMAL_VALS" 
   (    
    "SUBNET" VARCHAR2(4000 BYTE), 
    "CIDR_BLOCK" VARCHAR2(30 BYTE), 
    "NETWORK" VARCHAR2(4000 BYTE), 
    "BROADCAST" VARCHAR2(4000 BYTE), 
    "NETWORK_DEC" NUMBER, 
    "BROADCAST_DEC" NUMBER
   ) ;

Insert into SUBNET_DECIMAL_VALS (SUBNET,CIDR_BLOCK,NETWORK,BROADCAST,NETWORK_DEC,BROADCAST_DEC) values ('128.110.0.0/20','/20','128.110.0.0','128.110.15.255',2154692608,2154696703);
Insert into SUBNET_DECIMAL_VALS (SUBNET,CIDR_BLOCK,NETWORK,BROADCAST,NETWORK_DEC,BROADCAST_DEC) values ('128.110.1.0/24','/24','128.110.1.0','128.110.1.255',2154692864,2154693119);
Insert into SUBNET_DECIMAL_VALS (SUBNET,CIDR_BLOCK,NETWORK,BROADCAST,NETWORK_DEC,BROADCAST_DEC) values ('128.110.4.0/22','/22','128.110.4.0','128.110.7.255',2154693632,2154694655);
Insert into SUBNET_DECIMAL_VALS (SUBNET,CIDR_BLOCK,NETWORK,BROADCAST,NETWORK_DEC,BROADCAST_DEC) values ('128.110.8.0/22','/22','128.110.8.0','128.110.11.255',2154694656,2154695679);
Insert into SUBNET_DECIMAL_VALS (SUBNET,CIDR_BLOCK,NETWORK,BROADCAST,NETWORK_DEC,BROADCAST_DEC) values ('128.110.12.0/22','/22','128.110.12.0','128.110.15.255',2154695680,2154696703);
Insert into SUBNET_DECIMAL_VALS (SUBNET,CIDR_BLOCK,NETWORK,BROADCAST,NETWORK_DEC,BROADCAST_DEC) values ('128.110.16.0/21','/21','128.110.16.0','128.110.23.255',2154696704,2154698751);
Insert into SUBNET_DECIMAL_VALS (SUBNET,CIDR_BLOCK,NETWORK,BROADCAST,NETWORK_DEC,BROADCAST_DEC) values ('128.110.16.0/22','/22','128.110.16.0','128.110.19.255',2154696704,2154697727);
Insert into SUBNET_DECIMAL_VALS (SUBNET,CIDR_BLOCK,NETWORK,BROADCAST,NETWORK_DEC,BROADCAST_DEC) values ('128.110.20.0/22','/22','128.110.20.0','128.110.23.255',2154697728,2154698751);
Insert into SUBNET_DECIMAL_VALS (SUBNET,CIDR_BLOCK,NETWORK,BROADCAST,NETWORK_DEC,BROADCAST_DEC) values ('128.110.24.0/22','/22','128.110.24.0','128.110.27.255',2154698752,2154699775);
Insert into SUBNET_DECIMAL_VALS (SUBNET,CIDR_BLOCK,NETWORK,BROADCAST,NETWORK_DEC,BROADCAST_DEC) values ('128.110.28.0/22','/22','128.110.28.0','128.110.31.255',2154699776,2154700799);
Insert into SUBNET_DECIMAL_VALS (SUBNET,CIDR_BLOCK,NETWORK,BROADCAST,NETWORK_DEC,BROADCAST_DEC) values ('128.110.28.0/24','/24','128.110.28.0','128.110.28.255',2154699776,2154700031);
Insert into SUBNET_DECIMAL_VALS (SUBNET,CIDR_BLOCK,NETWORK,BROADCAST,NETWORK_DEC,BROADCAST_DEC) values ('128.110.29.0/24','/24','128.110.29.0','128.110.29.255',2154700032,2154700287);
Insert into SUBNET_DECIMAL_VALS (SUBNET,CIDR_BLOCK,NETWORK,BROADCAST,NETWORK_DEC,BROADCAST_DEC) values ('128.110.30.0/24','/24','128.110.30.0','128.110.30.255',2154700288,2154700543);
Insert into SUBNET_DECIMAL_VALS (SUBNET,CIDR_BLOCK,NETWORK,BROADCAST,NETWORK_DEC,BROADCAST_DEC) values ('128.110.31.0/24','/24','128.110.31.0','128.110.31.255',2154700544,2154700799);

SELECT * FROM SUBNET_DECIMAL_VALS
subnet            cidr   network          broadcast        network_dec   broadcast_dec
128.110.0.0/20    /20    128.110.0.0      128.110.15.255   2154692608    2154696703
128.110.1.0/24    /24    128.110.1.0      128.110.1.255    2154692864    2154693119
128.110.4.0/22    /22    128.110.4.0      128.110.7.255    2154693632    2154694655
128.110.8.0/22    /22    128.110.8.0      128.110.11.255   2154694656    2154695679
128.110.12.0/22   /22    128.110.12.0     128.110.15.255   2154695680    2154696703
128.110.16.0/21   /21    128.110.16.0     128.110.23.255   2154696704    2154698751
128.110.16.0/22   /22    128.110.16.0     128.110.19.255   2154696704    2154697727
128.110.20.0/22   /22    128.110.20.0     128.110.23.255   2154697728    2154698751
128.110.24.0/22   /22    128.110.24.0     128.110.27.255   2154698752    2154699775
128.110.28.0/22   /22    128.110.28.0     128.110.31.255   2154699776    2154700799
128.110.28.0/24   /24    128.110.28.0     128.110.28.255   2154699776    2154700031
128.110.29.0/24   /24    128.110.29.0     128.110.29.255   2154700032    2154700287
128.110.30.0/24   /24    128.110.30.0     128.110.30.255   2154700288    2154700543
128.110.31.0/24   /24    128.110.31.0     128.110.31.255   2154700544    2154700799

What I tried to do is a hierarchical query traditional and used more than and less than the comparisons in the where clause. I'm trying to find the limits of subnet (top and bottom numbers) that match among other numerical limits. This is an example, and it gives me the results I need.

select level, subnet, cidr_block cidr, network, broadcast, network_dec, broadcast_dec
from poc_subnet_decimal_vals
connect by nocycle prior network_dec > network_dec and broadcast_dec < broadcast_dec

Do I have to create from this, it is something like this:

Level    Subnet           CIDR    Network        Broadcast         Network_Dec   Broacast_Dec
1        128.110.0.0/20    /20    128.110.0.0    128.110.15.255    2154692608    2154696703
2        128.110.1.0/24    /24    128.110.1.0    128.110.1.255     2154692864    2154693119
2        128.110.4.0/22    /22    128.110.4.0    128.110.7.255     2154693632    2154694655
2        128.110.8.0/22    /22    128.110.8.0    128.110.11.255    2154694656    2154695679
2        128.110.12.0/22   /22    128.110.12.0   128.110.15.255    2154695680    2154696703
1        128.110.16.0/21   /21    128.110.16.0   128.110.23.255    2154696704    2154698751
2        128.110.16.0/22   /22    128.110.16.0   128.110.19.255    2154696704    2154697727
2        128.110.20.0/22   /22    128.110.20.0   128.110.23.255    2154697728    2154698751
2        128.110.24.0/22   /22    128.110.24.0   128.110.27.255    2154698752    2154699775
2        128.110.28.0/22   /22    128.110.28.0   128.110.31.255    2154699776    2154700799
3        128.110.28.0/24   /24    128.110.28.0   128.110.28.255    2154699776    2154700031
3        128.110.29.0/24   /24    128.110.29.0   128.110.29.255    2154700032    2154700287
3        128.110.30.0/24   /24    128.110.30.0   128.110.30.255    2154700288    2154700543
3        128.110.31.0/24   /24    128.110.31.0   128.110.31.255    2154700544    2154700799

Once, I get a hierarchical query of good work I can do the rest of the formatting with the values of the path and CYCLE but I'm not able to get a basic querying work. Does anyone have an idea of how to go on this subject using SQL only? I can write a PL/SQL procedure to add an ID of parent to each row, and then I know that I can create a hierarchical query from that but I was trying to avoid this method if possible.

Hello

Earl Lewis wrote:

I need to write a hierarchical query for quite a number of (contiguous groups of IP addresses) IP subnets. What I'm hoping to do, is let the database do the bulk of the work here and I will not need to write code to do this. I'll do that if I have to but I would really rather not.

General information may be in order for those who do not know subnets. IP subnets have unique characteristics, based on network management standards (caveat: I'm not a guru/subnet on the network, but I know enough to be dangerous). The first thing to know is that a subnet is a contiguous block of IP addresses that help define the IP network protocol. Another thing is that an IP address can be converted to a binary or decimal/numeric value. This is useful because it can take us out of the sphere of analysis of strings and comparing a group of text values, which will eventually be converted to numbers in order to make meaningful comparisons anyway.

The result is that subnets can be defined by digital upper and lower limits. And the trick here is that some of these blocks of IP addresses live in the other blocks. Look at the data below and I'll explain if you need. In addition, the network address is the lower limit of the subnet and dissemination is the upper limit. This is a create table and examples of data from my dataset where you can see the IP addresses and name of each subnet and numeric limits for each subnet.

  1. CREATE TABLE 'SUBNET_DECIMAL_VALS '.
  2. (
  3. VARCHAR2 (4000 BYTE) "SUBNET."
  4. VARCHAR2 (30 BYTE) "CIDR_BLOCK."
  5. VARCHAR2 (4000 BYTE) 'NETWORK ',.
  6. "BROADCASTING" VARCHAR2 (4000 BYTE),
  7. NUMBER OF "NETWORK_DEC."
  8. NUMBER OF 'BROADCAST_DEC '.
  9. ) ;
  1. Insert into SUBNET_DECIMAL_VALS (subnet, CIDR_BLOCK, NETWORK, BROADCAST, NETWORK_DEC, BROADCAST_DEC) values ('128.110.0.0/20','/20','128.110.0.0','128.110.15.255',2154692608,2154696703);
  2. Insert into SUBNET_DECIMAL_VALS (subnet, CIDR_BLOCK, NETWORK, BROADCAST, NETWORK_DEC, BROADCAST_DEC) values ('128.110.1.0/24','/24','128.110.1.0','128.110.1.255',2154692864,2154693119);
  3. Insert into SUBNET_DECIMAL_VALS (subnet, CIDR_BLOCK, NETWORK, BROADCAST, NETWORK_DEC, BROADCAST_DEC) values ('128.110.4.0/22','/22','128.110.4.0','128.110.7.255',2154693632,2154694655);
  4. Insert into SUBNET_DECIMAL_VALS (subnet, CIDR_BLOCK, NETWORK, BROADCAST, NETWORK_DEC, BROADCAST_DEC) values ('128.110.8.0/22','/22','128.110.8.0','128.110.11.255',2154694656,2154695679);
  5. Insert into SUBNET_DECIMAL_VALS (subnet, CIDR_BLOCK, NETWORK, BROADCAST, NETWORK_DEC, BROADCAST_DEC) values ('128.110.12.0/22','/22','128.110.12.0','128.110.15.255',2154695680,2154696703);
  6. Insert into SUBNET_DECIMAL_VALS (subnet, CIDR_BLOCK, NETWORK, BROADCAST, NETWORK_DEC, BROADCAST_DEC) values ('128.110.16.0/21','/21','128.110.16.0','128.110.23.255',2154696704,2154698751);
  7. Insert into SUBNET_DECIMAL_VALS (subnet, CIDR_BLOCK, NETWORK, BROADCAST, NETWORK_DEC, BROADCAST_DEC) values ('128.110.16.0/22','/22','128.110.16.0','128.110.19.255',2154696704,2154697727);
  8. Insert into SUBNET_DECIMAL_VALS (subnet, CIDR_BLOCK, NETWORK, BROADCAST, NETWORK_DEC, BROADCAST_DEC) values ('128.110.20.0/22','/22','128.110.20.0','128.110.23.255',2154697728,2154698751);
  9. Insert into SUBNET_DECIMAL_VALS (subnet, CIDR_BLOCK, NETWORK, BROADCAST, NETWORK_DEC, BROADCAST_DEC) values ('128.110.24.0/22','/22','128.110.24.0','128.110.27.255',2154698752,2154699775);
  10. Insert into SUBNET_DECIMAL_VALS (subnet, CIDR_BLOCK, NETWORK, BROADCAST, NETWORK_DEC, BROADCAST_DEC) values ('128.110.28.0/22','/22','128.110.28.0','128.110.31.255',2154699776,2154700799);
  11. Insert into SUBNET_DECIMAL_VALS (subnet, CIDR_BLOCK, NETWORK, BROADCAST, NETWORK_DEC, BROADCAST_DEC) values ('128.110.28.0/24','/24','128.110.28.0','128.110.28.255',2154699776,2154700031);
  12. Insert into SUBNET_DECIMAL_VALS (subnet, CIDR_BLOCK, NETWORK, BROADCAST, NETWORK_DEC, BROADCAST_DEC) values ('128.110.29.0/24','/24','128.110.29.0','128.110.29.255',2154700032,2154700287);
  13. Insert into SUBNET_DECIMAL_VALS (subnet, CIDR_BLOCK, NETWORK, BROADCAST, NETWORK_DEC, BROADCAST_DEC) values ('128.110.30.0/24','/24','128.110.30.0','128.110.30.255',2154700288,2154700543);
  14. Insert into SUBNET_DECIMAL_VALS (subnet, CIDR_BLOCK, NETWORK, BROADCAST, NETWORK_DEC, BROADCAST_DEC) values ('128.110.31.0/24','/24','128.110.31.0','128.110.31.255',2154700544,2154700799);
  1. SELECT * FROM SUBNET_DECIMAL_VALS
  2. subnet cidr network network_dec broadcast_dec broadcast
  3. 128.110.0.0/20 20 128.110.0.0 128.110.15.255 2154692608 2154696703
  4. 128.110.1.0/24 24 128.110.1.0 128.110.1.255 2154692864 2154693119
  5. 22 128.110.4.0/22 128.110.4.0 128.110.7.255 2154693632 2154694655
  6. 22 128.110.8.0/22 128.110.8.0 128.110.11.255 2154694656 2154695679
  7. 22 128.110.12.0/22 128.110.12.0 128.110.15.255 2154695680 2154696703
  8. 128.110.16.0/21 21 128.110.16.0 128.110.23.255 2154696704 2154698751
  9. 22 128.110.16.0/22 128.110.16.0 128.110.19.255 2154696704 2154697727
  10. 22 128.110.20.0/22 128.110.20.0 128.110.23.255 2154697728 2154698751
  11. 22 128.110.24.0/22 128.110.24.0 128.110.27.255 2154698752 2154699775
  12. 22 128.110.28.0/22 128.110.28.0 128.110.31.255 2154699776 2154700799
  13. 128.110.28.0/24 24 128.110.28.0 128.110.28.255 2154699776 2154700031
  14. 128.110.29.0/24 24 128.110.29.0 128.110.29.255 2154700032 2154700287
  15. 128.110.30.0/24 24 128.110.30.0 128.110.30.255 2154700288 2154700543
  16. 128.110.31.0/24 24 128.110.31.0 128.110.31.255 2154700544 2154700799

What I tried to do is a hierarchical query traditional and used more than and less than the comparisons in the where clause

. I'm trying to find the limits of subnet (top and bottom numbers) that match among other numerical limits. This is an example, and it gives me the results I need.

  1. Select the level, subnet, cidr_block cidr, broadcast network, network_dec, broadcast_dec
  2. of poc_subnet_decimal_vals
  3. nocycle to connect before network_dec > network_dec and broadcast_dec<>

Do I have to create from this, it is something like this:

  1. Level of subnet CIDR network broadcast Network_Dec Broacast_Dec
  2. 1 20 128.110.0.0/20 128.110.0.0 128.110.15.255 2154692608 2154696703
  3. 2 128.110.1.0/24 24 128.110.1.0 128.110.1.255 2154692864 2154693119
  4. 2 128.110.4.0/22 22 128.110.4.0 128.110.7.255 2154693632 2154694655
  5. 2 128.110.8.0/22 22 128.110.8.0 128.110.11.255 2154694656 2154695679
  6. 2 128.110.12.0/22 22 128.110.12.0 128.110.15.255 2154695680 2154696703
  7. 1 128.110.16.0/21 21 128.110.16.0 128.110.23.255 2154696704 2154698751
  8. 2 128.110.16.0/22 22 128.110.16.0 128.110.19.255 2154696704 2154697727
  9. 2 128.110.20.0/22 22 128.110.20.0 128.110.23.255 2154697728 2154698751
  10. 2 128.110.24.0/22 22 128.110.24.0 128.110.27.255 2154698752 2154699775
  11. 2 128.110.28.0/22 22 128.110.28.0 128.110.31.255 2154699776 2154700799
  12. 3 128.110.28.0/24 24 128.110.28.0 128.110.28.255 2154699776 2154700031
  13. 3 128.110.29.0/24 24 128.110.29.0 128.110.29.255 2154700032 2154700287
  14. 3 128.110.30.0/24 24 128.110.30.0 128.110.30.255 2154700288 2154700543
  15. 3 128.110.31.0/24 24 128.110.31.0 128.110.31.255 2154700544 2154700799

Once, I get a hierarchical query of good work I can do the rest of the formatting with the values of the path and CYCLE but I'm not able to get a basic querying work. Does anyone have an idea of how to go on this subject using SQL only? I can write a PL/SQL procedure to add an ID of parent to each row, and then I know that I can create a hierarchical query from that but I was trying to avoid this method if possible.

This is the right forum. I can see why there is only a single forum for SQL and PL/SQL, but I do not see why they suggest that there are separate forums.

I'm not sure that you understand the problem.  In the ouptu (the line whose number 11) you have

  1. 2 128.110.28.0/22 22 128.110.28.0 128.110.31.255 2154699776 2154700799

I guess this level = 2 means that the row is a child of a few rows, but which?  It was numbered line 7:

  1. 1 128.110.16.0/21 21 128.110.16.0 128.110.23.255 2154696704 2154698751

?  This would mean that the child has a higher than its parent network_dec.

I think you want something like this:

WITH got_parent AS

(

SELECT s. *- or whatever the desired columns

,       (

SELECT MIN (ss.subnet) DUNGEON (DENSE_RANK FIRST ORDER BY ss.broadcast_dec - ss.network_dec)

OF subnet_decimal_vals ss

WHERE ss.network_dec<=>

AND ss.broadcast_dec > = s.broadcast_dec

AND ss.subnet <> s.subnet

) As a parent

OF s subnet_decimal_vals

)

SELECT LEVEL AS lvl

subnet, cidr_block, network, broadcast, network_dec, broadcast_dec

OF got_parent

START WITH parent IS NULL

Parent = subnet PRIOR CONNECTION

;

The result is:

LVL SUBNET NETWORK BROADCAST NETWORK_DEC BROADCAST_DEC CID

--- ---------------- --- ---------------- ---------------- ----------- -------------

1 20 128.110.0.0/20 128.110.0.0 128.110.15.255 2154692608 2154696703

2 128.110.1.0/24 24 128.110.1.0 128.110.1.255 2154692864 2154693119

2 128.110.4.0/22 22 128.110.4.0 128.110.7.255 2154693632 2154694655

2 128.110.8.0/22 22 128.110.8.0 128.110.11.255 2154694656 2154695679

2 128.110.12.0/22 22 128.110.12.0 128.110.15.255 2154695680 2154696703

1 128.110.16.0/21 21 128.110.16.0 128.110.23.255 2154696704 2154698751

2 128.110.16.0/22 22 128.110.16.0 128.110.19.255 2154696704 2154697727

2 128.110.20.0/22 22 128.110.20.0 128.110.23.255 2154697728 2154698751

1 22 128.110.24.0/22 128.110.24.0 128.110.27.255 2154698752 2154699775

1 22 128.110.28.0/22 128.110.28.0 128.110.31.255 2154699776 2154700799

2 128.110.28.0/24 24 128.110.28.0 128.110.28.255 2154699776 2154700031

2 128.110.29.0/24 24 128.110.29.0 128.110.29.255 2154700032 2154700287

2 128.110.30.0/24 24 128.110.30.0 128.110.30.255 2154700288 2154700543

2 128.110.31.0/24 24 128.110.31.0 128.110.31.255 2154700544 2154700799

Close enough to what you have requested, but not exact.  If this isn't what you want, explain how you can tell if a line is one ancestor of the other in the tree.

I guess that this subnet is unique.  If this is not the case, the above query will have to be changed a little, but only a little.

Tags: Database

Similar Questions

  • Hierarchical queries for table of account

    HelloW to all

    I have a Table that's graphic account

    The column of this table is
    Acc_id and Acc_name

    I insert data into this table of account

    Insert into the COA
    values
    * (01, 'ASSETS'); *
    values
    * (01001, 'active'); *
    values
    * (01002, "fixed assets"); *
    values
    * (010010001, 'banks'); *
    values
    * (010010002, "cash"); *
    values
    * (01001000100001, 'Metrol politan Bank'); *
    values
    * (01001000100002, 'Royal Bank'); *
    values
    * (01001000100003, 'stander charted Bank'); *
    values
    * (01001000200001, 'body'); *
    values
    * ('01001000200002, Patty Cash"); *

    This is my case, now I need to create a hierarchical tree

    That looks like this

    * 01 - active *.
    -010001 active+.
    Bank-010010001+.
    Metrol politan Bank---01001000100001+.
    Royal - 01001000100002 Bank+.
    ---01001000100003 stander charted Bank+.
    ---010010002 cash+.
    -01001000200001 money in hand+.
    01001000200002 Patty Cash+.
    Capital - 010002+.
    ---010020001 active machines.
    ---01002000100001 needle Machine+.
    Machine GGT - 01002000100002+.
    -010020002 computer active+.
    -01002000200001 Server computer+.
    -01002000200002 other computer+.


    Hope you guys understand that I need the hierarchical query to do this kind of tree


    Concerning

    Therese

    Like this?

    SQL> select
      2  lpad('-',(level-1)*4,'-')|| acc_id ||
      3  '  ' || acc_name as tree
      4  from coa
      5  connect by prior
      6  acc_id = rtrim(substr(acc_id,1,instr(acc_id,'0',-1)),'0')
      7  start with rtrim(substr(acc_id,1,instr(acc_id,'0',-1)),'0') is null
      8  ;
    
    TREE
    ------------------------------------------------------------
    01  ASSETS
    ----01001  Current Assets
    --------010010001  Banks
    ------------01001000100001  Metrol Politan Bank
    ------------01001000100002  Royal Bank
    ------------01001000100003  Stander Charted Bank
    --------010010002  Cash
    ------------01001000200001  Cash in Hand
    ------------01001000200002  Patty Cash
    ----01002  Fixed Assets
    
    10 rows selected.
    

    Best regards

    Maxim

  • Hierarchical queries - problem with condition "begins by".

    Hi people

    I play with the connection by and start with clause and am faced with a particular problem which I can not solve...

    My data set is:

    Create table dates_q
    (start_date date,
    end_date date)
    /
    

    REM INSERTING into dates_q
    Insert into dates_q ("START_DATE","END_DATE") values (to_date('01-JAN-14','DD-MON-RR'),to_date('10-JAN-14','DD-MON-RR'));
    Insert into dates_q ("START_DATE","END_DATE") values (to_date('11-JAN-14','DD-MON-RR'),to_date('20-JAN-14','DD-MON-RR'));
    Insert into dates_q ("START_DATE","END_DATE") values (to_date('10-MAR-14','DD-MON-RR'),to_date('20-MAR-14','DD-MON-RR'));
    Insert into dates_q ("START_DATE","END_DATE") values (to_date('21-MAR-14','DD-MON-RR'),to_date('31-MAR-14','DD-MON-RR'));
    Insert into dates_q ("START_DATE","END_DATE") values (to_date('01-APR-14','DD-MON-RR'),to_date('10-APR-14','DD-MON-RR'));
    

    Now I basically just want to get your hands on hierarchical queries and working with the syntax of various...

    What I now want is, start with the date of April 1 as my start date and work backward to build my 'tree '. The condition of my tree is between two rows; my start and end dates differ from 1 day. If they do not; I don't want these records in my tree.

    And using sys_connect_by_path, I want to get all the way from the root.

    Thus, for example,.

    SELECT a.*,
           sys_connect_by_path(start_date, '|'),
           LEVEL lvl
      FROM dates_q a
     CONNECT BY PRIOR end_date = (start_date - 1)
    

    I get the following output

    START_DATEEND_DATESYS_CONNECT_BY_PATH(START_DATE,'|')LVL
    01.01.201410.01.2014| 1 JANUARY 141
    11.01.201420.01.2014| 1 JANUARY 14 | JANUARY 11, 142
    11.01.201420.01.2014| JANUARY 11, 141
    10.03.201420.03.2014| MARCH 10, 141
    21.03.201431.03.2014| MARCH 10, 14. MARCH 21, 142
    01.04.201410.04.2014|10-MAR-14|21-MAR-14|01-APR-143
    21.03.201431.03.2014| MARCH 21, 141
    01.04.201410.04.2014| MARCH 21, 14. 1 APRIL 142
    01.04.201410.04.2014| 1 APRIL 141

    But for the moment I did not have any starting point... Now comes the FUN part...

    When I give the State of departure; I get a single row :-(

    Example of

    SELECT a.*,
           sys_connect_by_path(start_date, '|'),
           LEVEL lvl
      FROM dates_q a
     CONNECT BY PRIOR end_date = (start_date - 1)
     START WITH start_date = To_Date('01-apr-2014','dd-mon-yyyy');
    

    The result is

    START_DATEEND_DATESYS_CONNECT_BY_PATH(START_DATE,'|')LVL
    01.04.201410.04.2014| 1 APRIL 141

    Just a line...!

    I'm unable to understand this and work more and need help.

    The formation of the tree works only in a 'sense' and I'm going the other way around? Don't know what it means but just something that comes to mind. :/

    Thank you

    K

    P.S. - database is 10g R2.

    Hello

    Thanks for the display of the data of the sample; It is very useful.

    What do you expect the result will be and why?

    LEVEL = 1 contains all rows that meet the condition to START WITH.  The rows that meet the condition

    start_date = To_Date('01-apr-2014','dd-mon-yyyy')

    in this case?  Only the line you actually obtained.

    LEVEL = N (where N > 1) contains all rows that meet the conditions regarding some FRONT CONNECT BY rank level = N - 1.  Since the only line level = 1 to end_date = To_Date('10-apr-2014','dd-mon-yyyy'), lines satisfy the condition

    End_date PRIOR = (start_date - 1).

    ? None.  End_date PREREQUISITE is April 10, while rows with start_date April 11 would fulfill this condition, there is no line on LEVEL = 2 and the query stops there.

    You would have expected this from your previous results.  The line with the start_date April 1 had no children in the previous application, so there no children in any application that has the same State of CONNECT BY.

    Maybe you meant the CONNECT BY condtion to be

    End_date = BEFORE (start_date - 1).

  • Reg: Prior in hierarchical queries:

    Hi Experts,

    A little doubt - I've been working on the requests, but it still haunts me... Hierarchical queries
    One thing I am more confused about is the prior clause.

    I'll try to explain my concern below.
    Here, the tree yesterday gets reversed by changing the clause PRIOR to 'Manager Id' to 'Employee Id' and vice versa.

    Exactly how to understand where to put FORWARD... which column?
    I can get my results just double check... but I just want to know the concept. So stupid right... but do not want to take this doubt more far. ;)
    ranit@XE11GR2>> select * from
      2  emp;
    
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
    ---------- ---------- --------- ---------- --------- ---------- ---------- ----------
          7369 SMITH      CLERK           7902 17-DEC-08        800                    20
          7566 NORGAARD   MANAGER         7839 01-APR-07       2975                    20
          7654 MARTIN     SALESMAN        7698 28-SEP-07       1250       1400         30
          7698 BLAKE      MANAGER         7839 01-MAY-09       2850                    30
          7782 FOOTE      MANAGER         7839 09-JUN-08       2450                    10
          7788 SCOTT      ANALYST         7566 19-APR-87       3000                    20
          7839 ELLISON    PRESIDENT            17-NOV-06       5000                    10
          7844 TURNER     SALESMAN        7698 08-SEP-08       1500          0         30
          7876 ADAMS      CLERK           7788 18-JUN-07       1100                    20
          7900 JAMES      CLERK           7698 03-DEC-07        950                    30
          7902 LOFSTROM   ANALYST         7566 04-DEC-08       3000                    20
          7934 MILLER     CLERK           7782 23-JAN-08       1300                    10
    
    12 rows selected.
    
    Elapsed: 00:00:00.04
    ranit@XE11GR2>> select * from
      2  emp
      3  connect by empno  = prior mgr
      4  start with empno = 7698;
    
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
    ---------- ---------- --------- ---------- --------- ---------- ---------- ----------
          7698 BLAKE      MANAGER         7839 01-MAY-09       2850                    30
          7839 ELLISON    PRESIDENT            17-NOV-06       5000                    10
    
    Elapsed: 00:00:00.01
    ranit@XE11GR2>> select * from
      2  emp
      3  connect by prior empno = mgr
      4  start with empno = 7698;
    
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
    ---------- ---------- --------- ---------- --------- ---------- ---------- ----------
          7698 BLAKE      MANAGER         7839 01-MAY-09       2850                    30
          7654 MARTIN     SALESMAN        7698 28-SEP-07       1250       1400         30
          7844 TURNER     SALESMAN        7698 08-SEP-08       1500          0         30
          7900 JAMES      CLERK           7698 03-DEC-07        950                    30
    
    Elapsed: 00:00:00.07
    Please help guys.
    Oracle Database 11g Express Edition Release 11.2.0.2.0 - Production
    PL/SQL Release 11.2.0.2.0 - Production
    "CORE     11.2.0.2.0     Production"
    TNS for 32-bit Windows: Version 11.2.0.2.0 - Production
    NLSRTL Version 11.2.0.2.0 - Production
    Thank you
    Vanessa B.

    I know the feeling!

    START WITH gives you the first line of the result set.

    CONNECT BY gets you the next row. At this point, you already have is the "before" line and the line that you get is the current line.

    If the current line is supposed to be the Manager of the previous line, this means that Bishop PREREQUISITE = empno.

    If the previous line is supposed to be the Manager of the current line, which means PRIOR empno = mgr.

    Think AHEAD as referring to the line that you just received and "without any preconditions" as the line you want.

    Another way of thinking that is to ask "what new information I receive?

    If you say "Bishop PREREQUISITE = empno", you already know the Director of the previous row. New information will be the Director of the current line. As you continue, you will learn step by step who are managers.

    If you say "PRIOR empno = mgr", you already know that the employee of the previous row. New information will be the new empno. So step by step, you will find the empnos.

    You always ' move to before current. "Of mgr to empno" descends from the string, "empno to Bishop" goes to the top of the chain.

    Published by: stew Ashton on February 16, 2013 11:57

  • Gites join vs hierarchical queries

    Hello

    Please tel me who must use a 1?
    I have to get job list of the simple Manger, should I use self-join or hierarchical queries (CONNECT BY and earlier versions)?

    Yours sincerely

    Hello

    944768 wrote:
    Hello

    Please tel me who must use a 1?
    I have to get job list of the simple Manger, should I use self-join or hierarchical queries (CONNECT BY and earlier versions)?

    It depends on your data and your needs.

    Whenever you have a question, please post a small example of data (CREATE TABLE and INSERT statements) for all the tables involved, so people who want to help you can recreate the problem and test their ideas. Also post the results you want from this data, as well as an explanation of how you get these results from these data.
    Explain, using specific examples, how you get these results from these data.
    If you show what the problem using commonly available tables (suc as scott.emp, who has a hierarchy of level 4), then you do not have ot post sample data, just the results and explanations.
    Always say what version of Oracle you are using (for example, 11.2.0.2.0).
    See the FAQ forum {message identifier: = 9360002}

    If your hierarchy consists only of 2 levels, then a self-join will be probably more effective, simpler code and easier to maintain.

    If you don't know how many levels in the hierarchy, then self-join is not an option. Use CONNECT BY or, if you have Oracle 11.2, a WITH recursive clause.

    If you have a fixed number of levels (or an upper limit) greater than 2, then CONNECT BY (or a WITH recursive clause) will probably be the best.

  • How to order a tree balanced with SQL hierarchical queries

    by searching the forum I found this

    Re: Generate tree balanced with SQL hierarchical queries

    is there a way I can order this tree in alphabetical order so that the result looks like

    LEVEL INDENTED_ENAME
    ---------- --------------------
    1 KING BED
    2 BLAKE
    3 ALLEN
    3 JAMES
    MARTIN 3
    3 TURNER
    WARD 3
    2 CLARK
    3 MILLER
    2 JONES
    3 FORD
    4 SMITH
    3 SCOTT
    4 ADAMS

    -the original query-

    SELECT THE LEVEL
    , LPAD (' ', 3 * LEVEL) | Ename AS indented_ename
    FROM scott.emp
    START WITH mgr IS NULL
    CONNECT BY PRIOR empno = mgr
    ;

    LEVEL INDENTED_ENAME
    ---------- --------------------
    1 KING BED
    2 JONES
    3 SCOTT
    4 ADAMS
    3 FORD
    4 SMITH
    2 BLAKE
    3 ALLEN
    WARD 3
    MARTIN 3
    3 TURNER
    3 JAMES
    2 CLARK
    3 MILLER

    Hello

    Bodin wrote:
    Hi Frank, I can order it selectively depending on the level, which means that only siblings stopped at third level, but rest of the brothers and sisters remain Nations United ordered

    It's actually quite difficult. You can "ORDER of brothers and SŒURS BY CASE... ', like this:

    SELECT  LEVEL
    ,      LPAD (' ', 3 * LEVEL) || ename     AS indented_ename
    FROM      scott.emp
    START WITH        mgr     IS NULL
    CONNECT BY         mgr      = PRIOR empno
    ORDER SIBLINGS BY  CASE
                   WHEN  job = 'MANAGER'  THEN  ename
                                              ELSE  NULL
                 END
    ;
    

    In this case to get desired results in table scott.emp, as the lines are LEVEL = 2 if and only if use = "MANAGER".
    But if you reference LEVEL in the CASE expression (for example, if you replace ' job = 'MANAGER' ' with "2 LEVEL =" above "), then you will get the error" ORA-00976: LEVEL, PRIOR or ROWNUM not allowed here. "
    The best way I can think to do exactly what you asked is to do 2 CONNECT BY queries; one just to get the LEVEL and the other for the brothers and SŒURS ORDER BY:
    {code}
    WITH got_lvl AS
    (
    SELECT LEVEL AS lvl
    Bishop
    empno
    ename
    FROM scott.emp
    START WITH mgr IS NULL
    CONNECT BY PRIOR empno = mgr
    )
    SELECT lvl
    , LPAD (' ', 3 * LEVEL) | Ename AS indented_ename
    OF got_lvl
    START WITH mgr IS NULL
    CONNECT BY PRIOR empno = mgr
    BROTHERS AND SŒURS OF ORDER OF CASES
    ONCE lvl = 2 THEN ename
    ANOTHER NULL
    END
    ;
    {code}
    Why you can't simply "Brothers and SŒURS of ORDER BY ename" at all levels? If all you care is the order of the items of LEVEL = 2, then this is probably the most effective and simplest way. It really hurt anything if nodes on levels 3, 4, 5,... are in order, too?

    Here's something you can do if you want to order by different unique things to different levels:
    {code}
    WITH got_sort_key AS
    (
    SELECT LEVEL AS lvl
    , LPAD (' ', 3 * LEVEL) | Ename AS indented_ename
    empno
    SYS_CONNECT_BY_PATH (LPAD (CASE
    WHEN LEVEL = 2
    THEN ename
    Of OTHER TO_CHAR (empno)
    END
    10
    )
    , ','
    ) AS sort_key
    FROM scott.emp
    START WITH mgr IS NULL
    CONNECT BY PRIOR empno = mgr
    )
    SELECT lvl
    indented_ename
    empno
    OF got_sort_key
    ORDER BY sort_key
    ;
    {code}
    However, all possible values of the CASE expression must uniquely identify the node; otherwise, the output won't necessarily hierarchical order. You can assign arbitrary unique IDS to the lines (using the ROW_NUMBER analytic function, for example), but that requires another subquery and is also complex and perhaps as ineffective as the solution above with 2 garages CONNECT.

  • Stuck computer management on the volume of queries for available shrink space, please wait.

    I'm trying to reduce my Windows 7 partition but the computer management tool is stuck on "volume volume queries for available shrink space, please wait". I used to have a Linux installation on it earlier and I uninstalled it properly, but Windows still work, so that could be the problem. Anyone have any ideas?

    I don't know if l could help but try the system, sfc file Checker

    http://www.SevenForums.com/tutorials/1538-SFC-SCANNOW-Command-System-File-Checker.html

    And after doing so clean the PC boot to see if you can access disk management

  • How to remove DNS queries for banned sites?

    Hello

    I'm looking to create a certain number of signatures to DNS queries for banned sites, the only way I've implemented successfully is to create a signature (string UDP), so he abandons all traffic UDP 53 containing the banned site regex string.

    I would like clarification from the experts to verify that this is the only way to do this, I know that there is a DNS Service engine, but I can't specify the COMPLETE domain name in this context. I don't know if I am missing something?

    Thank you very much

    You are on the right track. A personal signature of UDP is the only way you will find the applications that you want to remove.

    The DNS engine does not allow for the custom string matches.

    -Bob

  • SQL queries for the date and year

    Hi friends,

    I have a named view - item_sales with 4 columns

    Item code

    Name of the element

    Transaction_YYYYMM (Date stored in a format YYYYMM)

    QTY_RECEIVED

    QTY_SOLD

    Sample data is

    ITEM_CODE POINT NAME TRANSACTION_YYYMM QTY_RECD QTY_SOLD

    TSHIRT 201307 3000 2000 AX

    TSHIRT AX 500 2000 201308

    TSHIRT 201309 1000 3000 AX

    CX 201307 3000 2000 XLSHIRT

    XLSHIRT CX 201308 3000 2500

    CX 201309 3000 2500 XLSHIRT

    END OF EACH MONTH I'LL RUN THIS QUERY TO FIND OUT THE DETAILS BELOW

    1. TO FIND NOM_ELEMENT WISE - QTY_RECEIVED AND QTY_SOLD (FOR THE CURRENT MONTH - EXAMPLE SEP)

    2. TO FIND NOM_ELEMENT WISE - QTY_RECEIVED AND QTY_SOLD (EXAMPLE EXERCISE OF JAN TO SEP)

    OUTPUT FOR SEPTEMBER MONTH LOOK LIKE THIS

    SEVEN MONTHS JAN TO SEP

    ITEM_CODE NOM_ELEMENT QTY_RECEIVED QTY_RECEIVED QTY_SOLD QTY_SOLD

    TSHIRT 1000, 3000, 6000, 5500 AX

    CX 3000 2000 9000 7000 XLSHIRT

    Pls advise me how to write queries for this

    RDK

    Hello

    This is called a Pivot, and here's a way to do it:

    WITH got_display_yyyymm AS

    (

    SELECT TO_CHAR (ADD_MONTHS (SYSDATE-1)

    , "YYYYMM.

    ) AS YYYYMM

    OF the double

    )

    SELECT i.item_code

    i.item_name

    SUM (CASE

    WHEN i.transaction_yyyymm = d.yyyymm

    THEN i.qty_received

    END

    ) AS month_received

    SUM (CASE

    WHEN i.transaction_yyyymm = d.yyyymm

    THEN i.qty_sold

    END

    ) AS month_sold

    SUM (CASE

    WHEN SUBSTR (i.transaction_yyyymm, 1, 4)

    = SUBSTR (d.yyyymm, 1, 4)

    THEN i.qty_received

    END

    ) AS year_received

    SUM (CASE

    WHEN SUBSTR (i.transaction_yyyymm, 1, 4)

    = SUBSTR (d.yyyymm, 1, 4)

    THEN i.qty_sold

    END

    ) AS year_sold

    Item_sales I have

    CROSS JOIN got_display_yyyymm d

    I.item_code GROUP, i.item_name

    ORDER BY i.item_code, i.item_name

    ;

    If you would care to post a small example of data (CREATE TABLE and INSERT statements) and the results desired from these data, then I could test it.

    The subquery got_display_yyyymm digit which is the previous month; It is not to change anything from month to month.  If you run the query in October 2013, then YYYYMM Gets the value '201309'.  If you run it in January 2014, then YYYYMM will be '201312'.

    As posted, it will work in Oracle 9.1 or higher.  The SELECT... PIVOT function that was introduced in Oracle 11.1 would not help in this problem, so you do not miss anything using Oracle 10 in this case.

  • Slow hierarchical queries

    Hello
    I wrote an application that allows the user to filter the data displayed based on several parameters, for example one of the parameters (b) is hierarchical, each element (with the exception of the root element) has a father and several sons, the hierarchy is managed by a specific table (LINKS), I need when the user selects b the result will include also all his descendants.

    This is the query:

    SELECT *.
    R
    JOIN IN-HOUSE RT ON R.A = RT. A
    WHERE (R.B IN (select sub_id
    the beginning of LINKS with father_id =: id
    Connect prior sub_id = father_id)
    or R.B =: id or: id = 0)
    AND (R.A =: GOLD: a = 0)
    ORDER OF R.B, R.A

    The problem is that the query is so slow, it allows the application of stuck, when I've omitted the line: ' or R.B =: id or: id = 0 ' he not stuck but this line is necessary because the user may also fill the filter field or try to filter b himself and not his descendants.

    Is it possible to improve the performance of this query or write it better?

    You can move the logic on r.b in the subquery.
    There is a small chance that it could accelerate the entire query.
    not tested

    SELECT *
    FROM R
    JOIN RT ON R.A = RT.A
    WHERE R.B IN (select sub_id
                       from LINKS
                       start with father_id = :id
                       connect by prior sub_id= father_id
                       UNION ALL
                       select :id sub_id from dual
                       UNION ALL
                       select sub_id
                       from LINKS
                       where :id = 0
                       )
    AND (R.A=:a or :a=0)
    ORDER BY R.B, R.A
    

    Also see the ecexution use it and explain how to call the select statement.
    A goal of optimization often used is wo writing several queries and call the right according to the parameters.
    Different queries may be optimized independently of each other and hence faster query where everything is condensed into one big.

    pls/sql example

    if :a=0 and :b=0 then
       SELECT *
       into...
       FROM R
       JOIN RT ON R.A = RT.A
       ORDER BY R.B, R.A;
    elsif :b=0 then
       SELECT *
       into...
       FROM R
       JOIN RT ON R.A = RT.A
       where R.A=:a
       ORDER BY R.B, R.A;
    elsif :a=0 then
       SELECT *
       into...
       FROM R
       JOIN RT ON R.A = RT.A
       WHERE R.B IN (select sub_id
                       from LINKS
                       start with father_id = :id
                       connect by prior sub_id= father_id
                       UNION ALL
                       select :id sub_id from dual)
       ORDER BY R.B, R.A;
    else /* both parameters are selected */
       SELECT *
       into...
       FROM R
       JOIN RT ON R.A = RT.A
       WHERE R.B IN (select sub_id
                       from LINKS
                       start with father_id = :id
                       connect by prior sub_id= father_id
                       UNION ALL
                       select :id sub_id from dual)
       and R.A=:a
       ORDER BY R.B, R.A;
    end;
    
  • hierarchical queries: output: display all folder paths. entry: Folder1, folder2

    I have a table called 'File' with the data indicated below. I want the sql query to show the hierarchical output.
    Enter values for the query: 2-11 tree shows two points (see "Input2" and "Input11"). The query now takes the values 2 and 11 and outputs hierarchical tree from root (see "Root") to the final sheets ('2, '12'), while the entries are as points of 'touch' inside the full tree-path, so I have the necessary output should be like 5 rows:

    (0, null)-parent of the two inputs
    (2, 0) - input2
    (10,0) - parents of 'input11 '.
    (11: 10) - input11
    (12: 11) - leaf


    I don't know how to write this query. Can help you.
    Something like:

    "Select...".
    Connect prior ID = PARENT_ID.

    --

    Table "Folder" (ID, PARENT_ID).

    Column PARENT_ID reference ID to create the hierarchy.
    Example of data in the table:

    (0, null)-root
    (1, 0) - child '1 '.
    (2, 0) - Input2
    (3, 1)
    (10,0) - child "10".
    (11: 10) - chilc-child "11", Input11
    (12: 11) - chilc-child "12".

    Hello

    If you want to ignore a few lines in the file and only pay attention to the parameters, their ancestors and their descendants. Is this fair?
    If so, do CONNECT it BY query on the results of a subquery which includes only the desired lines. In the example below, this query Tahina is be a UNION of two other CONNECT BY queries: one to get the ancestors of the parameters and the other for their descndents.

    VARIABLE     input_a     NUMBER
    VARIABLE     input_b     NUMBER
    EXEC  :input_a := 2;
    EXEC  :input_b := 11;
    
    WITH     universe     AS
    (
         -- Descendents of parameters
         SELECT     id,     parent_id
         FROM     folder
         START WITH     parent_id     IN (:input_a, :input_b)
         CONNECT BY     parent_id     = PRIOR id
         --
        UNION
         -- Ancestors of parameters
         SELECT  id,     parent_id
         FROM     folder
         START WITH     id     IN (:input_a, :input_b)
         CONNECT BY     id     = PRIOR parent_id
    )
    SELECT     SYS_CONNECT_BY_PATH (id, '/')     AS path
    FROM     universe
    START WITH     parent_id     IS NULL
    CONNECT BY     parent_id     = PRIOR id
    ;
    

    Output of your sample data:

    PATH
    ------------------------------
    /0
    /0/2
    /0/10
    /0/10/11
    /0/10/11/12
    
  • Legacy and hierarchical queries

    Hi all

    Using the RDBMS 11.2.0.3, I would like to know if there was a way to "inherit" a parent row values when you use a hierarchical query.

    For example, with these values:

    CREATE TABLE foohh (
     id NUMBER,
     parent NUMBER,
     name VARCHAR2(64),
     continent VARCHAR2(32)
    );
    
    INSERT INTO foohh VALUES ( 1, null, 'United States', 'AMERICA' ) ;
    INSERT INTO foohh VALUES ( 2, 1, 'California', null ) ;
    INSERT INTO foohh VALUES ( 3, 2, 'San Francisco', null ) ;
    INSERT INTO foohh VALUES ( 4, 3, 'Golden Gate', null ) ;
    INSERT INTO foohh VALUES ( 5, null, 'China', 'ASIA' ) ;
    INSERT INTO foohh VALUES ( 6, 5, 'Beijing', null ) ;
    INSERT INTO foohh VALUES ( 7, 6, 'Great Wall', null ) ;
    
    

    I would like to be able to view the continent of all lines.

    The following query returns the leaves, but I don't see their continent:

    SELECT
     id
     ,connect_by_root(parent) parent
     ,sys_connect_by_path(name, '-->') path
     ,nvl( continent, 'unknown' ) continent
    FROM foohh
    WHERE
     connect_by_root(parent) is null
     and connect_by_isleaf=1
    CONNECT BY PRIOR id=parent
    ;
    
    

    CONTINENT OF PARENT ID PATH
    ---------- ---------- ------------------------------------------------------------ ------------------------------
    4-> United States-> California-> San Francisco-> Golden Gate unknown
    7-> China-> Beijing-> great unknown wall

    Is there a clever way to do this?

    Thank you

    Anthony

    Include below in him SELECT query.

    Continent CONNECT_BY_ROOT

  • unnecessary SQL queries for ViewObject used in different tab

    In my application, I have a table A in the first tab and table B in the second tab.

    Sometimes when I work as a user with table B in the second tab, the ViewObjectA for table A is executed.

    Of course this ViewObjectA execution is absolutely useless, because I work in another tab and I don't don't even see table A.

    Unfortunately, the query takes a long time and it makes the application slower.

    Question: why the ADF runs the query for a table that is not visible and the user accesses not?

    Is it possible to prevent it?

    A note on the configuration that may be linked to the problem:

    The ViewObjectA has an implementation customized with debug messages (that's how I discovered the ViewObject is exectuted).

    Due to the limitation of the DB, I have configured my pool ApplicationModule instances of timeout after 120 idle seconds (because the DB does not like the many connections and long-term).

    I also found that after the expiry of the ApplicationModule, a new instance of ViewObjectA is created (Yes, it should according to the ViewObjectImpl API).

    It seems to me that the unnecessary ViewObjectA execution happens after this new creation of instance of ViewObjectA.

    Well, the execution of the query of a VO is part of the creation of a VO.

    You can try to adjust it for example, you add a where clause such as 1 = clause: bindVar' and init the bindVar to 0 so that the query is performed from the user interface (see JDeveloper: obstacle to the return of the games to outline on the loading of the page of VO using the binding variable |) JDev & amp; ADF Goodies).

    Or follow Andrejus Baranovskis Blog: Oracle ADF Tuning: prevent execution of SQL queries during the loading of the Page

    Timo

  • Queries for use by ExecuteQueryRS infra v8 API

    I will carry out ExecuteQueryRS of the infra v8 API to run a query below. I was under the impression that this could be any question, as if I was using the below customer as an officer. But this doesn't seem to be the case. I get an error, for example executing a query named 'Are called Current Status' and use a group below as the current assignee:

    "Application" get call Current Status"not found. »

    This indicates that this request is not available on my system.

    Then, I came across an example in this forum that mention the query with the name 'escalation status call '. It works fine on my installation. Applications are available in the infra v8 API using the ExecuteQueryRS method? Are there available out-of-the-box queries? I try to run a query that finds all calls assigned to a group.

    Thank you.

    If it is similar to the v8 somehing like in v9, you can check standard and customized (if you have the ones) questioned in *.sql [inside the Config folder] files.

    If there is no required query, you can define a (query or procedure) in your custom_infra.sql (or similar) of the file and analysed in the VSM Server Console. If you have created a new request file, don't forget to make a reference to it at the end of the file ' config - queries.xml.

    I just checked - there is none "are called Current Status" and "Climbing status call" in the standard VSM 9 queries (I suspect v8 has the same situation).

    G

  • Hierarchical queries with Rollup sum (CONNECTED BY GROUP BY ROLLUP)

    Hi all

    Imagine the following scenario: I have an ACCOUNT table that contains the accounts and their hierarchy (currently 5 levels) and a BALANCE table that holds the record for the balance of the accounts. Only CHILD accounts (level 5) have records in the table for BALANCE. Simple example:
    CREATE TABLE accounts (account_code VARCHAR2(30), parent_account VARCHAR2(30), account_desc VARCHAR2(400));
    CREATE TABLE balances (account_code VARCHAR2(30), balance_amount NUMBER(18,2));
    INSERT INTO ACCOUNTS VALUES ('TOT',NULL,'Total');
    INSERT INTO ACCOUNTS VALUES ('ANA1','TOT','General Expenses');
    INSERT INTO ACCOUNTS VALUES ('4801001','ANA1','Small Expenses');
    INSERT INTO ACCOUNTS VALUES ('4801002','ANA1','Transportation');
    INSERT INTO ACCOUNTS VALUES ('ANA2','TOT','Health Expenses');
    INSERT INTO ACCOUNTS VALUES ('4802001','ANA2','Healthcare');
    INSERT INTO ACCOUNTS VALUES ('4802002','ANA2','Facilities');
    
    
    INSERT INTO BALANCES VALUES ('4801001', 2000);
    INSERT INTO BALANCES VALUES ('4801002', 1000);
    INSERT INTO BALANCES VALUES ('4802001', 3000);
    INSERT INTO BALANCES VALUES ('4802002', 4000);
    What I need in this scenario is to run a hierarchical query, where each node, I calculate the sum of all its children (in TERMINAL nodes that are child accounts, this amount is the value of the balances itself). End result would be:
    TOT -> 10000
      ANA1 -> 3000
        4801001 -> 2000
        4801001 -> 1000
      ANA2 -> 7000
        4802001 -> 3000
        4802002 -> 4000
    I tried many ways and found a solution that works for a fixed amount of levels, basically he built the hierarchy and calculates the SYS_CONNECT_BY_PATH, then divides it as a regular expression and using GROUP BY ROLLUP to calculate the highest levels. Then I assemble again, now with the calculated values. Here's the example query:
    select level
        , NVL (vfinal.child_account,'TOTAL') ||' - '||
                            ( SELECT account_desc
                                FROM accounts 
                               WHERE account_code = vfinal.child_acct ) account_name
    
         , to_char(sum_bal, 'fm999g999g999g990') as rolled_up_balance
      from 
    (
    select coalesce( princ.lvl3, princ.lvl2, princ.lvl1 ) child_acct
         , DECODE ( princ.lvl2 , NULL 
                                     , NULL 
                                     , DECODE ( princ.conta_lvl3, NULL
                                     , princ.conta_lvl1,princ.conta_lvl2 ) ) parent_acct
         , sum(princ.balance_amount) sum_bal
    from (
    select hier.lvl1
         , hier.lvl2
         , hier.lvl3
         , hier.parent_account
         , hier.account_code child_acc
         , bal.balance_amount
      from ( select level  
                  , sys_connect_by_path( account_code, '/' ) hierarchy_acct
                  , REGEXP_SUBSTR(sys_connect_by_path( account_code, '/' ),'[^/]+',1,3) lvl3
                  , REGEXP_SUBSTR(sys_connect_by_path( account_code, '/' ),'[^/]+',1,2) lvl2
                  , REGEXP_SUBSTR(sys_connect_by_path( account_code, '/' ),'[^/]+',1,1) lvl1
                  , account_code
                  , parent_account  
               from accounts acc
               where level <= 3
               start with parent_account is null
               connect by nocycle prior account = parent_account
               order siblings by parent_account
               ) hier
          , balances  bal
      where bal.cod_conta  = hier.account_code
    ) princ
    where princ.lvl1 is not null
    group by rollup ( princ.lvl1
                    , princ.lvl2
                    , princ.lvl3 )
    
    order by princ.conta_lvl1
           , princ.conta_lvl2
           , princ.conta_lvl3
    ) vfinal
    where child_acct is not null
    start with parent_acct is null
    connect by nocycle prior child_acct = parent_acct
    All is said and done, what I need is to do the same thing for infinite levels, because this query has 3 fixed levels. Do you know how can I structure a new query where, regardless of the number of levels, amounts of parent are all wound like that?

    Thank you very much in advance! Best regards!
    Thiago

    Published by: Thiago Sep 6, 2011 11:31

    Published by: Thiago Sep 6, 2011 13:01
    select  account_code,
            (
             select  sum(balance_amount)
               from  accounts a2,
                     balances b
               where b.account_code(+) = a2.account_code
               start with a2.account_code = a1.account_code
               connect by a2.parent_account = prior a2.account_code
            ) balance_amount
      from  accounts a1
    /
    
    ACCOUNT_CODE    BALANCE_AMOUNT
    --------------- --------------
    TOT                      10000
    ANA1                      3000
    4801001                   3000
    4801002
    ANA2                      7000
    4802001                   7000
    4802002
    
    7 rows selected.
    
    SQL> 
    

    SY.

Maybe you are looking for

  • Is no longer able to sync to iPod album art

    All my album in my library artwork iTunes stopped syncing with my iPod - even the music I bought on the iTunes store. How can I restore it? I've been deleting music from my library to create capabilities but no joy so far.

  • check spelling

    In Yosemite, spell check is too conservative, even with this option disabled in system preferences > keyboard > text When in TextEdit, both automatically check spelling and abbriviations, (owa = I'll be there!) or anyting has added to this list, does

  • Foxfire logo does not appear on my toolbar so I can access the web!

    When I first accessed the site of Foxfire it seems only three steps to access the web. (wait 1) download 2) Guest to pull logo to the toolbar to access the web. I'm still waiting!

  • Qosmio F10 graphics card stopped working

    HelloI have a F10 (almost 3 years) which has suddenly stopped working last week. I took to a local computer repair shop and was told that it will be more than 450 of my English books to make alive again. Apparently the graphics card started badly, so

  • HP Pavilion Elite HPE-400Y no video output.

    Hello I have a HP Pavilion Elite HPE-400Y computer that I had stored (unplugged) in a bedroom closet bedroom for almost a year.  It was working fine when I put it in storage. This past weekend, I wanted to use, so I plugged in and connected to an ana