Example 1 – UNIX
This example uses a user-loadable module called btnfyext.so. This module is built from the file btnfyext.c, which is included along with a makefile in the BTEQ distribution as an example.
Before calling BTEQ, set the environmental variable LD_LIBRARY_PATH so that the module can be found:
Script started on Wed Jan 24 18:19:12 1996 app002-0:/home/cme/src/notify/clientsw/src/bteqsrc > export LD_LIBRARY_PATH=/home/cme/src/notify/clientsw/src/bteqsrc app002-0:/home/cme/src/notify/clientsw/src/bteqsrc > bteq Teradata BTEQ 3.1 for UNIX5. Enter your logon or BTEQ command: .logon dbc .... BTEQ -- Enter your SQL request logon or BTEQ command: .set notify low exit btnfyext.so .set notify low exit btnfyext.so BTEQ -- Enter your SQL request logon or BTEQ command: sel * from sessiontbl; sel * from sessiontbl; *** Query completed. 5 rows found. 24 columns returned. *** Total elapsed time was 1 second. HostNo SessionNo IFPNo LogonDate LogonTime LogonCollation LogonData ------- -------------- ----- --------- ----------- -------------- ---- 97 -2 4-3 96/01/24 15:25:29.56 H TDPUSER 93 -2 3-4 96/01/09 17:13:25.24 H TDPUSER 100 1,012 4-4 96/01/24 18:22:18.20 H DBC 93 -3 3-4 96/01/09 17:13:25.25 H TDPUSER 97 -3 3-3 96/01/24 15:25:29.57 H TDPUSER .....
The user-loadable module writes the parameters it passed to a file called NFYEXT.OUT. After the parameter sequence, the file contains the following line:
exit called @ bteq request complete.
Example 2 – UNIX
This example uses the MEDIUM option. The BTEQ output is not included because it is similar to the output from Example 1.
The NFYEXT.OUT output file contains two lines:
exit called @ bteq request complete. exit called @ bteq notify out of scope: return code 0.
Example 3 – UNIX
This example uses the HIGH option. Every event is used, and 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: dbc. User Name Len: 3. exit called @ bteq start request: 'sel * from sessiontbl;'. exit called @ bteq request complete. exit called @ bteq fetch: statement 1, request 1 activity 5. exit called @ bteq request processing complete: 1 requests exit called @ bteq notify out of scope: return code 0.
Example 4 – UNIX
This example uses the MSG option.
The STDOUT from BTEQ is as follows:
BTEQ 3.1 Wed Jan 24 20:05:10 1996 +---------+---------+---------+---------+---------+---- .logon dbc, *** Logon successfully completed. *** Transaction Semantics are BTET. *** Character Set Name is ASCII. *** Total elapsed time was 1 second. +---------+---------+---------+---------+---------+---- .set notify high msg 'This is a UNIX msg'; +---------+---------+---------+---------+---------+---- sel * from sessiontbl; *** Query completed. 5 rows found. 24 columns returned. *** Total elapsed time was 1 second. HostNo SessionNo IFPNo LogonDate LogonTime LogonCollation LogonData ------- --------- ----- --------- ----------- -------------- --------- 97 -2 4-3 96/01/24 15:25:29.56 H TDPUSER 93 -2 3-4 96/01/09 17:13:25.24 H TDPUSER 93 -3 3-4 96/01/09 17:13:25.25 H TDPUSER 100 1,013 4-4 96/01/24 20:02:59.95 H DBC 97 -3 3-3 96/01/24 15:25:29.57 H TDPUSER +-----+--------_-+------+---------+-----------+----------------------- .quit *** You are now logged off from the DBC. *** Exiting BTEQ... *** RC (return code) = 0
For UNIX systems, the MSG option requires BTEQ to write a message using the standard syslog (system log) system.
On the test system, the default location for the file is /var/adm/usererr/ error.01-24. However, the location of this file can vary.
The above job produces the following lines in the system log:
Jan 24 20:05:10 app002-0 unix: syslog: This is a UNIX msg - BTEQ notify processed. Jan 24 20:05:10 app002-0 unix: syslog: This is a UNIX msg - BTEQ request issued: 'sel * from sessiontbl;'. Jan 24 20:05:11 app002-0 unix: syslog: This is a UNIX msg - BTEQ request complete. Jan 24 20:05:11 app002-0 unix: syslog: This is a UNIX msg - BTEQ ready to fetch request 1, statement 1: activity count 5. Jan 24 20:05:11 app002-0 unix: syslog: This is a UNIX msg - BTEQ fetches complete: 1 requests. Jan 24 20:05:11 app002-0 unix: syslog: This is a UNIX msg - BTEQ notify out of scope RC = 0.