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

  • Home
  • SEARCH
  • 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 3618288
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T22:43:57+00:00 2026-05-18T22:43:57+00:00

I am working with stored procedures in order to access my db data. I

  • 0

I am working with stored procedures in order to access my db data. I am trying to put the business logic in the code and not in the stored procedures. But I have a case I don’t know how to solve:

I have a table like: Items(item_id, itemd_name, item_price) with 700 items in it.

Now I want to display the client all the items and their names.
Since I develop for web, I don’t want to load all the 700 items, but using paging – 40 items at a time.

(When I am writing “load” I meen that the stored procedure returns datatable and the code I wrote converts each row to an item class – this is why I don’t want to load 700 items, it will proccess many data I don’t really need)

So I wrote stored procedure that knows to get 40 items.

Now, I need to summarized all the items prices and add it 16% tax.

The problem is that I can’t use the 40 items I get from that store procedure because I need to summarize the price+tax of all the 700 items.

The only solution I found is to use another stored procedure that will return the price+tax sum.

  • 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-18T22:43:57+00:00Added an answer on May 18, 2026 at 10:43 pm

    Basically you are using two different stored procedures, for two different (albeit connected) business requirements, and that is OK in my book.

    The first one is: Display a page of the data with a given offset and page size.
    The second one is: Display a data summary according to some rules.

    Both can be done if you use a simple stored proc that just gets all the data, and you can handle the paging and summarizing on the application side, and that will adhere to your “no logic in the database” rule. This wont be much of a problem when you have 700 rows, however, if that number goes into hundreds of thousands, you will have a large performance penalty for loading and processing tons of items you don’t really need.

    A second approach is to put the paging logic is one proc, and the summarizing logic in another. The paging logic is pretty generic, so it does not have to be considered “business”, but the summary generation, in order to be useful, must incorporate real business logic. This will work, performance wise, but clearly breaks your rule.

    Of course, there is no one correct answer, but in most cases, I do not mind putting business logic in the database, because, even the structure of the database is restricted by the business rules of the system. If we want absolutely “no business rules in the database” we should waive default values, check constraints, etc, because they too are business restrictions on the data, those are not properties of the data itself.

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

Sidebar

Related Questions

Is the following stored procedure code robust for multi-user application. It is working fine.
I'm working on mac OS x 10.4 . I have a subversion repository stored
I am trying to convert some of my stored procedures to Linq and am
I have an assortment of database objects (tables, functions, views, stored procedures) each scripted
I'm working on a project where I have to take data from one source
I have the following stored procedure that I working on. I have noticed that
We have two distinct agile teams, each working on separate, but related, applications. Each
i have a question on stored procedures. I try to get a page of
I'm new to SQL and am now working with stored procedures. I was watching
I have a set of stored procedures that I am using to populate an

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.