UniBasic Commands Reference - Rocket Software
UniBasic Commands Reference - Rocket Software UniBasic Commands Reference - Rocket Software
SUBROUTINE (Update Trigger) Syntax SUBROUTINE trigname(execstat, dictflag, filename, record.ID.expr, recordval) FUNCTION trigname(dictflag, filename, record.ID.expr, recordval) Description Triggers enforce user-defined constraints that must be met before data can be updated. The trigger is associated with the data file, so it verifies any access to the data. A UniBasic trigger subroutine or function serves as an UPDATE trigger. The SUBROUTINE or FUNCTION definition must be the first line in the UniBasic trigger. You must include a RETURN statement in the function: RETURN [execstat] Points to Remember 1-880 UniBasic Commands Reference When you attempt to update a record, UniData calls the trigger, passing the file name, DICT if dictionary file, record ID, and the input value before updating the record. The subroutine returns the execution status and the new record value. If the update request fails, the subroutine must return an execstat value of 0. If the request passes, the return value must be 1. Tip: You can call a C routine from the UniBasic subroutine or function that is called from a trigger.
Parameters The following table describes each parameter of the syntax. Paragraph Description trigname Name of the globally cataloged subroutine. execstat Execution status returned by the trigger subroutine: 0 – No updates allowed. 1 – Update is allowed. 2 – Update is allowed; uses the return recordval. dictflag “DICT” – Indicates that the trigger is operating on the dictionary file. “” – Indicates that the trigger is operating on the data file. The quotation marks are required. filename The name of the file on which the trigger is operating. record.ID.expr The record to be updated. recordval The input record value submitted to the UPDATE trigger. recordval is both an input and output parameter. The trigger can change this value (for example, by performing a conversion). Then, if the trigger sets execstat to 2, this value is passed back in recordval and updates the data record. Only strings and numbers are valid. If the value returned in recordval is invalid, the record is not updated, even if the trigger subroutine sets execstat to 2. In this case, the UniBasic STATUS function returns 3 when executed immediately after the command that calls the trigger. Only strings and numbers are valid. SUBROUTINE Update Trigger Parameters STATUS Function Return Values After you execute a trigger subroutine, the STATUS function returns one of the values described in the following table. SUBROUTINE (Update Trigger) 1-881
- Page 872 and 873: Parameters The following table desc
- Page 874 and 875: 1-832 UniBasic Commands Reference C
- Page 876 and 877: SQLNumParams Syntax status = SQLNum
- Page 878 and 879: SQLNumResultCols Syntax status = SQ
- Page 880 and 881: SQLParamOptions Syntax status = SQL
- Page 882 and 883: Example This example shows how you
- Page 884 and 885: ODBC Data Sources If you execute a
- Page 886 and 887: SQLRowCount Syntax status = SQLRowC
- Page 888 and 889: SQLSetConnectOption Syntax status =
- Page 890 and 891: Return Values The following table d
- Page 892 and 893: SQLSetParam SQLSetParam is a synony
- Page 894 and 895: For complete details about the SQLS
- Page 896 and 897: 1-854 UniBasic Commands Reference C
- Page 898 and 899: Parameter Description tablename Nam
- Page 900 and 901: TYPE Smallint Not null 1-858 UniBas
- Page 902 and 903: SQLTables Syntax status = SQLTables
- Page 904 and 905: Return Values The following table d
- Page 906 and 907: Parameters The following table desc
- Page 908 and 909: SQRT Syntax SQRT(num.expr) Descript
- Page 910 and 911: SSUB Syntax SSUB(x, y) Description
- Page 912 and 913: STOP Syntax STOP [expr] Description
- Page 914 and 915: STR Syntax STR(str.expr, num.expr)
- Page 916 and 917: STRS Syntax STRS(dyn.array, expr) D
- Page 918 and 919: If the response status indicates th
- Page 920 and 921: SUBROUTINE Syntax SUBROUTINE sub.na
- Page 924 and 925: Tip: The UniBasic STATUS function r
- Page 926 and 927: SUBROUTINE (Delete Trigger) Syntax
- Page 928 and 929: Tip: The UniBasic STATUS function r
- Page 930 and 931: Related Commands UniBasic DEL, INSE
- Page 932 and 933: Examples In the following example,
- Page 934 and 935: In the next example, SWAP does not
- Page 936 and 937: Parameter Description 1-894 UniBasi
- Page 938 and 939: Parameter Description 1-896 UniBasi
- Page 940 and 941: TAN Syntax TAN(num.expr) Descriptio
- Page 942 and 943: TIMEDATE Syntax TIMEDATE( ) Descrip
- Page 944 and 945: Example In the following example, t
- Page 946 and 947: Parameters The following table desc
- Page 948 and 949: TRANSACTION START Syntax TRANSACTIO
- Page 950 and 951: TRIM Syntax TRIM(str.expr[,char[,ty
- Page 952 and 953: Related Commands UniBasic TRIMB, TR
- Page 954 and 955: TRIMF Syntax TRIMF(str.expr) Descri
- Page 956 and 957: Example In the following example, t
- Page 958 and 959: Parameters The following table desc
- Page 960 and 961: UNLOCK Syntax UNLOCK [num.expr] Des
- Page 962 and 963: UPCASE Syntax UPCASE(string.expr) D
- Page 964 and 965: Related Commands UniBasic PAUSE Uni
- Page 966 and 967: STATUS Function Return Values After
- Page 968 and 969: Related Commands UniBasic CLOSESEQ,
- Page 970 and 971: 1-903 UniBasic Commands Reference
Parameters<br />
The following table describes each parameter of the syntax.<br />
Paragraph Description<br />
trigname Name of the globally cataloged subroutine.<br />
execstat Execution status returned by the trigger subroutine:<br />
0 – No updates allowed.<br />
1 – Update is allowed.<br />
2 – Update is allowed; uses the return recordval.<br />
dictflag “DICT” – Indicates that the trigger is operating on the dictionary file.<br />
“” – Indicates that the trigger is operating on the data file.<br />
The quotation marks are required.<br />
filename The name of the file on which the trigger is operating.<br />
record.ID.expr The record to be updated.<br />
recordval The input record value submitted to the UPDATE trigger. recordval is<br />
both an input and output parameter. The trigger can change this value<br />
(for example, by performing a conversion). Then, if the trigger sets<br />
execstat to 2, this value is passed back in recordval and updates the data<br />
record. Only strings and numbers are valid.<br />
If the value returned in recordval is invalid, the record is not updated,<br />
even if the trigger subroutine sets execstat to 2. In this case, the<br />
<strong>UniBasic</strong> STATUS function returns 3 when executed immediately after<br />
the command that calls the trigger. Only strings and numbers are valid.<br />
SUBROUTINE Update Trigger Parameters<br />
STATUS Function Return Values<br />
After you execute a trigger subroutine, the STATUS function returns one of the<br />
values described in the following table.<br />
SUBROUTINE (Update Trigger) 1-881