Executing a Modify bean

To access relational data using a Modify bean, you connect an interface component to the Modify bean. For example, you can make an event-to-method connection between the actionPerformed event for a button and the execute method of the Modify bean. When the button is selected, the SQL statement associated with the Modify bean is executed.

If you have defined parameters in your SQL statement, you must set the parameters before you invoke the execute method. If you used the SQL Assist SmartGuide to compose the SQL statement, VisualAge for Java generates two bound properties for each parameter you defined. One property is the parameter in its specified data type. The other property is a String representation of the parameter. So, for example, you can make a property-to-property connection between the text property of a text field and the String representation of a parameter. Because the text property is not bound, you must also specify in the connection properties an event to trigger the propagation of the text value to the parameter.  Once you do this, code is generated to invoke the setParameterFromString method whenever the event is fired.

The purpose of the Modify bean is to execute SQL INSERT, UPDATE, and DELETE statements. After you execute, the value of the numAffectedRows property tells you how many rows were inserted, updated, or deleted. It is possible to execute other kinds of SQL statements using a Modify bean, but if the statement produces a result set, the Modify bean does not give you access to it.


Related concepts
About Relational Database Access

Related procedures
Editing Modify bean properties
Connecting beans

Related references
Data Access Beans