f$SQLUpdate
f$SQLUpdate
Data records in database tables are modified with this function. All recorded parameters in the specified parameter group, whose names correspond to a column name in the table, are included in the update command. To insert the values, the description of the table is calculated and the data types adjusted. Only binary data types cannot be processed. Parameters which have an UNDEF value are deleted from the database. Parameters which are NOVAL are not processed. With the optional NovalUndef parameter, you can manage how parameters in NOVAL or UNDEF state are treated. The treatment of empty strings (") is managed using the empty string argument. This parameter manages if empty strings (") set their belonging database field to NULL. (Empty = 1). If Empty=0 is entered, empty strings are ignored. If the WHERE condition selects multiple data records all selected data records are modified. With the function f$SQLRowCount the number of affected data records can be determined.
Note: since it takes time to make the connection, a new connection should not be established for every SQL function.
Syntax: | Status = f$SQLUpdate(Channel,Table,PGName,Where[,emptystrings][,EmptyUndef]) | ||
| Argument | Type | Meaning |
| Channel | Integer | Channel number for the SQL connection |
| Table | String | Name of the table in which the data record is to be modified. |
| PGName | String | The name of the parameter group whose values are to be processed. The parameter group can either not be indexed or the index must also be given. Functions which use the internal buffer: f$FileBinRead, f$FileBinWrite, f$SQLUpdate, f$SQLBindColumn |
| Where | String | The selection criteria for executing the update command. The keyword WHERE cannot be included. |
| Emptystrings | Integer | This parameter manages if empty strings (") set their belonging database field to NULL. (empty = 1). If Empty=0 is entered, empty strings are ignored. Empty=2: if a parameter has a NOVAL state, " is written if the belonging database column is of varchar type or similar. |
| EmptyUndef | Integer | This parameter manages how parameters in NOVAL or UNDEF state are processed. For NovalUndef = 0 all NOVAL parameters are ignored and the belonging database field for UNDEF parameters is set to NULL. For NovalUndef = 1, UNDEF parameters are ignored and the belonging database field for NOVAL parameters is set to NULL. Because the parameter is set to NOVAL by deleting a field content in a dialog, NovalUndef=1 is the correct setting since the belonging database field also should be deleted. This parameter is optional. If it is not given, the value 0 is accepted as the default. |
Result: | Integer | Error status: 0 :command was resolved correctly 1:table name is empty 2:the parameter group does not exist 3:the parameter group is empty or the parameters do not agree with the columns in the table (depending on the ODBC settings, they are case-sensitive. With Oracle, SMP_NG.ODBC_DBTYP has to be set to value 2). 4:the Where condition is empty 5:a data record was not found with this Where condition -9999: the SQL command was not successful. In this case, the error status and error description can be calculated using: f$SQLError. | |
|
|
| |
Example: | Channel = f$SQLConnect( db, user, password ) Status = f$SQLUpdate ( Channel, 'T_Anschrift','Addresslist[No]',SQLW) Status = f$SQLDisconnect( Channel ) | ||