Pseudocode: validating a record before insertion
Only insert the record if every validation check left the valid flag true. If any check set valid to false, skip the bad record or report it instead of inserting it.
Understanding Pseudocode: validating a record before insertion in QCE Digital Solutions Unit 2
What it does: The check tests one field. When it fails, it changes the valid flag to false, and the record is then blocked. All checks must pass. One passing check does not prove the whole record is good. Inside a condition, = compares the flag to true. <- is for assignment, not comparison. Bad data should not enter the database. Skipping or reporting it protects data integrity. If the flag is not reset for each record, one bad record would cause every later record to be rejected. Validation comes first so the decision to insert is based on all of the checks, not just some of them.
Common mistakes: The age check is reversed. It flags every positive age as invalid and lets negative ages through. A bad age is one that is less than 0, so it should be: if age < 0 then. After reporting the bad height, the check must set the flag to false so the record is not inserted. Setting it to true leaves a bad record marked as valid. It should be: valid <- false.
Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.
This module's key terms are also in a printable crossword (Modules 234–285) and word search (Modules 234–409).
Take this worksheet further — free with Cloodit
Each concept is reinforced from every angle — learned, then applied, then tested.
Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.
Over 100 of them, across seven natural biomes.
Turns their work into revision material ready for Flash Cards and Exam study.
Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.
Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.
Quick Questions
Match the Pairs
Key Term
if valid = true thenFill in the Blanks
Spot the Error
Student with a class code? Join your class →