---
title: "How to Convert SQL Error into Text"
description: "In this post, I explained SQL logic to convert SQL error into a text message using DSNTIAR."
url: https://srinimf.com/2016/03/07/how-to-convert-sql-error-code-into-text-message-dsntiar/
date: 2016-03-07
modified: 2026-10-10
author: "Srini"
image: https://i0.wp.com/srinimf.com/wp-content/uploads/2016/03/how-to-convert-an-sql-error-into-text-message.jpg?fit=1200%2C700&ssl=1
categories: ["PL/I"]
tags: ["PLI DSNTIAR Calling Logic", "SQL Error Codes"]
type: post
lang: en
---

# How to Convert SQL Error into Text

You can use the subroutine DSNTIAR to convert an SQL return code into a text message. DSNTIAR takes data from the SQLCA, formats it into a message, and places the result in a message output area that you provide in your application program.

Related[INSERT and SELECT How to Use in Single Query](https://srinimf.com/2018/04/04/sql-query-insert-values/)

---

**DSNTIAR syntax:** By calling the DSNTIAR module in the PLI program you can covert error message into Text Message.

```
CALL DSNTIAR ( sqlca, message, lrecl );
```

**The DSNTIAR parameters have the following meanings:**
SQLCA – An SQL communication area.

M**essage**

An output area, in [VARCHAR format](https://srinimf.com/2015/08/15/all-about-mainframe-db2-varchar-field/), in which DSNTIAR places the message text. The first halfword contains the length of the remaining area; its minimum value is 240.

The output lines of text, each line being the length specified in LRECL, are put into this area. For example, you could specify the format of the output area as:

```
DCL DATA_LEN     FIXED BIN(31) INIT(132);
DCL DATA_DIM     FIXED BIN(31) INIT(10);
DCL 1 ERROR_MESSAGE AUTOMATIC,
    3 ERROR_LEN FIXED BIN(15) UNAL INIT((DATA_LEN*DATA_DIM)),
    3 ERROR_TEXT(DATA_DIM) CHAR(DATA_LEN);
⋮
CALL DSNTIAR ( SQLCA, ERROR_MESSAGE, DATA_LEN );
```

Where ERROR_MESSAGE is the name of the message output area, DATA_DIM is the number of lines in the message output area, and DATA_LEN is the length of each line.

Type your email…

Subscribe

### Share this:

-
- [Tweet](https://twitter.com/share)
- [![](https://i0.wp.com/assets.pinterest.com/images/pidgets/pinit_fg_en_rect_gray_20.png)](https://www.pinterest.com/pin/create/link/?url=https%3A%2F%2Fsrinimf.com%2F2016%2F03%2F07%2Fhow-to-convert-sql-error-code-into-text-message-dsntiar%2F&media=https%3A%2F%2Fi0.wp.com%2Fsrinimf.com%2Fwp-content%2Fuploads%2F2016%2F03%2Fhow-to-convert-an-sql-error-into-text-message.jpg%3Ffit%3D1200%252C700%26ssl%3D1&description=How%20to%20Convert%20SQL%20Error%20into%20Text)
-
- [Share on Tumblr](https://www.tumblr.com/share)
- [Share on WhatsApp (Opens in new window) WhatsApp](https://srinimf.com/2016/03/07/how-to-convert-sql-error-code-into-text-message-dsntiar/?share=jetpack-whatsapp)
- [More](#)
-

- [Print (Opens in new window) Print](https://srinimf.com/2016/03/07/how-to-convert-sql-error-code-into-text-message-dsntiar/?share=print)
- [Share on Reddit (Opens in new window) Reddit](https://srinimf.com/2016/03/07/how-to-convert-sql-error-code-into-text-message-dsntiar/?share=reddit)
- [Share on Telegram (Opens in new window) Telegram](https://srinimf.com/2016/03/07/how-to-convert-sql-error-code-into-text-message-dsntiar/?share=telegram)
- [Email a link to a friend (Opens in new window) Email](mailto:?subject=%5BShared%20Post%5D%20How%20to%20Convert%20SQL%20Error%20into%20Text&body=https%3A%2F%2Fsrinimf.com%2F2016%2F03%2F07%2Fhow-to-convert-sql-error-code-into-text-message-dsntiar%2F&share=email)
-

### Like this:

Like Loading…
