Skip to Content

Recursive Query in HANA

Hello,

In SQL SERVER i have a recursive query to compose a tree of Bill of materials SAP B1.

Please can you tell me how I can get the same query in HANA?

WITH RecursiveSQL as (

    SELECT 1 as Level,OITT.Code as ABSCODE,OITT.Code,ITT1.Code as ITEMCODE,ITT1.Quantity FROM OITT INNER JOIN ITT1 ON OITT.Code = ITT1.Father

    UNION ALL

    SELECT RecursiveSQL.Level + 1 as Level, RecursiveSQL.ABSCODE, OITT.Code,ITT1.Code as ITEMCODE,ITT1.Quantity FROM RecursiveSQL INNER JOIN OITT ON RecursiveSQL.ITEMCODE = OITT.Code INNER JOIN ITT1 ON OITT.Code = ITT1.Father

)

SELECT * FROM RecursiveSQL WHERE ABSCODE = '0021142-5252-3-00XXL' Order by Level

Many Thanks for your help.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Sep 05, 2013 at 11:31 AM

    Thanks for your comments, but I think OPTION (MAXRECURSION n) is not HANA syntax.

    What I am looking for is the syntax for SAP HANA  to obtain the same result (a recursive query) as in SQL Server.

    Thank you very much.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 05, 2013 at 09:58 AM

    Hi

    You can use OPTION(MAXRECURSION n)

    Regards

    NK


    Add comment
    10|10000 characters needed characters exceeded