5025

FlowFields Without the N+1

Performance
Medium
Pro
flowfield
n-plus-one
customer
sql-budget

FlowFields Without the N+1

Credit control starts every morning from the balance digest: one line per customer of the region — number, name, and what they currently owe. The lines come out right, but the DBA's trace glows: inside the loop, one extra little SELECT fires against the ledger for every single customer. Forty customers, forty-one statements — the textbook N+1, born the moment a per-row lookup lands inside a loop.

Your job: the same lines, a handful of statements.

Requirements

Create a codeunit named "Customer Balance Digest" with one public procedure:

procedure BuildDigest(var Customer: Record Customer): List of [Text]

The procedure receives a Customer record whose filters the caller has already set, and nothing has been read into it yet. Do the pass inside those filters.

Rules:

  1. Return one line per matching customer, in ascending "No." order: the customer's "No.", Name and balance joined by | (pipe), no extra spaces — e.g. TRYAL-1|Alice Smith|250.75.
The rest of the statement and 3 hints Unlock with Pro
ALBusiness Central 28.5
Pro
Pro problem

Solve it with Pro

You’re reading the opening of the statement. Pro unlocks the whole problem:

  • The full statement
  • Starter code in the browser editor
  • 7 grading tests, run on Business Central 28.5
  • 3 hints
  • The reference solution

Pro also opens all 92 Pro problems and lifts the daily limits on compile checks and submissions.

$10 / month
or $100 / year
Upgrade
This problem is part of Pro
Pro unlocks the full statement, tests, hints and solution. The code editor works on a computer.
Upgrade