# sql: Rows are closed

- **ID:** `go/database-sql-rows-closed`
- **Domain:** go
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

Attempting to call Next() or Scan() on a sql.Rows object after it has been closed, either explicitly or due to an error.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 1.15 | active | — | — |
| 1.20 | active | — | — |

## Workarounds

1. **** (95% success)
   ```
   Always check errors and call rows.Close() in defer: defer rows.Close(); for rows.Next() { ... }
   ```
2. **** (90% success)
   ```
   Check rows.Err() after iteration: if err := rows.Err(); err != nil { handleErr(err) }
   ```

## Dead Ends

- **** — Rows are already closed; further calls will panic or return stale data. (90% fail)
- **** — May cause data inconsistency and resource leaks if not handled properly. (60% fail)
