Teradata error message with new line character needs to be passed on as a parameter to a bat file

270 views Asked by At

The below is the error message that is being thrown by Teradata when executing using a bteq script. This error message will be passed on as a parameter to another bat file where it will store this error message to the database.

Here <p> tags and the word Error Message are statically entered. Apart from that the error message returned by the Teradata is having a new line character in the last. Because of this new line character the batch script is unable to read the parameters list properly and the bat script is failing, hence the script is unable to capture the error message.

<p>Error Message:  *** Failure 3807 SP_StoredProcedure:Object 'DB_Name.TableName' does not exist.

</p>

What I need to achieve is that the error message should not contain a new line either when it is generated from the Teradata or the new line should be removed using string parsing operations before passing to the second bat file as parameter. Tried TRIM and REPLACE functions to get rid of the new line characters, but that didn't help. Even after that the new line character is there.

When checked for the symbols present, this is what it shows: enter image description here

Looking for a solution where the error message is free from the new line character when Teradata throughs this error.

1

There are 1 answers

0
Kristie Hudson On BEST ANSWER

By default the value of the .SET WIDTH property is 75 characters. This happens to be declared explicitly by the Teradata.

If the length of the error string returned by the TD BTEQ script is 200 characters. Then everything that is after 75 characters will be moved to another line since the .SET WIDTH 75 marks the end of line after 75 characters, this means a \n is present after 75 characters. Similarly everything after 150 characters will be moved to another line with a \n character and rest of all the characters between 151 and 200 characters will end up on the third line.

A \n i.e. a new line character is not welcome in the parameters of a command task, due to this new line the command task script ends up being broken due to invalid list of input arguments.

To change this use the following in the bteq script:

.SET WIDTH 65531;

The minimum width allowed is .SET WIDTH 20 and the maximum width allowed is .SET WIDTH 65531

The .SET WIDTH property should be defined in the start of the bteq file

For further reference on the same checkout this documentation from TD.