Oracle OCI Best Practices
Overview
Use this skill when working with OCI-based data paths (connect, execute, fetch, bind, transaction control) and when configuring Oracle Instant Client across local dev and CI.
OCI implementation rules
- Wrap OCI handles in RAII-style owners to guarantee cleanup.
- Check OCI return codes immediately and include context in diagnostics.
- Keep NLS/session settings explicit instead of relying on ambient defaults.
- Reuse prepared statements and array operations for throughput.
Connection and credential handling
- Prefer secrets/secure config flow instead of embedding credentials.
- Support wallet/TNS-based flows where applicable.
- Keep connection string parsing strict and explicit.
- Cache connections only with clear invalidation/reconnect behavior.
Data-path best practices
- Use array fetch/bind for bulk transfer; tune prefetch/array sizes with measured data.
- Be explicit in LOB and long-text handling.
- Handle Oracle-specific types (for example spatial/vector) via deliberate conversion policies.
- Treat transaction behavior as an explicit contract and test it.
Instant Client and build hygiene
- Ensure both Basic and SDK components are available when compiling OCI-dependent code.
- Keep
ORACLE_HOME/library path handling deterministic in local and CI builds. - Validate platform differences (Linux/macOS/Windows) with dedicated setup scripts.
- Document fallback behavior when OCI libraries are not found.
Validation checklist
- Connection success/failure paths are covered with actionable messages.
- Statement execution paths cover bind, fetch, and error cases.
- Type mappings have targeted tests for edge values.
- Integration tests run against a real Oracle container/environment.
Learn more (official)
- Oracle Call Interface Programmer's Guide (19c): https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/index.html
- Oracle Instant Client install/config docs: https://www.oracle.com/database/technologies/instant-client.html
- Oracle Database Free docs: https://www.oracle.com/database/free/get-started/
- Oracle SQL and datatype references: https://docs.oracle.com/en/database/
微信扫一扫