Raw SQL
For specialized use cases, you can execute raw SQL through the ORM client.
rawQuery()
ballerina
stream<record {}, error?>|error result = db.rawQuery(
"SELECT * FROM users WHERE created_at > ? ORDER BY email",
["2026-01-01"]
);
if result is stream<record {}, error?> {
record {}[] rows = check from var row in result select row;
}rawExecute()
ballerina
int|error affected = db.rawExecute(
"UPDATE users SET status = ? WHERE id = ?",
["ACTIVE", 101]
);Parameterization guidance
- never concatenate untrusted input into SQL text
- always pass values via params arrays
- prefer query builder for routine CRUD and filtering
Next step
Move to Annotations Reference.