0

I am working on converting oracle queries to maria db. There is no hierarchical queries like "start with...connect by..." in MariaDB. So I had to create queries similar to "start with... " But it looks hard. Can you guys help me?

SELECT *
       FROM
           (SELECT T2.JOB_TYPE, 
                   T2.COMPONENT_TYPE,
                   T1.POOL_SEQ,
                   FN_GET_CODE_VALUE('componenttype',T2.COMPONENT_TYPE) AS COMPONENT_TYPE_NM,
                   MIN(T1.WORKFLOW_SEQ)WORKFLOW_SEQ,
                   MIN(T1.UPPER_WORKFLOW_SEQ)UPPER_WORKFLOW_SEQ,
                   MAX(T1.DEFAULT_JOB_SEQ)DEFAULT_JOB_SEQ,
                   T1.WORKFLOW_TYPE,
                   /*   MAX(T1.WORKFLOW_TYPE)WORKFLOW_TYPE, */
                   COUNT(CASE T1.JOB_STATE WHEN '01' THEN 1 END)STATE_01_CNT,
                   COUNT(CASE T1.JOB_STATE WHEN '02' THEN 1 END)STATE_02_CNT,
                   COUNT(CASE T1.JOB_STATE WHEN '03' THEN 1 END)STATE_03_CNT,
                   COUNT(CASE T1.JOB_RESULT WHEN '20' THEN 1 END)ERCNT,
                   COUNT(CASE T1.JOB_RESULT WHEN '10' THEN 1 END)END_CNT,
                   COUNT(*)TOT_CNT
                   /*   ,MAX(T1.POOL_SEQ)POOL_SEQ   */
              FROM JOB_TBL T1,
                   SERVER_POOL_TBL T2
             WHERE T1.POOL_SEQ =  T2.POOL_SEQ

          )T
  START WITH UPPER_WORKFLOW_SEQ IS NULL
CONNECT BY UPPER_WORKFLOW_SEQ = PRIOR WORKFLOW_SEQ
1
  • I don't think Maria DB has an equivalent of connect by.. though you can implement it in a procedure or function. Commented Jul 25, 2017 at 8:57

1 Answer 1

0

Use Recirsive CTE. connect by is Oracle proprietary extension, introduced before CTEs were "invented". Recursive CTEs are also more generic.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.