How to capture output of dml in teradata?

Member

by lew , in category: MySQL , 21 days ago

How to capture output of dml in teradata?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by adan , 20 days ago

@lew 

To capture the output of DML (Data Manipulation Language) statements in Teradata, such as INSERT, UPDATE, DELETE, or MERGE, you can use the BTEQ (Basic Teradata Query) utility. Here's how you can do it:

  1. Write the DML statement in a text file, for example, insert_data.txt:
1
2
INSERT INTO database.table_name
VALUES (1, 'John', 'Doe');


  1. Create a BTEQ script that will execute the DML statement and capture its output. For example, insert_script.btq:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
.LOGON <Teradata server>/<username>,<password>;
.SET RETLIMIT <max_number_of_rows>;

.SET ERRORLEVEL 3807 SEVERITY 0;
.SET ERRORLEVEL 0 SEVERITY 5;

.LOGTABLE sysadm.my_log_table;

.RUN file=insert_data.txt;

.LOGOFF;
.QUIT;


  1. Run the BTEQ script in a terminal or command prompt:
1
bteq < insert_script.btq > output.txt


This will execute the DML statement in insert_data.txt and capture the output in output.txt. The output will include any error messages or success/failure status of the DML statement.


Note: Make sure to replace <Teradata server>, <username>, <password>, <max_number_of_rows> with your actual Teradata server connection information and settings.