Help with 'connect by prior' statement

I've got a quoting report that is sporadically ordering incorrectly and I've traced the source down to a 'connect by prior' statement. Can I get an explanation of what the statement is doing so I can figure out how to change it to get the desired results?
select rownum config_rownum, quote_line_id,related_quote_line_id rlid, level
from aso_line_relationships
where relationship_type_code = 'CONFIG'
connect by prior related_quote_line_id = quote_line_idsample output for the line_ids for one quote:
CONFIG_ROWNUM     QUOTE_LINE_ID     RLID     LEVEL
1          7438          7439     2
2          7440          7441     2
3          7430          7431     2
4          7432          7433     2
5          7432          7434     2
6          7432          7435     2
7          7436          7437     2
8          7442          7443     2
9          7442          7444     2
10          7442          7445     2
11          7442          7446     2
12          7442          7447     2
13          7442          7448     2
14          7442          7449     2
15          7450          7451     2
16          7452          7453     2
17          7452          7454     2
18          7452          7455     2
19          7456          7457     2
20          7456          7458     2
21          7456          7459     2
22          7460          7461     2
23          7460          7462     2
24          7463          7464     2
25          7430          7431     1
26          7432          7433     1
27          7432          7434     1
28          7432          7435     1
29          7436          7437     1
30          7438          7439     1
31          7440          7441     1
32          7442          7443     1
33          7442          7444     1
34          7442          7445     1
35          7442          7446     1
36          7442          7447     1
37          7442          7448     1
38          7442          7449     1
39          7450          7451     1
40          7452          7453     1
41          7452          7454     1
42          7452          7455     1
43          7456          7457     1
44          7456          7458     1
45          7456          7459     1
46          7460          7461     1
47          7460          7462     1
48          7463          7464     1 The correct ordering can be seen by running this statement:
select rownum config_rownum, quote_line_id,related_quote_line_id rlid
from aso_line_relationships
where relationship_type_code = 'CONFIG' and quote_line_id between 7430 and 7464
CONFIG_ROWNUM     QUOTE_LINE_ID     RLID
1          7430          7431
2          7432          7433
3          7432          7434
4          7432          7435
5          7436          7437
6          7438          7439
7          7440          7441
8          7442          7443
9          7442          7444
10          7442          7445
11          7442          7446
12          7442          7447
13          7442          7448
14          7442          7449
15          7450          7451
16          7452          7453
17          7452          7454
18          7452          7455
19          7456          7457
20          7456          7458
21          7456          7459
22          7460          7461
23          7460          7462
24          7463          7464I tried to substitute the simple query above for the 'connect by prior' query in the report but failed because something in the report is expecting input from the 'connect by prior' statement. So eliminating the statement is not a choice.

"connect by prior " is for for hierarchical queries which is for data has parent-children relationship, and ususlly its' result is used to populate tree-like data result. and order by is NOT recommend since it will destroy the hierarchical order.
you could use "order by sibiling" if you would like to order inside the same level of data

Similar Messages

  • SQL with connect by prior running for a long time

    Hi,
    We are using Oracle 10g. Below is a cursor sql which is having performance issues. The pAccountid is being passed from the output of a different cursor. But this cursor sql is running for a long time. Could you please help me in tuning this sql. I believe the subquery with connect by prior is causing the trouble.
    The TRXNS is a huge table which is not partitioned. The query is forced to use the index on the accountid of the TRXNS table.
    The accountlink table has 20,000 records and the TRXNStrack table has 10,000 records in total.
    This sql executes for 200,000 pAccountids and runs for more than 8 hours.
    SELECT /*+ INDEX(T TRXNS_ACCOUNTID_NIDX) */ AL.FROMACCOUNTID oldaccountid ,
                                    A.ACCOUNTNUM  oldaccountnum,
                                   T.TRXNSID,
                                   T.TRXNSTYPEID,
                                   T.DESCRIPTION ,
                                   T.postdt,
                                   T.TRXNSAMT
                        FROM
                        ACCOUNTLINK AL,
                        TRXNS T,
                        ACCOUNT A
                       WHERE AL.TOACCOUNTID IN
                                                             (SELECT TOACCOUNTID FROM ACCOUNTLINK START WITH TOACCOUNTID = pAccountid
                                                                                                                         CONNECT BY PRIOR FROMACCOUNTID  = TOACCOUNTID)
                            AND AL.FROMACCOUNTID = T.ACCOUNTID
                            AND A.ACCOUNTID = AL.FROMACCOUNTID
    AND NOT EXISTS (select 1 from TRXNStrack trck where trck.TRXNSid = t.TRXNSid AND TRXNSTrackReasonid = 1)
                            AND T.postdt > A.CLOSEDATE
                            AND T.postdt >= sysdate-2
                            AND T.postdt <= sysdate;
    Create script for trxn table:
    CREATE TABLE SP.TRXNS
      TRXNSID      NUMBER(15) CONSTRAINT "BIN$rpIQEeyLDfbgRAAUT4DEnQ==$0" NOT NULL,
      ACCOUNTID    NUMBER(15) CONSTRAINT "BIN$rpIQEeyMDfbgRAAUT4DEnQ==$0" NOT NULL,
      STATEMENTID  NUMBER(15),
      TRXNSTYPEID  NUMBER(15),
      DESCRIPTION  VARCHAR2(80 BYTE),
      postdt     DATE,
      TRXNSAMT     NUMBER(12,2),
      TRXNSREQID   NUMBER(15),
      LASTUPDATE   DATE,
      SOURCEID     NUMBER(15),
      HIDE         VARCHAR2(1 BYTE)
    TABLESPACE SO_TRXN_DATA
    RESULT_CACHE (MODE DEFAULT)
    PCTUSED    40
    PCTFREE    10
    INITRXNS   2
    MAXTRXNS   255
    STORAGE    (
                INITIAL          50M
                NEXT             1M
                MINEXTENTS       1
                MAXEXTENTS       UNLIMITED
                PCTINCREASE      0
                FREELISTS        8
                FREELIST GROUPS  1
                BUFFER_POOL      DEFAULT
                FLASH_CACHE      DEFAULT
                CELL_FLASH_CACHE DEFAULT
    LOGGING
    NOCOMPRESS
    NOCACHE
    NOPARALLEL
    MONITORING;
    CREATE INDEX SP.TRXNS_ACCOUNTID_NIDX ON SP.TRXNS
    (ACCOUNTID, postdt)
    LOGGING
    TABLESPACE SO_TRXN_INDEX
    PCTFREE    10
    INITRXNS   2
    MAXTRXNS   255
    STORAGE    (
                INITIAL          64K
                NEXT             1M
                MINEXTENTS       1
                MAXEXTENTS       UNLIMITED
                PCTINCREASE      0
                FREELISTS        1
                FREELIST GROUPS  1
                BUFFER_POOL      DEFAULT
                FLASH_CACHE      DEFAULT
                CELL_FLASH_CACHE DEFAULT
    NOPARALLEL;
    below is the executing plan for this sql taken from toad :
    PLAN_ID
    TIMESTAMP
    OPERATION
    OPTIONS
    OBJECT_OWNER
    OBJECT_NAME
    OBJECT_ALIAS
    OBJECT_INSTANCE
    OBJECT_TYPE
    OPTIMIZER
    SEARCH_COLUMNS
    ID
    PARENT_ID
    DEPTH
    POSITION
    COST
    CARDINALITY
    BYTES
    CPU_COST
    IO_COST
    TEMP_SPACE
    ACCESS_PREDICATES
    FILTER_PREDICATES
    PROJECTION
    TIME
    QBLOCK_NAME
    1121
    9/10/2013 3:30
    FILTER
    1
    0
    1
    1
    NOT EXISTS (SELECT 0 FROM "TRXNSTRACK" "TRCK" WHERE "TRXNSTRACKREASONID"=1 AND "TRCK"."TRXNSID"=:B1)
    AL."FROMACCOUNTID"[NUMBER,22], "T"."TRXNSID"[NUMBER,22], "T"."TRXNSTYPEID"[NUMBER,22], "T"."DESCRIPTION"[VARCHAR2,80], "T"."POSTDT"[DATE,7], "T"."TRXNSAMT"[NUMBER,22], "A"."ACCOUNTNUM"[VARCHAR2,19]
    SEL$5DA710D3
    1121
    9/10/2013 3:30
    FILTER
    2
    1
    2
    1
    SYSDATE@!-2<=SYSDATE@!
    AL."FROMACCOUNTID"[NUMBER,22], "T"."TRXNSID"[NUMBER,22], "T"."TRXNSTYPEID"[NUMBER,22], "T"."DESCRIPTION"[VARCHAR2,80], "T"."POSTDT"[DATE,7], "T"."TRXNSAMT"[NUMBER,22], "A"."ACCOUNTNUM"[VARCHAR2,19]
    1121
    9/10/2013 3:30
    NESTED LOOPS
    3
    2
    3
    1
    (#keys=0) "AL"."FROMACCOUNTID"[NUMBER,22], "T"."TRXNSID"[NUMBER,22], "T"."TRXNSTYPEID"[NUMBER,22], "T"."DESCRIPTION"[VARCHAR2,80], "T"."POSTDT"[DATE,7], "T"."TRXNSAMT"[NUMBER,22], "A"."ACCOUNTNUM"[VARCHAR2,19]
    1121
    9/10/2013 3:30
    NESTED LOOPS
    4
    3
    4
    1
    5
    1
    119
    3989858
    4
    (#keys=0) "AL"."FROMACCOUNTID"[NUMBER,22], "T"."TRXNSID"[NUMBER,22], "T"."TRXNSTYPEID"[NUMBER,22], "T"."DESCRIPTION"[VARCHAR2,80], "T"."POSTDT"[DATE,7], "T"."TRXNSAMT"[NUMBER,22], "A".ROWID[ROWID,10]
    1
    1121
    9/10/2013 3:30
    NESTED LOOPS
    5
    4
    5
    1
    4
    1
    90
    3989690
    3
    (#keys=0) "AL"."FROMACCOUNTID"[NUMBER,22], "T"."TRXNSID"[NUMBER,22], "T"."TRXNSTYPEID"[NUMBER,22], "T"."DESCRIPTION"[VARCHAR2,80], "T"."POSTDT"[DATE,7], "T"."TRXNSAMT"[NUMBER,22]
    1
    1121
    9/10/2013 3:30
    HASH JOIN
    SEMI
    6
    5
    6
    1
    3
    2
    54
    3989094
    2
    AL."TOACCOUNTID"="TOACCOUNTID"
    (#keys=1) "AL"."FROMACCOUNTID"[NUMBER,22]
    1
    1121
    9/10/2013 3:30
    INDEX
    FULL SCAN
    SP
    ACCOUNTLINK_AK1
    AL@SEL$1
    INDEX (UNIQUE)
    ANALYZED
    7
    6
    7
    1
    1
    18
    252
    107
    1
    AL."FROMACCOUNTID"[NUMBER,22], "AL"."TOACCOUNTID"[NUMBER,22]
    1
    SEL$5DA710D3
    1121
    9/10/2013 3:30
    VIEW
    SYS
    VW_NSO_1
    VW_NSO_1@SEL$5DA710D3
    11
    VIEW
    8
    6
    7
    2
    2
    18
    234
    107
    1
    TOACCOUNTID[NUMBER,22]
    1
    SEL$683B0107
    1121
    9/10/2013 3:30
    CONNECT BY
    NO FILTERING WITH START-WITH
    9
    8
    8
    1
    TOACCOUNTID=PRIOR "FROMACCOUNTID"
    TOACCOUNTID=56354162
    TOACCOUNTID[NUMBER,22], "FROMACCOUNTID"[NUMBER,22], PRIOR NULL[22], LEVEL[4]
    SEL$683B0107
    1121
    9/10/2013 3:30
    INDEX
    FULL SCAN
    SP
    ACCOUNTLINK_AK1
    ACCOUNTLINK@SEL$3
    INDEX (UNIQUE)
    ANALYZED
    10
    9
    9
    1
    1
    18
    252
    107
    1
    ACCOUNTLINK.ROWID[ROWID,10], "FROMACCOUNTID"[NUMBER,22], "TOACCOUNTID"[NUMBER,22]
    1
    SEL$3
    1121
    9/10/2013 3:30
    TABLE ACCESS
    BY INDEX ROWID
    SP
    TRXNS
    T@SEL$1
    2
    TABLE
    ANALYZED
    11
    5
    6
    2
    1
    1
    63
    298
    1
    T."TRXNSID"[NUMBER,22], "T"."TRXNSTYPEID"[NUMBER,22], "T"."DESCRIPTION"[VARCHAR2,80], "T"."POSTDT"[DATE,7], "T"."TRXNSAMT"[NUMBER,22]
    1
    SEL$5DA710D3
    1121
    9/10/2013 3:30
    INDEX
    RANGE SCAN
    SP
    TRXNS_ACCOUNTID_NIDX
    T@SEL$1
    INDEX
    ANALYZED
    2
    12
    11
    7
    1
    1
    1
    224
    1
    AL."FROMACCOUNTID"="T"."ACCOUNTID" AND "T"."POSTDT">=SYSDATE@!-2 AND "T"."POSTDT"<=SYSDATE@!
    T.ROWID[ROWID,10], "T"."POSTDT"[DATE,7]
    1
    SEL$5DA710D3
    1121
    9/10/2013 3:30
    INDEX
    UNIQUE SCAN
    SP
    ACCOUNT_PK
    A@SEL$1
    INDEX (UNIQUE)
    ANALYZED
    1
    13
    4
    5
    2
    1
    1
    90
    1
    A."ACCOUNTID"="AL"."FROMACCOUNTID"
    A.ROWID[ROWID,10]
    1
    SEL$5DA710D3
    1121
    9/10/2013 3:30
    TABLE ACCESS
    BY INDEX ROWID
    SP
    ACCOUNT
    A@SEL$1
    3
    TABLE
    ANALYZED
    14
    3
    4
    2
    1
    1
    29
    168
    1
    A."CLOSEDATE"<SYSDATE@! AND "T"."POSTDT">"A"."CLOSEDATE"
    A."ACCOUNTNUM"[VARCHAR2,19]
    1
    SEL$5DA710D3
    1121
    9/10/2013 3:30
    INDEX
    RANGE SCAN
    SP
    TRXNSTRACK_TRXNSID_NIDX
    TRCK@SEL$6
    INDEX
    ANALYZED
    2
    15
    1
    2
    2
    1
    1
    10
    73
    1
    TRCK."TRXNSID"=:B1 AND "TRXNSTRACKREASONID"=1
    TRCK."TRXNSID"[NUMBER,22], "TRXNSTRACKREASONID"[NUMBER,22]
    1
    SEL$6
    Please help me in debugging this thanks!

    Hi,
    Thanks for your thought on this subject. Below is the trace info that I got from the DBA
    SQL ID: d0x879qx2zgtz Plan Hash: 4036333519
    SELECT /*+ INDEX(T TRXNS_ACCOUNTID_NIDX) */ AL.FROMACCOUNTID OLDACCOUNTID ,
      A.ACCOUNTNUM OLDACCOUNTNUM, T.TRXNSID, T.TRXNSTYPEID, T.DESCRIPTION ,
      T.POSTDT, T.TRXNSAMT
    FROM
    ACCOUNTLINK AL, TRXNS T, ACCOUNT A WHERE AL.TOACCOUNTID IN (SELECT
      TOACCOUNTID FROM ACCOUNTLINK START WITH TOACCOUNTID = :B3 CONNECT BY PRIOR
      FROMACCOUNTID = TOACCOUNTID) AND AL.FROMACCOUNTID = T.ACCOUNTID AND
      A.ACCOUNTID = AL.FROMACCOUNTID AND NOT EXISTS (SELECT 1 FROM TRXNSTRACK
      TRCK WHERE TRCK.TRXNSID = T.TRXNSID AND TRXNSTRACKREASONID = :B4 ) AND
      T.POSTDT > A.CLOSEDATE AND T.POSTDT >= :B2 AND T.POSTDT <= :B1
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        0      0.00       0.00          0          0          0           0
    Execute  17160      2.10       1.87          0          0          0           0
    Fetch    17160   7354.61    7390.86     169408    5569856  883366791           0
    total    34320   7356.71    7392.74     169408    5569856  883366791           0
    Misses in library cache during parse: 0
    Optimizer mode: CHOOSE
    Parsing user id: 38     (recursive depth: 1)
    SQL ID: gs89hpavb4cts Plan Hash: 3415795327
    SELECT A.ACCOUNTID, C.MEMBERID, A.PROGRAMID, A.ACCOUNTNUM
    FROM
    CUSTOMER C, CUSTOMERACCOUNT CA, ACCOUNT A, PROGRAMPARAMVALUE PPV,
      BATCHPROCESSPROGRAM BP WHERE A.PROGRAMID = BP.PROGRAMID AND A.PROGRAMID =
      PPV.PROGRAMID AND A.ACCOUNTID = CA.ACCOUNTID AND CA.PERSONID = C.PERSONID
      AND PPV.PARAMID = :B2 AND PPV.VALUE = 'Y' AND BP.PROCESSID = :B1 AND BP.RUN
      = 'Y' AND A.ACCOUNTTYPEID = 4 AND A.ACCOUNTSTATUSID = 1 AND C.MEMBERID IS
      NOT NULL
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        0      0.00       0.00          0          0          0           0
    Execute      0      0.00       0.00          0          0          0           0
    Fetch      172     13.14     115.34      80826     278650          0       17200
    total      172     13.14     115.34      80826     278650          0       17200
    Misses in library cache during parse: 0
    Parsing user id: 38     (recursive depth: 1)
    OVERALL TOTALS FOR ALL NON-RECURSIVE STATEMENTS
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        0      0.00       0.00          0          0          0           0
    Execute      0      0.00       0.00          0          0          0           0
    Fetch        0      0.00       0.00          0          0          0           0
    total        0      0.00       0.00          0          0          0           0
    Misses in library cache during parse: 0
    OVERALL TOTALS FOR ALL RECURSIVE STATEMENTS
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        0      0.00       0.00          0          0          0           0
    Execute  17160      2.10       1.87          0          0          0           0
    Fetch    17332   7367.75    7506.21     250234    5848506  883366791       17200
    total    34492   7369.85    7508.09     250234    5848506  883366791       17200
    Misses in library cache during parse: 0
        2  user  SQL statements in session.
        0  internal SQL statements in session.
        2  SQL statements in session.
    Trace file: svoprod_ora_12346.trc
    Trace file compatibility: 11.1.0.7
    Sort options: default
           1  session in tracefile.
           2  user  SQL statements in trace file.
           0  internal SQL statements in trace file.
           2  SQL statements in trace file.
           2  unique SQL statements in trace file.
       66499  lines in trace file.
        7516  elapsed seconds in trace file.

  • Help with connection flash builder 4.5 to remote php database

    help with connection flash builder 4.5 to remote php database

    Fatal error: require_once() [function.require]: Failed opening required 'Zend/Loader/Autoloader.php' (include_path='.;C:\php5\pear;D:/webserver/apache2/htdocs/ZendFramework/library') in D:\webserver\apache2\htdocs\giga\first-debug\gateway.php on line 27

  • Help with connecting Nintendo dsi to internet

    I really need some help with connecting my daughters nintendo dsi to the internet, I have tried everything but just can't get it to work. Would really appreciate any advice....

    Hi sandy and welcome
    Have a read http://bt.custhelp.com/app/answers/detail/a_id/11263/c/346%2C502%2C504/kw/nintendo%20ds/r_id/125731
    Note: The Nintendo DS only supports either no security or WEP security!!
    -+-No longer a forum member-+-

  • Help needed with CONNECT BY PRIOR

    I need to display salesrep-manager hierarchy. I'm using the following SQL and am sure I'm doing something wrong somewhere, but just can't pinpoint. Any help is greatly appreciated.
    <pre>
    SELECT sf.source_name salesrep
    ,mgr.full_name manager
    ,level
    FROM as_salesforce_v sf
    ,per_all_assignments_f pass
    ,per_all_people_f mgr
    WHERE sf.role_name = 'Sales Representative'
    AND SYSDATE BETWEEN nvl(sf.start_date_active, SYSDATE) AND
    nvl(sf.end_date_active, SYSDATE)
    AND SYSDATE BETWEEN nvl(pass.effective_start_date, SYSDATE) AND
    nvl(pass.effective_end_date, SYSDATE)
    AND SYSDATE BETWEEN nvl(mgr.effective_start_date, SYSDATE) AND
    nvl(mgr.effective_end_date, SYSDATE)
    CONNECT BY PRIOR mgr.person_id = pass.supervisor_id
    START WITH pass.person_id = sf.employee_person_id;
    </pre>
    TIA
    Alka.
    Forgot to mention, the SQL takes forever to run.
    Message was edited by:
    user498444

    as_salesforce_v view stores the salesrep name (as specified by the condition sf.role_name = 'Sales Representative'). This view also has rows for managers of salesreps as that's how Oracle Sales app allows the users to access the app. This table stores employee id in column employee_person_id.
    per_all_assignments_f table stores the assignments for all the employees (including salesreps and that's why condition START WITH pass.person_id = sf.employee_person_id). It also stores the employee id for the manager (column supervisor_id).
    per_all_people_f has all the employee records (including manager records) and the column person_id is the employee id (condition pass.supervisor_id = mgr.person_id).
    Hope this explanation is helpful.

  • CONNECT BY PRIOR statement issue

    Hi,
    I'm using the below select query to build a relationship b/w ID & parent_id, but HANA studio is throwing a syntax error. I don't see a problem around the syntax. Please throw some light's here.
    SELECT * FROM "SIVA_TEST"."Core_Competency" START with  "Competency_ID"=1
    CONNECT BY PRIOR "Competency_ID" = "Parent_Competency_ID"   ;
    Error:
    Could not execute 'SELECT * FROM "SIVA_TEST"."Core_Competency" START WITH "Competency_ID"='1' CONNECT BY PRIOR ...' in 170 ms 563 µs .
    SAP DBTech JDBC: [257] (at 46): sql syntax error: incorrect syntax near "START": line 2 col 1 (at pos 46)
    Table struct:
    create column table "SIVA_TEST"."Core_Competency"("Competency_ID" integer,
    "Competency_Name" varchar(200),
    "Competency_description" varchar(1000),
    "Parent_Competency_ID" integer,
    "start_date" date,
    primary key("Competency_ID"));
    Thanks,
    Siva.

    Insert statement for the corresponding table..
    INSERT INTO "SIVA_TEST"."Core_Competency" VALUES (1,'value 1',null,null,'2013-12-02');
    INSERT INTO "SIVA_TEST"."Core_Competency" VALUES (2,'value 2',null,1,'2013-07-31');
    INSERT INTO "SIVA_TEST"."Core_Competency" VALUES (3,'value 3',null,1,'2013-02-01');
    INSERT INTO "SIVA_TEST"."Core_Competency" VALUES (4,'value 4',null,2,'2013-06-24');
    INSERT INTO "SIVA_TEST"."Core_Competency" VALUES (5,'value 6',null,2,'2013-04-09');
    INSERT INTO "SIVA_TEST"."Core_Competency" VALUES (6,'value 7',null,3,'2013-09-12');
    INSERT INTO "SIVA_TEST"."Core_Competency" VALUES (7,'value 8',null,3,'2013-08-09');
    INSERT INTO "SIVA_TEST"."Core_Competency" VALUES (8,'value 9',null,7,'2013-04-09');
    INSERT INTO "SIVA_TEST"."Core_Competency" VALUES (9,'value 10',null,7,'2013-12-09');
    INSERT INTO "SIVA_TEST"."Core_Competency" VALUES (10,'value 11',null,4,'2013-09-08');
    INSERT INTO "SIVA_TEST"."Core_Competency" VALUES (11,'value 12',null,4,'2013-10-10');

  • Connect by prior statement....

    Hi,
    please help me in the following query.
    select a.part,a.assy
    from assy_info a
    connect by prior part = assy
    start with assy in ('A');
    part assy
    B A
    C B
    Z C
    H Z
    I don't want the above query to extract after part = 'Z'.
    please help me...
    regards
    laxman

    I don't want the above query to extract after part = 'Z'.Hmm, something like:
    SQL> select a.part,a.assy
      2  from (
      3  select 'B' part, 'A' assy from dual
      4  union all
      5  select 'C' part, 'B' assy from dual
      6  union all
      7  select 'Z' part, 'C' assy from dual
      8  union all
      9  select 'H' part, 'Z' assy from dual
    10  ) a
    11  connect by prior part = assy and prior part != 'Z'
    12  start with assy in ('A');
    P A
    B A
    C B
    Z C?
    Rgds.

  • Need help with connecting file inputs to arrays

    In this assignment I have a program that will do the following: display a list of names inputed by the user in reverse order, display any names that begin with M or m, and display any names with 5 or more letters. This is all done with arrays.
    That was the fun part. The next part requires me to take the names from a Notepad file, them through the arrays and then output them to a second Notepad file.
    Here is the original program: (view in full screen so that the code doesn't get jumbled)
    import java.io.*;       //Imports the Java library
    class progB                    //Defines class
        public static void main (String[] arguments) throws IOException
            BufferedReader keyboard;                                  //<-
            InputStreamReader reader;                                 //  Allows the program to
            reader = new InputStreamReader (System.in);               //  read the the keyboard
            keyboard = new BufferedReader (reader);                  //<-
            String name;                 //Assigns the name variable which will be parsed into...
            int newnames;               //...the integer variable for the amount of names.
            int order = 0;              //The integer variable that will be used to set the array size
            String[] array;             //Dynamic array (empty)
            System.out.println (" How many names do you want to input?");   //This will get the number that will later define the array
            name = keyboard.readLine ();
            newnames = Integer.parseInt (name);                                         // Converts the String into the Integer variable
            array = new String [newnames];                                               //This defines the size of the array
            DataInput Imp = new DataInputStream (System.in);       //Allows data to be input into the array
            String temp;                                       
            int length;                                                                  //Defines the length of the array for a loop later on
                for (order = 0 ; order < newnames ; order++)                                //<-
                {                                                                           //  Takes the inputed names and
                    System.out.println (" Please input name ");                            //  gives them a number according to
                    temp = keyboard.readLine ();                                           //  the order they were inputed in
                    array [order] = temp;                                                  //<-
                for (order = newnames - 1 ; order >= 0 ; order--)                                //<-
                {                                                                                //  Outputs the names in the reverse 
                    System.out.print (" \n ");                                                   //  order that they were inputed
                    System.out.println (" Name " + order + " is " + array [order]);             //<-
                for (order = 0 ; order < newnames ; order++)                                  //<-
                    if (array [order].startsWith ("M") || array [order].startsWith ("m"))     //  Finds and outputs any and all
                    {                                                                         //  names that begin with M or m
                        System.out.print (" \n ");                                            //
                        System.out.println (array [order] + (" starts with M or m"));         //
                    }                                                                         //<-
                for (order = 0 ; order < newnames ; order++)                                            //<-
                    length = array [order].length ();                                                   //
                    if (length >= 5)                                                                    //  Finds and outputs names
                    {                                                                                  //  with 5 or more letters
                        System.out.print (" \n ");                                                      //
                        System.out.println ("Name " + array [order] + " have 5 or more letters ");      //<-
    }The notepad file contains the following names:
    jim
    laruie
    tim
    timothy
    manny
    joseph
    matty
    amanda
    I have tried various methods but the one thing that really gets me is the fact that i can't find a way to connect the names to the arrays. Opening the file with FileInputStream is easy enough but using the names and then outputing them is quite hard. (unless i'm thinking too hard and there really is a simple method)

    By "connect", do you just mean you want to put the names into an array?
    array[0] = "jim"
    array[1] = "laruie"
    and so on?
    That shouldn't be difficult at all, provided you know how to open a file for reading, and how to read a line of text from it. You can just read the line of text, put it in the array position you want, until the file is exhausted. Then open a file for writing, loop through the array, and write a line.
    What part of all that do you need help with?

  • Help with connecting to NIST NTP server on port 123

    I can get NIST time in Daytime format using the rt_nist_date_time.llb example posted on ni.com, but I cannot connect to NIST NTP format time data using port 123.  I freely admit to being over my head with this stuff, and have spent much of this Thanksgiving holiday reading about UDP and TCP.
    The attached vi summarizes what I've tried so far.  The UDP case is what I thought would work, but I can't come up with a network address that the UDP-open vi likes.  Can anyone out there help this n00b tell the time?
    The attached file is supposed to be in 8.0 format, although I'm working in 9.0
    Here is a link discussing the time formats: http://tf.nist.gov/service/its.htm 
    Jeff 
    Solved!
    Go to Solution.
    Attachments:
    UDP.vi ‏17 KB

    jstevens wrote:
    THANK YOU!!!  I don't think I ever would have come up with connecting the web address to a Read or Write UDP rather than the Open UDP block.  Not to mention starting by opening port zero.
    Unlike TCP, UDP is a connectionless protocol. Here's a quick explanation in different words.
    A udp packet travels from a [sourceIP, sourcePort] to a [DestinationIP, destinationPort].
    UDP open basically reserves a local port used for sending (soucePort) and receiving (incoming packet with that same destinationPort). Since some local ports are always in use, you would generate an error if you would accidentally pick a used port. Picking zero is useful for requests (as in this case!), because the OS will pick an unused ephemeral port. The actual source port number does not matter because the NTP server will just send the reply packet back to whatever port it came from. (If you would write your own NTP server in LabVIEW, you would of course need to set the local port to 123, and would get a conflict if another NTP server is already running on your rig). Writing an NTP server in LabVIEW would be a trivial modification to the current code, try it! . Simply listen for packets on port 123, form a response packet based on the timestamp, and send it to whatever IP/Port it came from (that info is available from udp read) and then go back to listen for new requests.).
    UDP write sends a packet to the server using the above opened local port as source port. You can use the same connectionID to write to several other servers and ports, because UDP is connectionless. (TCP is connection based, so a TCP connection involves a defined source/destination pair)
    UDP read listens for incoming packets from all over the world at that same local port. It is very unlikely, but theoretically possible that other UDP packets will arrive at that same port, so you could even filter to make sure to read incoming packets until they match the port and IP of the original request. The current code is somewhat vulnerable to a DOS (denial of service) attack for example as follows: Imagine the guy in the next cubicle had means of sniffing your network traffic. He could write a small program that looks for your NTP requests and then immediately starts flooding your IP with meaningless UDP packets to the sourcePort you just used. The current program only reads one packet and thus will never see the return packet from the NTP server.
    UDP close frees up the local port and the computer is now no longer listening for packets on that port. Of course you could keep the port open for the duration of the program, especially if you intend to send UDP request once in a while during execution.
    Makes sense?
    LabVIEW Champion . Do more with less code and in less time .

  • Help with connecting a G4 with mac 9.2.2 to the internet?

    I am new to mac, and I have a G4 that runs on Mac 9.2.2. I plan on upgrading to 10.4.6 (tiger), but I am unable to get it to connect to the internet. Can anyone help?

    What is the specific model of your Mac? This can make a difference in some things.
    You can connect via a built-in 56K modem if it has one, but it will be very slow. Much better would be to connect via broadband (such as DSL or Cable) using an external modem, either hard-wired via ethernet (usual) or via wireless if available on the machine.
    Connecting via hard-wired ethernet is easy. You would need to acquire a modem that is acceptable to your ISP, or lease one from them if they make that option available. Either way, get one that connects via ethernet rather than via USB - USB on a G4 is just too slow for this purpose.
    The setup for ethernet is simple in OS 9:
    In the TCP/IP control panel (Apple menu > Control Panels > TCP/IP), set
         Connect via     -to-     Ethernet
         Configure         -to-     Using DHCP Server
    And that's usually all that is needed.
    Connecting via wireless, Airport in Apple's lexicon, is similar to ethernet, as far as setting up the software goes. In order to use wireless, the G4 will need to have an Airport card installed, or you can use a local transmitter which connects via ethernet to the G4. The modem would need to be connected to a receiver (base station) in order to complete the communication path with the Mac.
    If you choose to go this path, someone else would need to assist you in setting up the wireless components - I've never done that.
    However, if you do not now have wireless internet available, and this is going to be the only machine needing to connect to the internet, it would be much cheaper and easier to just connect the modem via wired ethernet directly to the Mac.
    In either case, you will also need to set up your email account. Your email service provider should provide you with the info you need to do that - account type and password, etc. This info is entered into the Internet control panel, Email tab.
    If I have misunderstood and you want to connect wirelessly directly to your ISP using something like those small transceiver type modems that many folk use with laptops, that's something else, and someone else would need to help with that.

  • Help regarding CONNECT BY PRIOR AND LEVEL

    Hi
    I need to retreive all the employees that are at the least level under a particular employee. Assume basic emp table.
    I have been using CONNECT BY PRIOR
    select mgr,empno,ename, level from emp
    start with empno=7839
    connect by prior empno=mgrOUTPUT:
    MGR     EMPNO     ENAME     LEVEL
         7839     KING     1
    7839     7566     JONES     2
    7566     7788     SCOTT     3
    7788     7876     ADAMS     4
    7566     7902     FORD     3
    7902     7369     SMITH     4
    7839     7698     BLAKE     2
    7698     7499     ALLEN     3
    7698     7521     WARD     3
    7698     7654     MARTIN     3
    7698     7844     TURNER     3
    7698     7900     JAMES     3
    7839     7782     CLARK     2
    7782     7934     MILLER     3The Output i require should be
    MGR     EMPNO     ENAME     LEVEL
    7788     7876     ADAMS     4
    7902     7369     SMITH     4
    7698     7499     ALLEN     3
    7698     7521     WARD     3
    7698     7654     MARTIN     3
    7698     7844     TURNER     3
    7698     7900     JAMES     3
    7782     7934     MILLER     3Also if i change the empno then i need to get only the employees under that employee only.
    Thanks in Advance,
    G.Vamsi Krishna

    oracle_for_dude wrote:
    can you explain what is this query doing
    SQL> select  mgr,empno,ename, level
    2  from    emp
    3  where   level  > 2
    4  start with  empno = 7566
    5  connect by  prior empno = mgr;
    MGR      EMPNO ENAME           LEVEL
    7788       7876 ADAMS               3
    7902       7369 SMITH               37566 in scott.emp table is employee_id of JONES, It's displaying the selected columns for all the employees in the sub-tree starting with Jones, not including Jones (who is at LEVEL=1) and the people who report directly to Jones (LEVEL=2).
    >
    >
    Thanks in advance

  • Help with connecting iPad 2 to Motif xs keyboard using GarageBand.?

    I have an iPad 2. I recently bought the iPad camera connection kit from amazon because I heard you can connect your iPad to a music keyboard with GarageBand. I have a Yamaha motif xs 8. When I connect my keyboard with a midi USB to the iPad.. Nothing happens. Can anybody help with this, and am I missing something in order to make this work???

    It worked for me no problem but I'm using an ES Rack and the dude on the video I think was using an ES. It maybe the XS is wired differently. Your best option is still getting a piece like IK Multimedia's iRig Midi. It connects from the iPad dock to actual midi cables and is way more flexible if your using multiple devices.

  • MSI P67A-C45 (B3) Newb needs Help with connections..

    Hi all..
    First time posting here, but have been in the shadows for quite a while..   
    Anyway, i decided to finally take the plunge, and build my own PC, and now i'm beginning to hit a few bumps.
    I have a couple of questions that i would like some help with, if possible to reassure myself i may be in the right direction..
    I bought THIS PSU and was hoping someone could tell me where the Blue connectors (one labelled CP and one labelled U1) Connect to?
    Is it into JPWR2? And does it/do they only connect in the correct way? (Do i remove the plastic cap and attach both?
    and i bought THIS VIDEO/GRAPHICS CARD and i'm guessing the RED "PCI express" and "SLI ready" connect to that somehow (Haven't opened box yet for card)
    Again, wondering is there a certain way for them to connect.
    Also, from my chassis, the "AC '97" and "HDA" connectors go to JAUD (I guess), does it matter which one? (I currently have "HDA" connected)
    I have i5 2500k already on board. (If that makes a difference).

    Quote from: Ben_Cartwright on 26-May-11, 22:05:35
    Do the Audio plugs go into JAUD? and does it matter which one?
    Yep, connect the front panel audio to the JAUD. If you need the pin layout, it says in the manual. I would say the HDA connector is the one to connect.
    Quote from: Ben_Cartwright on 26-May-11, 22:05:35
    Any recommendations for testing it all, before i plug it in, and press the power?
    Should i (Can i) test individual parts first?
    Thanks again.
    Check all power connections, seating of the RAM and add-on cards, check the HSF is plugged into the fan header, and obvious things like that.
    As for testing, enter the BIOS and make sure the CPU isn't running too hot. Set up the RAM with the required timings and voltage, and test with >>Memtest86<< for several hours. No point starting the Windows installation if say your RAM has errors, since it will corrupt files during the install, if it installs at all.

  • Problem with connect by prior

    Hi,
    I've table TAB_MGR:
    EMPLOYEE................MANAGER
    ABCD...................ABC
    ABC.....................AB
    AB......................A
    WAXXY..Y...............WAXX
    WAXX...................WA
    WA.....................W
    I tried this query:
    select a.EMPLOYEE, b.MANAGER
    from
    (select EMPLOYEE, MANAGER, rownum-level rl, level lv
    from TAB_MGR connect by prior MANAGER = EMPLOYEE) a,
    (select EMPLOYEE, MANAGER, rownum-level rl, level lv
    from TAB_MGR connect by prior MANAGER = EMPLOYEE) b
    where a.lv=1 and a.rl=b.rl;
    output is:
    EMPLOYEE....................MANAGER
    ABCD........................ABC
    ABCD........................AB
    ABCD........................A
    ABC.........................AB
    ABC.........................A
    AB..........................A
    WAXXYY.....................WAXX
    WAXXYY.....................WA
    WAXXYY.....................W
    WAXX.......................WA
    WAXX.......................W
    WA.........................W
    but I'd like to get also the level 1 of employee = MANAGER
    In my case I'd like to get this output:
    EMPLOYEE........................MANAGER
    ABCD..........................ABCD
    ABCD..........................ABC
    ABCD..........................AB
    ABCD..........................A
    ABC...........................ABC
    ABC...........................AB
    ABC...........................A
    AB............................AB
    AB............................A
    WAXXYY........................WAXXYY
    WAXXYY........................WAXX
    WAXXYY........................WA
    WAXXYY........................W
    WAXX..........................WAXX
    WAXX..........................WA
    WAXX..........................W
    WA............................WA
    WA............................W
    in my query lacks:
    EMPLOYEE........................MANAGER
    ABCD..........................ABCD
    ABC...........................ABC
    AB............................AB
    WAXXYY........................WAXXYY
    WAXX..........................WAXX
    WA............................WA
    How can I get also this record in my query??
    Thanks!

    Hi,
    I had to add two record at the table TAB_MGR, because W and A haven't manager:
    New tab TAB_MGR is:
    EMPLOYEE................MANAGER
    ABCD...................ABC
    ABC.....................AB
    AB......................A
    WAXXYY.................WAXX
    WAXX....................WA
    WA.......................W
    W.........................
    A..........................
    I have written the query:
    select a.EMPLOYEE, b.MANAGER
    from
    (select EMPLOYEE, MANAGER, rownum-level rl, level lv
    from TAB_MGR connect by prior MANAGER = EMPLOYEE) a,
    (select EMPLOYEE, MANAGER, rownum-level rl, level lv
    from TAB_MGR connect by prior MANAGER = EMPLOYEE) b
    where a.lv=1 and a.rl=b.rl
    AND a.MANAGER IS NOT NULL
    AND b.MANAGER IS NOT NULL
    UNION ALL
    select NVL(r.EMPLOYEE,R.MANAGER),NVL(r.EMPLOYEE,R.MANAGER)
    from TAB_MGR r
    connect by prior r.EMPLOYEE = r.MANAGER
    group by r.EMPLOYEE,R.MANAGER;
    output is:
    EMPLOYEE........................MANAGER
    ABCD..........................ABCD
    ABCD..........................ABC
    ABCD..........................AB
    ABCD..........................A
    ABC...........................ABC
    ABC...........................AB
    ABC...........................A
    AB............................AB
    AB............................A
    A.............................A
    WAXXYY........................WAXXYY
    WAXXYY........................WAXX
    WAXXYY........................WA
    WAXXYY........................W
    WAXX..........................WAXX
    WAXX..........................WA
    WAXX..........................W
    WA............................WA
    WA............................W
    W............................W
    It seems run correctly, but now I have another problem:
    In my table TAB_MGR I have add a new column DESCRIPTION:
    EMPLOYEE................MANAGER.......DESCRIPTION
    A.......................................L1
    AB......................A..............L2
    ABC.....................AB.............L3
    ABCD...................ABC.............L4
    W......................................M1
    WA.......................W.............M2
    WAXX....................WA.............M3
    WAXXYY.................WAXX.............M4
    from my query I'd like to get this output:
    EMPLOYEE........................MANAGER.......DESCRIPTION
    ABCD...................................ABCD..............L1-L2-L3-L4
    ABCD...................................ABC...............L1-L2-L3-L4
    ABCD...................................AB................L1-L2-L3-L4
    ABCD...................................A.................L1-L2-L3-L4
    ABC....................................ABC...............L1-L2-L3
    ABC....................................AB................L1-L2-L3
    ABC....................................A.................L1-L2-L3
    AB.....................................AB................L1-L2
    AB.....................................A.................L1-L2
    A......................................A.................L1
    WAXXYY........................WAXXYY............M1-M2-M3-M4
    WAXXYY........................WAXX..............M1-M2-M3-M4
    WAXXYY........................WA................M1-M2-M3-M4
    WAXXYY........................W.................M1-M2-M3-M4
    WAXX..........................WAXX..............M1-M2-M3
    WAXX..........................WA................M1-M2-M3
    WAXX..........................W.................M1-M2-M3
    WA............................WA................M1-M2
    WA............................W.................M1-M2
    W............................W..................M1
    Have someone any idea of like completing my query?
    Thanks in advance!!!!

  • Help with Connecting New Computer w/ WRT110

    My sister just got a new laptop and has the WRT110.  My brother in law passed away 3 weeks ago and he had the security passcodes.  I just called Linksys to get help with it and their warrenty is up and wanted to charge us $30.  Money is tight right now.  Is there anyone that can help us with this issue?
    Thanks so much

    Open an Internet Explorer browser page on your wired computer(desktop).In the address bar type - 192.168.1.1 and press Enter...Leave Username blank & in Password use admin in lower case...
    Click on the Wireless tab..under Wireless tab,click on the subtab Wireless Security...Now,check the Security/Network Key.If you are using WEP Security then,use Key1 as the Security/Network Key.

Maybe you are looking for

  • RSDRO: Error RSAODS 131 raised

    Hello everybody, I'm trying to load an ODS and an infocube from 0HR_PE_1 infosource. The infocube load has finished OK however the ODS load fails. The error in sm21 is: > RSDRO: Error RSAODS 131 raised            > RSDRO: 1: 2: 3: 4:                 

  • LGWR ASYNC doest not working for redolog files, while archiving is working

    Hi All, I am using Oracle Database 10g Enterprise Edition Release 10.2.0.4.0. I have created a database named black. I then creaetd a standby database. now I want to syncronize the redo logs file as well. SO I added log_archive_dest_2='SERVICE=standb

  • Can I make a subfolder a Virtual Domain?

    Greetings all, Still on Tiger Server. I've created virtual domains before like this: Default: /Library/WebServer/Documents Virtual1: /Library/WebServer/Virtual1 But I want to know if I can do this: Default: /Library/WebServer/Documents Virtual1: /Lib

  • Sharing data

    I have a nokia lumia, but unable to activate network sharing. What size of data package must you purchase in order to use your smartphone as a data hub for your other wireless devices?

  • Print PDFs from Website Without Header

    Is there a way to print PDFs in safari from websites where it does not inclue the header and footer informaition with the website URL, time etc?