Error
Error Code:
695
SAP S/4HANA Error 695: Deprecated SQL Plan Record Missing
Description
Error 695, 'ERR_SQL_PLAN_STABILITY_RECORD_DOES_NOT_EXIST_DEPRECATED', indicates that the system is attempting to retrieve an SQL plan stability record that is either missing or has been deprecated. This typically occurs when an older or obsolete plan record is referenced, often after system upgrades, database migrations, or manual maintenance activities that remove deprecated features.
Error Message
ERR_SQL_PLAN_STABILITY_RECORD_DOES_NOT_EXIST_DEPRECATED
Known Causes
4 known causesSystem Upgrade or Migration
An upgrade to SAP S/4HANA or its underlying database may have rendered older SQL plan stability records obsolete or removed them during the process.
Manual Cleanup of Deprecated Features
Database administrators might have intentionally removed deprecated plan stability features or records as part of routine system maintenance.
Inconsistent Database State
The database catalog or plan stability tables may be in an inconsistent state, preventing the system from locating existing records.
Missing Configuration or Activation
The specific SQL plan stability feature or a particular plan might not have been properly configured or reactivated after a system change.
Solutions
3 solutions available1. Recreate Missing SQL Plan Stability Record medium
Manually recreate the deprecated SQL plan stability record for the affected SQL statement.
1
Identify the SQL statement that is causing the error. This can often be found in the SAP application logs (SM21) or the database traces.
2
Use the `SYSTOOLS.CREATE_SQL_PLAN_STABILITY` procedure to create a new SQL plan stability record. Replace `SCHEMA_NAME`, `STATEMENT_NAME`, and `SQL_STATEMENT` with the appropriate values.
CALL SYSTOOLS.CREATE_SQL_PLAN_STABILITY('SCHEMA_NAME', 'STATEMENT_NAME', 'SQL_STATEMENT');
3
Verify that the SQL plan stability record has been created by querying the `M_SQL_PLAN_STABILITY` view.
SELECT * FROM M_SQL_PLAN_STABILITY WHERE STATEMENT_NAME = 'STATEMENT_NAME';
4
Restart the affected SAP application or service to ensure the new plan stability record is used.
2. Force Regeneration of the SQL Plan easy
Clear the existing plan and force the database to generate a new one.
1
Identify the SQL statement causing the error, as described in the previous solution.
2
Use the `ALTER SYSTEM CLEAR SQL PLAN CACHE FOR STATEMENT` command to clear the cache for the specific SQL statement. Replace `SQL_STATEMENT` with the actual SQL.
ALTER SYSTEM CLEAR SQL PLAN CACHE FOR STATEMENT 'SQL_STATEMENT';
-- Example: ALTER SYSTEM CLEAR SQL PLAN CACHE FOR STATEMENT 'SELECT * FROM MYTABLE WHERE ID = ?';
3
Execute the SAP transaction or process that triggers the problematic SQL statement. This will force the database to generate a new execution plan.
4
Monitor the SAP application logs and database traces to confirm the error is resolved.
3. Update SAP Kernel and Database Software medium
Ensure your SAP kernel and SAP HANA database are at supported and patched levels.
1
Check the SAP Support Portal (support.sap.com) for the latest recommended SAP kernel patches for your S/4HANA version.
2
Apply the relevant SAP kernel patches using standard SAP patching procedures (e.g., SUM - Software Update Manager).
3
Check the SAP Support Portal for the latest recommended SAP HANA database revision and patches.
4
Apply the SAP HANA database patches and updates following SAP's recommended guidelines.
5
Restart the SAP S/4HANA system and SAP HANA database after applying updates.