UPDATE UDF Parameter List - Advanced SQL Engine - Teradata Database

SQL External Routine Programming

Product
Advanced SQL Engine
Teradata Database
Release Number
17.05
17.00
Published
June 2020
Language
English (United States)
Last Update
2021-01-24
dita:mapPath
qwr1571437338192.ditamap
dita:ditavalPath
lze1555437562152.ditaval
dita:id
B035-1147
lifecycle
previous
Product Category
Teradata Vantage™
UPDATE UDFs implement the security policy for an UPDATE operation. The parameter list for an UPDATE UDF consists of:
  • An input parameter that takes the current session security label as the argument.
  • An input parameter that takes the security label from the target row as the argument.
  • A result parameter that returns the current session security label if the UPDATE request passed the security policy; otherwise, it returns 0. For details about the valid return values, see Return Values for INSERT or UPDATE UDFs. The return data type must be the same as the type specified in the definition of the constraint object.
  • Indicator parameters for the input and result parameters. These are required only if the constraint object allows nulls.

Here is an example of how to declare an UPDATE UDF:

/*****  C source file name: updatelevel.c  *****/
   
#define SQL_TEXT Latin_Text
#include <sqltypes_td.h>
   
void UpdateLevel( short int  *sess_level,
                  short int  *curr_row,
                  short int  *upd_row )
{
     ...
}

The corresponding CREATE FUNCTION statement looks like this:

CREATE FUNCTION SYSLIB.UpdateLevel( current_session SMALLINT,
                                    input_row       SMALLINT )
        RETURNS SMALLINT
        LANGUAGE C
        NO SQL
        PARAMETER STYLE TD_GENERAL
        EXTERNAL NAME 'CS!updatelevel!cctests/updatelevel.c';
where:
  • Current_session is the system-defined parameter name that identifies the security label currently set for the session.
  • Input_row is the system-defined parameter name that identifies the security label from the target row.
  • The RETURNS data_type is the same as the data type specified in the definition of the constraint object.
  • PARAMETER STYLE is SQL if the constraint object allows nulls; otherwise, PARAMETER STYLE is TD_GENERAL.