WHat's the equivalent to RAISEERROR ?

Database
Enthusiast

WHat's the equivalent to RAISEERROR ?

In SQL Server stored procs, it was easy to get the count of the records processed, and if the resulting count was zero, then RAISE an error to abort the process and tell the scheduler that RTL steop failed.

How to do in Teradata ?

 


Accepted Solutions
Teradata Employee

Re: WHat's the equivalent to RAISEERROR ?

Upon completion of a DML statement, the variable ACTIVITY_COUNT reflects the number of rows processed.  You can raise an error using the SIGNAL (or RESIGNAL) command.  For the case of no records found, you could alternatively DECLARE an exit handler for NOT FOUND, which could log an error and set a SQLSTATE code.  For details and examples, go to info.teradata.com, Teradata Database, and download the SQL Stored Procedures and Embedded SQL manual.

1 ACCEPTED SOLUTION
3 REPLIES
Teradata Employee

Re: WHat's the equivalent to RAISEERROR ?

Upon completion of a DML statement, the variable ACTIVITY_COUNT reflects the number of rows processed.  You can raise an error using the SIGNAL (or RESIGNAL) command.  For the case of no records found, you could alternatively DECLARE an exit handler for NOT FOUND, which could log an error and set a SQLSTATE code.  For details and examples, go to info.teradata.com, Teradata Database, and download the SQL Stored Procedures and Embedded SQL manual.

Enthusiast

Re: WHat's the equivalent to RAISEERROR ?

Thanks much for that....I knew I was missing the manual !!

I think the ACTIVITY_COUNT is the best way to go because if you are expecting 10,000 records to be processed and only get 100, then raise the error.

One could make the tolerances as parameters passed to the procedure so it can be adjusted without a code change.

 

Highlighted
Enthusiast

Sample TD Script

Hi .

 

Can you please help me to get sample script to load XML file into table. 

 

I have source as XML file. I need to load the data into tables. 

 

I have multiple repetitive blocks in XML with huge data with many columns . 

 

Thanks in advance