---
slug: /limitations-of-exception-handling
---

# Limitations of exception handling

The PL feature of seekdb has usage limitations when handling exceptions.

The PL feature of seekdb has the following usage limitations when handling exceptions:

* `SIGNAL`, `RESIGNAL`, and `GET DIAGNOSTICS` cannot be used in prepared statements. The following example is invalid:

  ```sql
  PREPARE stmt1 FROM 'SIGNAL SQLSTATE "42000"';
  ```

* `SQLSTATE` values of class '04' are not specially handled and are treated the same as other exceptions.

* In standard SQL, the first condition should be related to the `SQLSTATE` value returned by the previous SQL statement, but this is not always guaranteed. Therefore, the following statement cannot be used to obtain the main error information:

  ```sql
  GET DIAGNOSTICS CONDITION 1 @err_no = MYSQL_ERRNO;
  ```

  Instead, the following method is recommended:

  ```sql
  GET DIAGNOSTICS @count_no = NUMBER;
  GET DIAGNOSTICS CONDITION @count_no @err_no = MYSQL_ERRNO;
  ```