Results 1 to 1 of 1
  1. #1
    Join Date
    Feb 2016

    Unanswered: Bill of Material in Sybase (NOT ASE)

    Bill of material - i.e. generate a tree, is a know problem and in most current databases (including ASE) it is solved with recursive CTE like this example (which I plucked from the internet and modified a bit)

    ;WITH BOMcte(joid, job_Name, type, source, Lvl, job_source, Sort)
    SELECT WQ.jobid, job_name, WQ.type, WQ.source, 1 as lvl, WQ.job_source, '\' + WQ.job_name as aort
    FROM V_nodes_and_edges AS WQ
    WHERE WQ.jobid = 768
    --AND WQ.job_source IS NULL
    SELECT WQ.jobid, REPLICATE('| ', Lvl) + WQ.job_name, WQ.type, WQ.source, Lvl + 1, WQ.job_source, Sort + '\' + WQ.job_name
    FROM V_nodes_and_edges AS WQ
    JOIN BOMcte AS cte
    ON WQ.job_source = cte.jobid
    SELECT Lvl, job_Name, type, source, Sort
    FROM BOMcte
    ORDER BY Sort;

    My employer uses regular Sybase that does not support that stuff. Could somebody please guide me to how to do that
    Last edited by zatlas1; 02-02-16 at 14:25.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts