Assigning New Values to Table Columns
Use
RWDBAssignment to assign new values to columns in tables, in other words, to update. The only way to create an instance of class
RWDBAssignment is through the invocation of the
RWDBColumn::assign() method. An
RWDBAssignment is an encapsulation of the SQL phrase:
SET column = expression
where
column refers to the
RWDBColumn instance whose
assign() method produced the
RWDBAssignment, and
expression refers to its argument. Here is an example:
Example 6 – Assigning a value to a column
RWDBAssignment a = col1.assign(col2 / 3.1415);
This is equivalent to the SQL phrase:
SET COL1 = COL2/3.1415
The compiler interprets the SQL phrase as follows:
The
assign() member function accepts an
RWDBExpr as an argument.
The compiler does not find an overloaded
operator / for
RWDBColumn instances and doubles, but it has one for two
RWDBExpr instances.
Since the compiler can create an
RWDBExpr instance from both an
RWDBColumn and a double, it does.
It then applies the
operator / to form an
RWDBExpr acceptable to the
assign() function.
Eventually, the assignment is executed by the underlying access library module.