Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8045247
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T05:29:13+00:00 2026-06-05T05:29:13+00:00

After some previous help on how to approach a problem I am having with

  • 0

After some previous help on how to approach a problem I am having with some legacy code, it seems like the best approach for my issue is to concatenate case statements to return a value I can parse out in PHP.

I am trying to do something like this, but it is returning many rows, and eventually getting this error:

Maximum stored procedure, function, trigger, or view nesting level
exceeded (limit 32).

SELECT org.org_id,
       org.org_name_1,
       Datename(YEAR, member.enroll_date) AS enroll_year,
       Max(CASE
             WHEN board.member_from IS NULL THEN 0
             ELSE 1
           END)                           AS board_member,
       CASE
         WHEN ( org.delete_reason = 'OUT'
                AND org.org_delete_flag = 'Y'
                AND org.org_status_flag = 'C' ) THEN 'out_of_business|'
         ELSE ''
       END + CASE
               WHEN ( stat.carrier = 'BS'
                      AND stat.status_id IS NOT NULL
                      AND stat.termination_date IS NULL
                      AND stat.flat_dues > 0 ) THEN 'insurance_member|'
               ELSE ''
             END + CASE
                     WHEN ( stat.carrier = 'BS'
                            AND stat.status_id IS NOT NULL
                            AND stat.termination_date IS NULL
                            AND stat.flat_dues = 0
                            AND member.status_flag IN( 'C', 'P' ) ) THEN 'insurance_product|'
                     ELSE ''
                   END + CASE
                           WHEN ( member.enroll_date IS NOT NULL
                                  AND member.status_flag NOT IN( 'C', 'P' ) ) THEN 'member_since|'
                           ELSE ''
                         END + CASE
                                 WHEN ( org.org_relationship_parent = 'Y'
                                        AND org.dues_category = 'MBR'
                                        AND org.org_status_flag = 'R' ) THEN 'subsidiary_member|'
                                 ELSE ''
                               END + CASE
                                       WHEN ( org.org_misc_data_9 = 'PAC' ) THEN 'pac|'
                                       ELSE ''
                                     END + CASE
                                             WHEN ( org.dues_category = 'PART' ) THEN 'partner_member|'
                                             ELSE ''
                                           END + CASE
                                                   WHEN ( org.dues_category = 'FREE'
                                                          AND org.org_status_flag = 'P' ) THEN 'associate_member|'
                                                   ELSE ''
                                                 END
                                          --ELSE 'non_member'
                                          --END 
                                          AS org_status,
       60                                 AS expires_in,
       CASE
         WHEN stat.dues_type = 'M' THEN
           CASE
             WHEN ( stat.termination_date IS NULL ) THEN ( stat.flat_dues )
             ELSE 0
           END
         ELSE
           CASE
             WHEN ( member.payments = 0 ) THEN member.dues_billed_annual
             ELSE member.payments
           END
       END                                AS dues_level,
       CASE
         WHEN ( org.affiliate_code = 'PCCE'
                AND org.dues_category = 'MBR'
                AND org.org_status_flag = 'R' ) THEN 1
         ELSE 0
       END                                AS pcce_membr,
       --          '$'+CONVERT(VARCHAR,@dues) AS dues_level,
       Ltrim(@product_level)              AS product_level,
       Ltrim(@involve_level)              AS involvement_level
FROM   organiz AS org
       LEFT JOIN affilbil AS member
         ON member.status_id = org.org_id
            AND member.dues_category = 'MBR'
       LEFT JOIN individu AS ind
         ON ind.org_id = org.org_id
       LEFT JOIN commembr AS board
         ON board.status_id = ind.ind_id
            AND board.committee_code = '5'
            AND board.member_to IS NULL
       LEFT JOIN statinsmorn AS stat
         ON stat.status_id = org.org_id
            AND stat.carrier = 'BS'
            AND stat.planz = 'PCI'
WHERE  org.org_id = @org_id
GROUP  BY org.org_id,
          org.org_name_1,
          member.enroll_date,
          org.delete_reason,
          org.org_status_flag,
          org.org_delete_flag,
          stat.status_id,
          stat.flat_dues,
          stat.dues_type,
          stat.termination_date,
          org.org_misc_data_9,
          org_relationship_parent,
          org.dues_category,
          member.status_flag,
          member.dues_billed_annual,
          member.payments,
          stat.carrier,
          org.Affiliate_Code 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T05:29:15+00:00Added an answer on June 5, 2026 at 5:29 am

    Well, this is embarrassing.

    When I was making my changes to the stored procedure, I had inadvertently placed a call to the same procedure at the bottom. So I was recursively calling the same procedure over and over again. DOH.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

After some code review I removed unnecessary properties which resulted in empty rules. So
after some advice regarding a problem i am getting using a linux based piece
Ok after my previous post, i have made some progress, yet still i need
After my previous question (http://stackoverflow.com/questions/8217522/best-way-to-search-for-partial-words-in-large-mysql-dataset), I've chosen Sphinx as the search engine above my
After some research about algorithms I found two terms which confuses me. I've read
After some research, I can't find anything on super classes, so I decided to
After some experience with functional languages, I'm starting to use recursion more in Java
after some processing my program shows a messagebox saying you can read a log
After some use Visual Studio 2008 when opening a solution that is checked into
After some reading and R&D, I have came to conclusion that ? Forms in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.