To use the “update-in-place” actions of Java void instance methods in the SQL system, Java in Adaptive Server treats a call of a Java void instance method as follows:
For a void instance method M( ) of an instance CI of a class C, written “CI.M(...)”:
In SQL, the call is treated as a type method call. The result type is implicitly class C, and the result value is a reference to CI. That reference identifies a copy of the instance CI after the actions of the void instance method call.
In Java, this call is a void method call, which performs its actions and returns no value.
For example, you can invoke the removeLeadingBlanks( ) method for the home_addr column of selected rows of the emps table as follows:
update emps set home_addr = home_addr>>removeLeadingBlanks( ) where home_addr>>removeLeadingBlanks( )>>street like “123%”
In the where clause, “home_addr>>removeLeadingBlanks( )” calls the removeLeadingBlanks( ) method for the home_addr column of a row of the emps table. removeLeadingBlanks( ) strips the leading blanks from the street and zip fields of a copy of the column. The SQL system then returns a reference to the modified copy of the home_addr column. The subsequent field reference:
returns the street field that has the leading blanks removed. The references to home_addr in the where clause are operating on a copy of the column. This evaluation of the where clause does not modify the home_addr column.
The update statement performs the set clause for each row of emps in which the where clause is true.
On the right-side of the set clause, the invocation of “home_addr>>removeLeadingBlanks( )” is performed as it was for the where clause: removeLeadingBlank( ) strips the leading blanks from street and zip fields of that copy. The SQL system then returns a reference to the modified copy of the home_addr column.
The Address instance denoted by the result of the right side of the set clause is serialized and copied into the column specified on the left-side of the set clause: the result of the expression on the right side of the set clause is a copy of the home_addr column in which the leading blanks have been removed from the street and zip fields. The modified copy is then assigned back to the home_addr column as the new value of that column.
The expressions of the right and left side of the set clause are independent, as is normal for the update statement.
The following update statement shows an invocation of a void instance method of the mailing_addr column on the right side of the set clause being assigned to the home_address column on the left side.
update emps set home_addr = mailing_addr>>removeLeadingBlanks( ) where ...
In this set clause, the void method removeLeadingBlanks( ) of the mailing_addr column yields a reference to a modified copy of the Address2Line instance in the mailing_addr column. The instance denoted by that reference is then serialized and assigned to the home_addr column. This action updates the home_addr column; it has no effect on the mailing_addr column.