How to convert the hierarchical query of SQL Server (CTE) to Oracle?

How to convert the hierarchical query of SQL Server (CTE) to Oracle?

WITH cte (col1, col2) AS
(
SELECT col1, col2
FROM dbo. [tb1]
WHERE col1 = 12
UNION ALL
SELECT c.col1, c.col2
FROM dbo. [tb1] AS c INNER JOIN cte AS p ON c.col2 = p.col1
)
DELETE one
FROM dbo. [tb1] AS an INNER JOIN b cte
ON a.col1 = b.col1

Hello
Something like this maybe:

DELETE FROM dbo.tb1 a
 WHERE EXISTS (
  SELECT 1
    FROM dbo.tb1 b
  WHERE a.co11 = b.col1
      AND a.col2 = b.col2
   START WITH b.col1 = 12
  CONNECT BY b.col2 = PRIOR b.col1)

Although you need to do here is to check that CONNECT it BY SELECT, returns records you wait first, then the DELETION should work too.

Tags: Database

Similar Questions

  • Different output for the same query in SQL Server and Oracle

    I have two tables table1 and table2

    -table1 has two columns c1 int and varchar c2. There are no constraints added in it. It contains data as shown below

    C1 c2
    -------------------
    d 6
    5 d
    102 g
    6%
    f 103
    5.
    501 j
    1 g
    601 n
    2 m

    -table2 has only a single column c1 int. There is no added in constraints. It contains data as shown below

    C1
    ----
    6
    1
    4
    3
    2

    now when I run below, given the query in sql server and oracle it gives me different results

    Select *.
    FROM table1
    table2 on table2.c1 = table1.c1 inner join (SELECT ROW_NUMBER() (any ORDER by ASC c1) AS c1 from table2)

    output of SQL server
    ------------------------
    C1 c2 c1
    --------------------------------
    1 g 1
    2 m 2
    3 h 3
    4 g 4
    5 d 5


    release of Oracle
    ----------------------
    C1 C2 C1
    ---------------------------------
    5 d 5
    4 g 4
    3 h 3
    1 g 1
    2 m 2


    If you notice the first column in the two outputs. It is sorted in sql server and no oracle.

    Why he behaves differently in oracle? Is there a way I can fix this problem in oracle?

    Thank you
    Jigs

    It is NOT a behavior "differently" in Oracle; you did not specify just an order that you expect of your results, so you'll get output in what order the fantasies of the database showing (ie. no guaranteed order). It is an artifact of the way the database chooses to collect the data and databases (or same sets of data within the same database) can and will most likely behave differently.

    Same SQL Server will not be guaranteed to always get your data in an orderly manner if you exclude the order by clause, even if you think that there always display the data in an orderly manner.

    Your solution is to add an order by clause, in the TWO databases, to force the order of the data output.

  • How to combine the 2 tables in sql server 2008?

    Tell me how to combine 2 tables in sql server. and give me an example, I am a beginner again.

    You can get a faster or better response if you ask one of the instances of SQL Server dedicated from Microsoft here:

    http://social.technet.microsoft.com/Forums/en-us/category/sqlserver .

    (I'm sorry, but I can't move this thread for you because the two forums are working on separate platforms)

  • How to install the driver jdbc for sql server 2005 in sql developer 4.0?


    Hallo all

    I need to access the tables in a MS SQL Server 2005 database.

    The JDBC driver is possible.

    How to install this driver?

    Thanks a lot for your messages.

    Hello

    It's the documentation-

    Database: third-party JDBC Drivers

    The component drivers JDBC third party specifies drivers to use for connections to the third-party databases (non-Oracle), such as IBM DB2, MySQL, Microsoft SQL Server or Sybase Adaptive Server. (You don't need to add a driver for connections to Microsoft Access databases.) To add a driver, click Add an entry and select the path for the driver:

    For Microsoft SQL Server or Sybase Adaptive Server: jtds - 1.2.jar, which is included in the download of jtds - 1.2 - dist.zip

    To find a specific third-party driver, visit the appropriate site (for example, http://www.mysql.com for MySQL Connector/J JDBC driver for MySQL, http://jtds.sourceforge.net/ for the for Microsoft SQL Server and Sybase Adaptive Server jTDS driver, or search for Teradata JDBC driver to http://www.teradata.com/ ). For MySQL, use the driver in MySQL 5.0 not 5.1 or a later version with the version of SQL Developer 1.5.

    You must specify a third-party driver or install a driver using the check for updates feature before you can create a connection to a database to third parties of the associated type. (See the tabs to create connections to the databases of third parties in the Create/Edit/Select database connection dialog box).

    Alternative:

    As an alternative to the use of this preference, you can click Help, and then search for the updates install the for Microsoft SQL Server JTDS JDBC driver and the driver of JDBE of MySQL as extensions.

    Kind regards

    Mike

  • How to avoid the SEPARATE in OBIEE SQL

    Hello...

    For the issue I posted previously...
    Problem with the data type LONG in responses

    I executed the query into a FROG, and I've identified the error because of what this error is coming... because of SEPARATE...
    I took care to avoid this column in ORDER BY putting order on another column...

    Now my question is how to avoid the DISTINCT clause in SQL generated by OBIEE...
    If the first column of criteria is then it avoids the SEPARATE... but if I use measure... Group of will come... and group of should not be used here...

    If it's done... my problem is solved...
    Of course... I get duplicate rows...

    However, I want the answer how avoid SEPARATE?
    Waiting for the response from your...

    Thanks and greetings
    Kishore Guggilla

    Kishore,

    In the physical layer, open the properties of physical catalog and in the features tab find DISTINCT_SUPPORTED and remove the check box value.

    who removed separate in each query generated for this database.

    -Madan

  • How to convert the precision extended float to float in C++

    Hello

    Could someone me please how to convert the extended precision (floatExt) float normal float in C++?

    What is the difference in the float between Labview and C++ data type?

    When I tried to receive a range of float of a function of the DLL generated by Labview in C++, data are bad.

    Thank you

    Victor King

    You can search for numeric data types in LabVIEW help for more information on the different types of data. Before sending the data to the C++ application, you can use the function of Double precision on digital / range of Conversion to convert number to Double precision.

  • Error message when I run delete the query in SQL Server 2008.

    Error message when I run delete the query in SQL Server 2008 SP3.

    Error message:

    MSG 0, level 11, State 0, line 0
    A serious error occurred on the current command.  The results, if any, should be discarded.

    I never got any problem since 5 years.

    Please let me know what is the cause of the problem.

    You can get a response better/faster if repost you your question in the instances of SQL Server dedicated from Microsoft here:

    http://social.technet.microsoft.com/Forums/en-us/category/sqlserver .

    Thank you.   :)

    (I'm sorry, but I can't move this thread for you because the two forums are working on separate platforms)

  • How to convert the date in milliseconds?

    Hi all

    Can I know how to convert the date in milliseconds?

    My current datetime like this Formate

    QDateTime::currentDateTime (m:System.NET.SocketAddress.ToString ("MMMM dd, yyyy HH"))

    Seconds since January 1, 1970

    http://Qt-project.org/doc/Qt-4.8/QDateTime.html#toTime_t

    Sinds milliseconds January 1, 1970

    http://Qt-project.org/doc/Qt-4.8/QDateTime.html#toMSecsSinceEpoch

  • Please how to convert the photo to the second

    2012-Kia-Rio-SX-side1.jpg11707850_10153403835594354_514303523436587694_n-1.jpg

    Please guys how to convert the kia rio pictures the second perfect like this, and with any program, I know that all steps in details please its very important

    That looks just like you would use the tool pen to redraw on the image and create shape layers (black areas). It could be done in Photoshop or Illustrator.

    Using Photoshop | Draw with the pen tools

  • Hello, I have a full desktop in Adobe Muse, site and I want to convert it into a version Tablet & phone, then, how would convert the site Office to Tablet & phone to copy the entire office content and site structure? Thanks for any help.

    Hello, I have a full desktop in Adobe Muse, site and I want to convert it into a version Tablet & phone, then, how would convert the site Office to Tablet & phone to copy the entire office content and site structure? Thanks for any help.

    You can not automatically convert. Click on the "tablet" or "Phone" at the top of your plan view to create these versions.

    You can then copy and paste on any content you want has more of your office.

  • How to convert the following code in as3?

    As the title says... How to convert the following code to as3?... Thanks in advance.

    import flash.display.BitmapData;

    linkageId = "landscape";
    myBitmapData = BitmapData.loadBitmap (linkageId);


    MC = this.createEmptyMovieClip ("mc", 1);
    mc.attachBitmap (myBitmapData, 1);

    onMouseMove = function() {}
    myNewColor = "0 x" + myBitmapData.getPixel(_xmouse,_ymouse).toString (16);
    newColor.setRGB (myNewColor);
    selectedColor.colorValue.text = myNewColor;
    }
    selectedColor.swapDepths (_root.getNextHighestDepth ());
    newColor = new Color (selectedColor.sample);

    :

    var myBitmapData:landscape = new landscape (0,0);

    var bmp:Bitmap = new Bitmap (myBitmapData);
    addChild (bmp);

    stage.addEventListener (MouseEvent.MOUSE_MOVE, f);

    function f(e:MouseEvent):void {}
    var myNewColor:String = "0 x" + myBitmapData.getPixel(mouseX,mouseY).toString (16);
    newColorTransform.color = uint (myNewColor);
    selectedColor.sample.transform.colorTransform = newColorTransform;
    selectedColor.colorValue.text = myNewColor;
    }
    addChild (selectedColor);
    var newColorTransform:ColorTransform = selectedColor.sample.transform.colorTransform;

  • I have some problem in my query to sql server. If I press f5 to run it opens to record dialogue area nd do not run (I don't get successful... orders etc). Please help me

    I have some problem in my query to sql server. If I press f5 to run it opens to record dialogue area nd do not run (I don't get successful... orders etc). Please help me

    Hello

    SQL Server is not supported in these forums. I suggest that you ask your question again in one of the forums dedicated to Microsoft for him here:

    http://social.technet.microsoft.com/Forums/en-us/category/sqlserver .

    Thank you.   :)

  • How to configure the LDAP connector in windows server 2012 R2 Active Directory?

    How to configure the LDAP connector in windows server 2012 R2 Active Directory?

    Hello

    Please post your question in Server TechNet Forums.

    http://social.technet.Microsoft.com/forums/WindowsServer/en-us/home?category=WindowsServer

    See you soon.

  • What is the date of end SQL server 2008 SP2 support?

    What is the date of end SQL server 2008 SP2 support?

    Have you tried Google? or:

    ASK THE QUESTION IN THE SQL SERVER FORUM:
    http://social.msdn.Microsoft.com/forums/en/category/SQLServer

  • How to deploy the project to my weblogic Server Application?

    How to deploy the project in my weblogic Server Application? Wouldn't be great if I copy the folder of the project to the root of the ACE?

    Also, how should I call Javascript context help assuming the project deployed to Weblogic As.

    I use Robohelp 10.

    Thanks in advance.

    Hello

    You generate to help and then you copy the output generated on the server.

    For sensitivity to context, which is output are you using? Try the following

    pages for more information:

    Take a bow

    Willam

Maybe you are looking for

  • Pavilion 510-p127c: I can install an additional hard drive in the model 510-p127c

    Is there a space to install a second hard drive for storage in the PC?

  • Specified sample rate clock works do not

    I hope that I was right to post on this forum. I have a problem that I had not previously in the acquisition of data on a chassis 9172 cDAQ using a 9234 for 2 analog inputs and a 9219 for four thermocouple inputs. The 9219 is obviously not ideal as i

  • the upgrade of T430s to with an SSD

    I currently have a computer 14 "laptop T430s with a hard drive. I plan to upgrade to an SSD. My question is, in any 2.5 "SSD will be compatible with my laptop? Currently, I am planning to buy Samsung 840 EVO. I'm not sure if it is compatible (in term

  • I need the part number of optical drive for my new Aspire E5-573-5653.

    I need the optical drive part number for my new Aspire E5-573-5653, I bought it for my son without realizing he did not have. I would buy it and install it. Thank you.

  • A520 printer and Mac

    Recently I had to reload OSX Mavericks. Then when I tried to reinstall the printer I get say error message "unable to install the software because it is currently not avaialbe from the software update server. Any ideas? I don't know if it's a questio