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 6011891
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T02:19:29+00:00 2026-05-23T02:19:29+00:00

Good morning. I’ll do my best to explain my question without posting the SQL

  • 0

Good morning. I’ll do my best to explain my question without posting the SQL (it’s 650 lines). Let me know if more information is needed.

We have an in-house fulfillment system that is allocating inventory in real time. For allocation to work properly, we need to know how much inventory is available each time a user asks what they should be working on (by loading/reloading their task list). The data would look something like this:

ID    ItemID    QtyOrdered    QtyAvailableAfterAllocation    ParentID
1     1234      5             500                            NULL
2     1234      15            485                            1
3     1234      10            475                            2

Currently a while loop is being used to set the QtyAvailableAfterAllocation column. The example above demonstrates the need for the loop. Row 2’s QtyAvailableAfterAllocation is dependent on the value of row 1’s QtyAvailableAfterAllocation. Row 3 is dependent on row 2 and so on.

This is the (very) simplified version of the logic. It gets infinitely more complicated when you take into account kits (groups of inventory items that belong to a single parent item). There are times that inventory does not need to be allocated to the item because it exists inside of a kit that has sufficient inventory to fulfill the order. This is why we can’t do a running total. Also, kits could be nested inside of kits to the Nth level. Therein lies the problem. When dealing with a large amount of orders that have nested kits, the performance of the query is very poor. I believe that the loop is to blame (testing has proved this). So, here’s the question:

Is it possible to commit an update, one row at a time and in a specific order (without a loop), so that the child record(s) below can access the updated column (QtyAvailAfterOrder_AllocationScope) in the parent record?

EDIT

Here is a small portion of the SQL. It’s the actual while loop. Maybe this will help show the logic that’s needed to determine the allocation for each record.

http://pastebin.com/VM9iasq9

  • 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-05-23T02:19:30+00:00Added an answer on May 23, 2026 at 2:19 am

    Based on the comments/answers above and my inability to accurately represent this complicated issue properly, I’ve rewritten the processing in C#. Using PLINQ, I’ve reduced the processing time from 15 seconds to 4. Thanks to all those who tried to help!

    If this isn’t the appropriate way to close a question, let me know (and let me know the appropriate way so I can do that instead).

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

Sidebar

Related Questions

Good Morning, Quick CSS question. Does anyone know any quick css to make an
Good morning, Apologies for the newbie question. I'm just getting started with ASP.NET internationalization
Good morning ! What is the best way to remove duplicate records from grid
Good morning/afternoon, Not so much a problem but more of a query. If I
Good morning. After having read the answer on a question about optimizing Excel Interop
Good Morning All, I have an Objective C question that is coming from JavaScript.
Good morning, I'm studing the SQL, and today I've found two ways of declaring
Good morning SO, So I have a simple question I can't seem to find
Good Morning All, I'm trying to refactor an SQL stored procedure. I'm no SQL
Good morning, I am about to start writing an Excel add-in for Excel 2002.

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.