SQL CONNECTION question

Hello
I have the following script:
CREATE TABLE TEST_CONNECT_BY)
PK NUMBER NOT NULL,
key_group number not null,
START_DATE DATE,
END_DATE DATE
);
insert into TEST_CONNECT_BY values (1, 1, 1 January 2011 ", January 2, 2011");
insert into TEST_CONNECT_BY values (2, 1, January 2, 2011 ", January 3, 2011");
insert into TEST_CONNECT_BY values (3, 1, January 3, 2011 ", January 4, 2011");
insert into TEST_CONNECT_BY values (4, 2, 1 January 2011 ", January 2, 2011");
insert into TEST_CONNECT_BY values (5, 2, January 2, 2011 ", January 3, 2011");
insert into TEST_CONNECT_BY values (6, 3, 1 January 2011 ", January 2, 2011");
insert into TEST_CONNECT_BY values (7, 3, January 3, 2011 ", January 4, 2011");
commit;

And seek to get the following result:
KEY_GROUP START_DATE END_DATE
--------- ---------- --------
1 1 JANUARY 2011 JANUARY 4, 2011
2 1 JANUARY 2011 JANUARY 3, 2011
3. ON JANUARY 1, 2011 JANUARY 2, 2011
3 JANUARY 3, 2011 JANUARY 4, 2011

The connection must be grouped by key_group and connect by end_date to START DATE
Any help would be appreciated.
Thank you

Hello

arik103 wrote:
Hello
I have the following script:
CREATE TABLE TEST_CONNECT_BY)
PK NUMBER NOT NULL,
key_group number not null,
START_DATE DATE,
END_DATE DATE
);
insert into TEST_CONNECT_BY values (1, 1, 1 January 2011 ", January 2, 2011"); ...

Thanks for posting this; It is very useful.
Do not attempt to INSERT a VARCHAR2 (like January 1, 2011 "") in a DATE (such as start_date) field. Even if the above instructions to INSERT work today on your system, there is no guarantee that they will work on the system of someone else, or that they will work on your system in the future. Use TO_DATE or a DATE literal to INSERT a DATE.

Here's a way to do what you asked:

SELECT     key_group
,     CONNECT_BY_ROOT start_date     AS s_date
,     end_date
FROM     test_connect_by
WHERE     CONNECT_BY_ISLEAF     = 1
START WITH     (key_group, start_date) NOT IN
                    (
                  SELECT  key_group
               ,     end_date
               FROM     test_connect_by
               WHERE     end_date     IS NOT NULL     -- If necessary
              )
CONNECT BY     key_group     = PRIOR key_group
     AND     start_date     = PRIOR end_date
;

Whenever you use a NOT IN subquery, make sure that it never returns NULL values. If end_date is a NOT NULL constraint in your real of the table, then you don't need the WHERE clause of the subquery.

Whenever you have a question, always say what version of Oracle you are using.
This is particularly important with CONNECT BY queries, because each version since Oracle 7 has had significant changes in this area.
The query above requires Oracle 10.1 (or higher).

Tags: Database

Similar Questions

  • SQL * Net questions - which forum?

    Does anyone know what forum manages SQL * Net questions?

    THX

    For general issues, it's probably as good a place to ask as any.

    If you have SQL * Net questions that are specific to a particular technology (i.e. how various options of TNS interact with different configurations of CARS), you probably want to ask in the forums dedicated to these products.

    Justin

  • Loads of parallel data through SQL connect and replace existing data

    I'm doing a load of multiple data through SQL Connect using the following statement.  Just try to put in place a .bat file to automate the process but not sure that whenever it executes this statement adds data to existing or replaces the data? I tried to write an override for this but it works for instructions which contain the import section.

    Import of database data App.DB connect as username identified by password

    with the help of several rules_file, rul1, rul2, rul3

    load_buffer_block starting with buffer_id 10 on error write to 'C:\\dataload.err ';

    We can add spec commit buffer such as "replace all data ', 'create group', 'Add' to this import statement? The default declaration overrides the value whenever the data is loaded?

    Thanks in advance!

    you have an option in the rules file "Overwrite out of values."

    rulefile > setting dataload > loading values

  • Question about SQL * connect more in the syntax

    Good evening

    I can connect successfully from the client to the host using the following command:
    0 19:40 [Oracle] [23G] [569M] E:\Client>sqlplus scott/abc123@dbca
    
    SQL*Plus: Release 11.2.0.1.0 Production on Sun Aug 22 20:01:56 2010
    But I wanted to omit the password, so I tried:
    0 20:03 [Oracle] [23G] [590M] E:\Client>sqlplus scott/@dbca
    thinking that SQL * more tempt me the password but, if it does at all. I tried in vain a few variations. I read the specifications of command line for SQL * more and it seems that this command should work.

    Questions: What is the problem with the command I typed and what is the correct syntax?

    Thank you for your help,

    John.

    To omit the password using connect scott@dbca , but do not connect scott/@dbca of sqlplus.
    or sqlplus scott@dbca

  • SQL connection error

    Hello

    I have the following SQL error when you try to connect to a SQL Server on the same domain / Vlan. Anyone know if they have had a similar problem?

    1 Windows Firewall is disabled

    2 SQL server started

    3 Protocol TCP/IP

    4 database configured to accept remote connections

    5. the login account has permission to access

    a network related or instance specific error has occurred all in establishing a connection to sql server. The server has not been or is not accessible. Verify that the instance name is correct and that SQL server is configured to allow remote connections.  (provider: named pipes provider, error 0 - no connection could be made because the target machine actively refused it)

    Hello

    Your question is beyond the scope of this community.

    Please repost your question in the SQL Server TechNet Forums.

    https://social.technet.Microsoft.com/forums/SQLServer/en-us/home?category=SQLServer

    See you soon.

  • CF vs. SQL connection connection

    I built a few dozen pages in CF with a MS SQL back-end. Whenever I check to see how the pages work (F12), he asks me to connect. The said connection box is for the coldfusion server, but the user name and password that work are my Windows username and password (they are related to SQL Security). I had four other people try to log to see what they can get in and two of the four do not see even a box of connection (the other connection two CF get even and they use their information in Windows). The girl who manages my server config tells me it has something to do with which groups of users we are, be it, they have to connect or if it just automatically pulling their Windows login data.

    I don't mind the Windows information used for now, but when we go live on the web, I'll have to manage passwords and usernames outside. I had initially set up a CF login page, but then I had to connect to the Application first and then another connection to SQL security. Is it possible to have just one login?

    Answers online

    Chrome Blue says:
    > That sounds right, because I think that people who have to open a session
    > every time use Mozilla and those who are not using IE. When we move
    > the pages on the live server and anyone accessing the site via the web, then I
    > assume that everyone will have to connect to the authentication server.

    They cannot "connect to server authentication. Integrated Windows
    Security uses the Windows Active Directory network domain security. If
    you continue to use this security that all users must be members
    your network domain controller.

    > So is
    > there a way to 'disable' web server authentication so I can set up a
    > ColdFusion Login?

    Of course, do not use "Integrated Windows security" in the web server. If you
    plan on using ColdFusion security on a public web site, a
    would probably not use the web server level security. About a company
    intranet, it is current to use the security of the web server that all the
    usually, users are on the same network.

    And when I do, this connection of ColdFusion can grant
    > permissions to stored procedures tables/views /?

    It's kinda a weird question. When a ColdFusion application access
    a database, it is not the user client that accesses the database.
    The user defined in the ColdFusion Data Source Name (DSN) that
    access to the database. When you build a web application for all users
    are considered by the database as same user DSN. And this user DSN
    must have the * MINIMUM * permissions to the application.

  • VPN connection question

    In my workplace, there are two networks is the local LAN that connect other computers to the internet and the wireless network which my computer connect to and is directly to the internet, my question is that is it possible to connect to the LAN over the internet using the connection V P N if yes how? Please help me because whenever I want to read my emails, I have to put the UTP cable which will be sometimes annoying.
    Please indicate all the measures that are needed to establish the VPN connection.

    Ask it professionals about your place of work.  They know what is possible and what is not.

    Where I work, there is an available VPN that allows connections to the LAN from outside work.  If I use a laptop computer provided by the company, access the LAN just as if I'm at work.  If I use my PC, I get a link that allows me to access a limited number of resources, such as the email of the company.  I can, however, DRC to my desktop at work PC and can get access to the local network.

  • Microsoft SQL server question

    The company I work for has a production with SQL Server Standard Edition (64-bit) database server. However when I try to configure Oracle as a linked server, the 'Microsoft OLE DB Oracle provider' does not appear in the drop down menu to the provider. The server is running service pack 2 and the .NET version on the server is 3.5 SP1 and more 2.0 SP2 and 3.0 SP2. Please guide as to what needs to be done.

    Hi Claudine Gupta,

    Welcome to the Microsoft Answers Forum community!

    The question you posted would be better suited to the TechNet community. Please visit the link below to find a community that will provide the best support.

    http://social.technet.Microsoft.com/forums/en-us/w7itpronetworking/threads

    Thank you best regards &,.

    Calogero - Microsoft technical support.
    Visit our Microsoft answers feedback Forum
    http://social.answers.Microsoft.com/forums/en-us/answersfeedback/threads/ and tell us what you think

  • Wire Vs sleep Vs MDS Http connection Question

    Hello

    Here's my situation...

    I created a thread for background based on this article:

    http://www.BlackBerry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800451/800660/How_To _...

    Here is my code:

    / * Thread that runs in the background * /.
    the final private class BackGroundThread extends Thread {}
    private static final int TIMER = 15; minutes
    Private boolean _stop = false;

    public synchronized void stop() {}
    _stop = true;
    }

    Private boolean isCoverageSufficient() {}
    If ((DeviceInfo.isSimulator ()) |)
    (RadioInfo.getState ()! = RadioInfo.STATE_OFF & (RadioInfo.getNetworkService () & RadioInfo.NETWORK_SERVICE_DATA)! = 0) & {CoverageInfo.isCoverageSufficient (CoverageInfo.COVERAGE_MDS))}
    Returns false; a Simulator or a real device with sufficient coverage
    }
    Returns false; real aircraft with insufficient coverage
    }

    public void run() {}
    CoverageInfo.addListener (new CoverageStatusListener() {}
    {} public void coverageStatusChanged (int newCoverage)
    {Switch (newCoverage)}
    box (CoverageInfo.COVERAGE_CARRIER):
    System.out.println ("COVERAGE_CARRIER");
    GPS.this.sendPoints ();
    break;
    box (CoverageInfo.COVERAGE_MDS):
    System.out.println ("COVERAGE_MDS");
    break;
    box (CoverageInfo.COVERAGE_NONE):
    System.out.println ("COVERAGE_NONE");
    break;
    }
    }
    });
               
    While (! _stop) {}
    GPS.this.getPoint (); try to get a GPS point
    Make sure the radio is on and there is the coverage of the data
    If (isCoverageSufficient()) {}
    GPS.this.sendPoints (); Send the _Dans table to the web server
    } else {/ / blackberry is out of coverage}
    GPS.this.storePoints (); store the table _Dans on blackberry
    }

    try {}
    Thread.Sleep(Timer*1000*60); pause the thread for a set number of minutes
    } catch (InterruptedException ie) {}
    System.Err.println ("Error:" + ie.toString ());
    }
    }
    }
    }

    The 'getPoint()' method to get a coordinate GPS using LocationProvider.getLocation ().

    The method 'sendPoints()' send the GPS coordinated to a web server using the HTTP connection:

    ...

    HttpConnection con = (HttpConnection) Connector.open (URL); Open the connection URL
    con.setRequestMethod (HttpConnection.POST); POST method
    con.setRequestProperty ("Content-Type", "application/x-www-formulaires-urlencoded");
    OutputStream out = con.openOutputStream (); display the results in a stream
    out. Write (Data.GetBytes ());
    int responseCode = con.getResponseCode (); Send data and receive the response code
    If (responseCode == HttpConnection.HTTP_OK) {}
    success
    }
    If (con! = null) con. Close; close the connection to the URL

    ...

    The "storePoints()" method simply store the GPS on the Blackberry Persistent Store when the BB is out of coverage.

    When the Blackberry is trying to send a GPS coordinate, but cannot because it is out of coverage, GPS data are stored on the Blackberry. My thread can sleep for 15 minutes before getting another coordinated GPS. If the BB is on the cover in the next interval of 15 minutes, the two coordinates are sent (the current and that (or those) that have been saved on the device).
    It works very well.

    However, now, I would put up a CoverageStatusListener so my GPS coordinates would be sent as soon as the BB is on the cover (and not wait for the next 15 minutes).
    I tried to "COVERAGE_MDS", but he never seems to have triggered... but gets "COVERAGE_CARRIER".
    I have a post on this here: http://supportforums.blackberry.com/rim/board/message?board.id=java_dev&thread.id=6076

    My question is on the wire. Actually here is called the 'sendPoints()' method:
    box (CoverageInfo.COVERAGE_CARRIER):
    System.out.println ("COVERAGE_CARRIER");
    GPS.this.sendPoints ();
    break;

    However, since my son sleeps, this method is not able to initiate a connection HTTP using MDS. I get an error in timeout after 2 minutes.

    I'm not an expert on the threads. I think I have all the necessary parts of the code... but I'm not sure about how to reorganize this.
    Can anyone help?

    Thank you!

    The network connection should be asked by a listener method.  Do not perform any operation or the heavy within a method of transformation of blocking listener.  Instead, you can create a new thread from the method which could then create the network connection to send your data.

  • While developer version 4.0.1.14 sql connection I get the error message

    Set of süden today morning when connecting sql developer, I get the following error

    To perform the requested operation, an error has occurred:

    () oracle.jdbc.driver.T2CConnection.getLibraryVersionNumber I have

    0 vendor ID

    Help, please

    Problem was the automatic change of type tns connection. Somehow, she had moved from network alias to connect identified and because of that, I was getting error. I changed to alias network and gave the names of tns and it worked.

  • Concurrent SQL connections

    Is that anyway via SQL for an account of how many users are currently connected to your system EBS? We need to check for authorization purposes, while the plan was to run the same query once every 30 minutes for a week during peak working hours. We operate R12 of EBS. I think remember me a similar query, circle on A11 but I can't find similar for R12.

    Please see

    Select u.user_name, r.responsibility_name, f.user_function_name, s.function_type,

    TO_CHAR (s.first_connect, ' ' DD - MY HH24:MI:SS) "first connection."

    TO_CHAR (s.last_connect, ' ' DD - MY HH24:MI:SS) "Last connection", n.node_name

    to s icx_sessions, fnd_user u, fnd_responsibility_vl r, fnd_form_functions_vl f, fnd_nodes n

    where u.user_id (+) = s.user_id

    AND f.function_id (+) = s.function_id

    AND r.responsibility_id (+) = s.responsibility_id

    AND n.node_id (+) = s.node_id

    AND s.disabled_flag! = « Y »

    and s.pseudo_flag = n

    and (s.last_connect + decode (FND_PROFILE. VALUE('ICX_SESSION_TIMEOUT'), NULL, s.limit_time, 0, s.limit_time, FND_PROFILE. VALUE('ICX_SESSION_TIMEOUT')/60) / 24) > sysdate

    and s.counter<>

    /

    Reference:

    Note 1301645.1 How to determine how many users (outside of the concurrent manager job - forms and web users) are saved in the E-Business system at some point and the line of high waters of users on a given date?

    APpsMasTi
    sharing is caring

  • We receive many messages "there are not enough connections in the SQL connection pool.

    We get about 50 or more of these messages when running large consolidations in the consolidation system messages.  We know not all the problems, but all 50 posts or more are less than one second of each other in the messages of consolidation.  Our links are set at 40.

    Should raise us this sum and if so, how do we determine how high solve this.  This is a SQL 2008R2 database.

    I can't find anything on this.

    You need to increase the pool of connections for HFM in the hyperion configuration tool... By default, it is set to 40 by application. You can experiment with optimal values, but should help to 80-120. Go to config tool on the HFM node, select Configure the connection to the base. Click Advanced. You will find how to adjust the pool.

    HFM still works perfectly with low, but since he has exhausted the pool, increasing will help.

    Nick

  • Datasource/eis Microsoft SQL Server question

    Hello

    I have 2 sources of data microsoft SQL server in weblogic server, say the DS1 and DS2. I want to talk through connection of the study of environmental impact of the adaptor DB OSB service.

    It is just a table insert.

    While I had created with HIA pointing to DS1, it works fine, then I changed the eis connection to point to the DS2.

    This change does not take effect, is ist always refers to DS1, the data is inserted into the DS1 not DS2.

    I had droppped the DS1 now, so his complain that DS1 is missing.

    OSB server, we need to change the login name of EIS in 3 places, .jca, business service wsdl, service companies file.

    Which means that iam wrong?

    See you soon,.
    Vijay

    I have fixed this issue by increasing the query and Timed Out at 20 under JDBC position options during setup of the DB adapter, you can find it.

    See you soon,.
    Vijay

  • IaaS deployment sql connection error

    Hello

    While the IaaS deployment server, I get this error. could not connect to my SQL Server. Please review the snapshot and advise.

    Thanks in advance.

    The problem is resolved. The SQL Server instance name was incorrect. When named according to the instance of SQL Server, IaaS good server connected to SQL Server and created the database without any problems.

  • SQL * more question: unprinted despite SET ECHO ON command

    RDBMS Version: 11.2.0.4

    OS: Oracle Linux 6.4 (bash shell)

    I'm kinda a newbie to SQL * more.

    Here's a SQL * Plus script embedded in bash script that scales multiple data files. This script has been run on the DB server side.

    #! / bin/bash

    export ORACLE_SID = ORCL1

    echo "resize Datafile began to" 'date '.

    sqlplus "/ as sysdba" < < EOF

    set echo on

    Set of feedback on

    ALTER DATABASE DATAFILE '+ DATA/brfcsprd/datafile/manh_audit_lob.338.834340223' resize 25g;

    ALTER DATABASE DATAFILE '+ DATA/brfcsprd/datafile/manh_audit_lob.337.834340223' resize 25g;

    ALTER DATABASE DATAFILE '+ DATA/brfcsprd/datafile/manh_audit_lob.336.834340225' resize 25g;

    ALTER DATABASE DATAFILE '+ DATA/brfcsprd/datafile/manh_audit_lob.335.834340225' resize 25g;

    ALTER DATABASE DATAFILE '+ DATA/brfcsprd/datafile/manh_audit_lob.334.834340225' resize 25g;

    ALTER DATABASE DATAFILE '+ DATA/brfcsprd/datafile/manh_audit_lob.333.834340225' resize 25g;

    ALTER DATABASE DATAFILE '+ DATA/brfcsprd/datafile/manh_audit_lob.332.834340227' resize 25g;

    quit smoking

    EXPRESSIONS OF FOLKLORE

    echo "resize Datafile ended in" 'date '.

    As you can see, the SQL * more script contains ON SET ECHO ON and PUT your COMMENTS.

    But in the logfile (see below), I don't see every ALTER DATABASE DATAFILE... command printing. I see that ' altered database.'  printing messages.

    I executed the script to nohup as

    nohup resize.sh > MyResize2.log &

    $ cat MyResize2.log

    DataFile resize started at Sun Dec 29 00:09:45 MYT 2013

    SQL * more: Production of the 11.2.0.4.0 on Sun Dec 29 00:09:45 version 2013

    Copyright (c) 1982, 2013, Oracle.  All rights reserved.

    Connected to:

    Oracle Database 11 g Enterprise Edition Release 11.2.0.4.0 - 64 bit Production

    With partitioning, Real Application Clusters, Automatic Storage Management, OLAP,.

    Options of Data Mining and Real Application Testing

    SQL > SQL > SQL > SQL > SQL >

    Database altered.

    SQL >

    Database altered.

    SQL >

    Database altered.

    SQL >

    Database altered.

    SQL >

    Database altered.

    SQL >

    Database altered.

    SQL >

    Database altered.

    Hello

    ECHO applies only to the SQL commands * Plus reads through the @ or the STARTUP command, no statements you type directly in the SQL > prompt or read the bash script statements.

    Try to create a separate file, containing only the command ALTER DATABASE in a separate file (let's call it alter_database.sql for now) and call it from your script bash, like this:

    #! / bin/bash

    export ORACLE_SID = ORCL1

    echo "resize Datafile began to" 'date '.

    sqlplus "/ as sysdba".<>

    set echo on

    Set of feedback on

    @whatever/alter_database

    quit smoking

    EXPRESSIONS OF FOLKLORE

    echo "resize Datafile ended in" 'date '.

Maybe you are looking for