Error
Error Code: 696

SAP S/4HANA Error 696: Deprecated SQL Plan Conversion

📦 SAP S/4HANA
📋

Description

This error indicates a failure to convert an existing SQL execution plan into an abstract plan, specifically flagging a deprecated plan stability feature. It typically occurs during database operations where the system attempts to optimize queries using outdated plan stability mechanisms, leading to performance issues or failed transactions.
💬

Error Message

ERR_SQL_PLAN_STABILITY_CANNOT_CONVERT_ABSTRACT_PLAN_DEPRECATED
🔍

Known Causes

4 known causes
⚠️
Outdated Database Statistics
The database optimizer relies on current statistics to generate efficient execution plans. Stale statistics can lead to attempts to use or convert deprecated plans, triggering the error.
⚠️
Incorrect System Configuration
Misconfigurations related to SQL plan management parameters or database optimizer settings can cause conflicts when interacting with deprecated plan stability features.
⚠️
Post-Upgrade/Migration Impact
After a database upgrade or migration, deprecated plan stability features might conflict with new optimizer logic, causing conversion failures if not properly addressed.
⚠️
Corrupted Plan Cache Entries
Corruption within the database's SQL plan cache can prevent the system from properly converting or utilizing existing execution plans, especially if they are marked as deprecated.
🛠️

Solutions

3 solutions available

1. Re-create SQL Plan Baseline for the Failing Statement medium

This solution involves identifying the problematic SQL statement and then recreating its SQL plan baseline to ensure stability.

1
Identify the SQL statement causing the error. This can often be found in the SAP application logs (SM21), Work Process traces (ST11), or the database alert log.
2
Once the statement is identified, use SQL Developer or another database tool to capture its current execution plan.
3
Use the `DBMS_SPM.CREATE_STAB_PLAN` or `DBMS_SPM.CREATE_PLAN_FROM_CURSOR` procedure to create a new SQL plan baseline for the identified statement. Replace placeholders with actual values.
DECLARE
  l_sql_text VARCHAR2(32767);
  l_plan_name VARCHAR2(30);
BEGIN
  -- Replace with the actual SQL text of the failing statement
  l_sql_text := 'SELECT * FROM YOUR_TABLE WHERE YOUR_COLUMN = :1';
  
  -- Optionally provide a name for the plan
  l_plan_name := 'PLAN_FOR_ERR_696';
  
  DBMS_SPM.CREATE_STAB_PLAN(
    sql_handle => DBMS_SPM.GET_HANDLE_FROM_SQL(l_sql_text),
    plan_name => l_plan_name
  );
  DBMS_OUTPUT.PUT_LINE('SQL Plan Baseline created for the statement.');
END;
/
4
Verify that the new SQL plan baseline has been created and is active using the `DBA_SQL_PLAN_BASELINES` view.
SELECT sql_handle, plan_name, enabled, accepted, origin 
FROM dba_sql_plan_baselines 
WHERE plan_name = 'PLAN_FOR_ERR_696';
5
Test the SAP transaction or process that was previously failing to confirm the error is resolved.

2. Disable SQL Plan Management for the Failing Statement easy

As a temporary workaround or if plan stability is not critical for a specific statement, disabling its SQL plan management can resolve the error.

1
Identify the SQL statement causing the error (refer to Solution 1, Step 1).
2
Use the `DBMS_SPM.DROP_SQL_PLAN_BASELINE` procedure to remove the existing plan baseline for the statement. Replace placeholders.
DECLARE
  l_sql_text VARCHAR2(32767);
BEGIN
  -- Replace with the actual SQL text of the failing statement
  l_sql_text := 'SELECT * FROM YOUR_TABLE WHERE YOUR_COLUMN = :1';
  
  DBMS_SPM.DROP_SQL_PLAN_BASELINE(
    sql_handle => DBMS_SPM.GET_HANDLE_FROM_SQL(l_sql_text)
  );
  DBMS_OUTPUT.PUT_LINE('SQL Plan Baseline dropped for the statement.');
END;
/
3
Alternatively, you can disable the plan baseline without dropping it, which is less disruptive if you intend to re-enable it later. Use `DBMS_SPM.ALTER_SQL_PLAN_BASELINE`.
DECLARE
  l_sql_text VARCHAR2(32767);
BEGIN
  -- Replace with the actual SQL text of the failing statement
  l_sql_text := 'SELECT * FROM YOUR_TABLE WHERE YOUR_COLUMN = :1';
  
  DBMS_SPM.ALTER_SQL_PLAN_BASELINE(
    sql_handle => DBMS_SPM.GET_HANDLE_FROM_SQL(l_sql_text),
    attribute_name => 'ENABLED',
    attribute_value => 'NO'
  );
  DBMS_OUTPUT.PUT_LINE('SQL Plan Baseline disabled for the statement.');
END;
/
4
Test the SAP transaction or process to confirm the error is resolved. Note that this might lead to plan instability for the statement in the future.

3. Update SAP Kernel and Database Software advanced

This is a more comprehensive solution that addresses potential underlying bugs in older versions of SAP kernel or Oracle database.

1
Consult SAP Notes related to error code 696 and SQL plan stability for your specific S/4HANA version and Oracle database version. Identify any recommended SAP kernel patches or updates.
2
Plan and schedule a downtime window for the SAP system.
3
Apply the recommended SAP kernel patches or upgrade the SAP kernel according to SAP's guidelines.
4
Check for and apply any recommended Oracle database patches or minor version upgrades that are certified by SAP for your S/4HANA environment.
5
After the system is back online, monitor the application and database for any recurrence of error 696. It's also good practice to re-evaluate SQL plan baselines after significant software updates.
🔗

Related Errors

5 related errors