Windows Examples for NOTIFY - Basic Teradata Query

Basic Teradata Query Reference

Product
Basic Teradata Query
Release Number
16.00
Published
November 2016
Language
English (United States)
Last Update
2018-04-25
dita:mapPath
hyz1479325149183.ditamap
dita:ditavalPath
Audience_PDF_include.ditaval
dita:id
B035-2414
lifecycle
previous
Product Category
Teradata Tools and Utilities

Example 1 – Windows

This example uses a user-loadable module called btnfyext.dll. The module is built from btnfyext.c, which is included with a makefile in the BTEQ distribution as an example.

c:\program files\teradata\client\14.10\bin>bteq
Teradata BTEQ 14.10.00.00 for WIN32.
Copyright 1984-2012, Teradata Corporation. ALL RIGHTS RESERVED.
Enter your logon or BTEQ command:
.logon dbc
.logon dbc
Password:
***Logon successfully completed.
***Teradata Database Release is 14.10.00.00
***Teradata Database Version is 14.10.00.00
***Transaction Semantics are BTET.
***Character Set Name is ASCII.
***Total elapsed time was 2 seconds.
BTEQ -- Enter your SQL request or BTEQ command:
.set notify low exit64 btnftext.dll
BTEQ -- Enter your SQL request or BTEQ command:
sel * from dbc.sessioninfo;
***Query completed. 7 rows found. 15 columns returned.
***Total elapsed time was 1 second.
 UserName      AccountName      Session 
DBC          DBC             1,2
DBC          DBC             1,2
DBC          DBC             1,2
DBC          DBC             1,0
DBC          DBC             1,2
DBC          DBC             1,2
DBC          DBC             1,2

This user-loadable module writes the parameters it passed to a file called NFYEXIT.OUT. After the parameter sequence, the file contains one line:

exit called @ bteq init.

Example 2 – Windows

This example uses the MEDIUM option. The BTEQ output is not included because it is similar to the output from EXAMPLE 7.

The NFYEXIT.OUT output file contains two lines:

exit called @ bteq request complete
exit called @ bteq notify out of scope: return code 0

Example 3 – Windows

This example uses the HIGH option, and every event that can be used. The exit is called six times:

exit called @ bteq init.
	Version Id:	Notify Version 01.00.00.
	Version ID Len:	23.
	Utility Id:	4.
	Utility Name:	BTEQ 14.00.00.00.
	Utility Name Len:	16.
	User Name:	weekly.
	User Name Len:	6.
exit called @ bteq start request: 'sel * from dbc.sessioninfo;'.
exit called @ bteq request complete.
exit called @ bteq fetch: statement 1, request 1 activity 7.
exit called @ bteq request processing complete: 1 requests.
exit called @ bteq notify out of scope: return code 0.

Example 4 – Windows

This example uses the MSG option. The STDOUT from BTEQ is as follows:

c:\teradata\bin>bteq
Teradata BTEQ 04.00.01.00 for WIN32. Enter your logon or BTEQ command:
.logon weekly
.logon weekly
Password:
***Logon successfully completed.
***Transaction Semantics are BTET.
***Character Set Name is ASCII.
***Total elapsed time was 41seconds.
BTEQ -- Enter your SQL request logon or BTEQ command:
.set notify high msg 'this is a NT msg';
.set notify high msg 'this is a NT msg';
BTEQ -- Enter your SQL request logon or BTEQ command:
sel * from dbc.sessioninfo;
sel * from dbc.sessioninfo;
***Query completed. 7 rows found. 15 columns returned.
***Total elapsed time was 9 seconds.
 UserName      AccountName      Session 
WEEKLY       DBC             1,0
WEEKLY       DBC             1,2
WEEKLY       DBC             1,2
WEEKLY       DBC             1,2
WEEKLY       DBC             1,2
WEEKLY       DBC             1,2
WEEKLY       DBC             1,2
BTEQ -- Enter your SQL request logon or BTEQ command:
quit;
quit;
***You are now logged off from the DBC.
***Exiting BTEQ...
***RC (return code) = 0

For Windows, the MSG option requires BTEQ to issue an event with a message to EventLog service. This means that the message is trapped and can be viewed by Event Viewer under Application log.