Named queries beat script soup
SQL buried inside button and tag scripts is a refactor trap. Named queries pay for themselves the first time you have to touch one.
The problem with inline SQL
String-built queries scattered through scripts cause real pain:
- The same query gets copy-pasted in five places and drifts out of sync.
- Hand-concatenated parameters invite SQL injection and quiet type bugs.
- There's no central place to see, test or optimize what's actually hitting the database.
Why named queries
Named queries move the SQL into the project where it belongs:
- Typed parameters with built-in protection against injection.
- One definition, called from anywhere — fix it once.
- Optional caching and per-query security.
- Testable right in the Designer with sample parameters, no live screen needed.
rows = system.db.runNamedQuery("orders/OpenByLine", {"line": lineId})
Migrating without a big bang
You don't have to convert everything at once. Move the hot, duplicated queries first — the ones you change most — and wrap them as named queries. New work goes straight to named queries. Over a few sprints the script soup quietly disappears.
Inherited a project full of inline SQL? I clean these up without a rewrite.
Contact us