function
Library: Database access (OMDB)
Import : omdb.xmd |
define external function db.update value db.table table from read-only stream values null value string null optional where value string condition
Argument definitions
Use db.update to update records in a table using the supplied data and criteria.
The database connection containing the table must be:
table must:
The record being inserted (values) must:
The condition must be
To specify a null value for the input you may represent the null data value as either an unattached stream or an optionally defined string. The column name is identified by the key of each values parameter shelf item.
If the record has a date, time, or timestamp field, you must represent the field's value in the OmniMark Date and Time library format. (This format returns the time with a time zone offset from UTC time, which most databases do not provide.)
The following program shows how to:
import "omdb.xmd" prefixed by db. process local db.database this-db local db.field student-average variable local db.table student local stream SQL-query initial { "select SID, ave(Grade) " || "from StudentCourse " || "group by SID " } local stream average variable initial { ' ' with key 'Average' } set this-db to db.open-odbc 'dbDemo' db.query this-db SQL sql-query into student-average set student to db.open-table in this-db named 'Student' repeat exit unless db.record-exists student-average set average{'Average'} to db.reader of student-average[2] null '0' db.update student from average where "SID = ' " || db.reader of student-average{'SID'} || " ' " ; advance the cursor db.move-record student-average again