Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

The operation "addEmployee" uses the facility to give default values to certain fields, if they were chosen not to be given an explicit value. Here, the parameter "salary" is given the default value 1500. This can be checked by calling the "addEmployee" operation with parameters except the "salary" value. For example, if the parameter values are employeeNumber=6002; lastName=Smith; firstName=John; email=john@smith.com, a call to the operation "employeesByNumber" with employeeNumber=6002 will result in the following:

Image Removed

Note that with the given parameters, the "salary" value is also This example demonstrates how default values specified in the .dbs file of the data service will be used when specific values are not given for some fields. In the RDBMS Sample service, a default employee salary is specified as 1500 in the .dbs file as shown below.

Code Block
<param defaultValue="1500" name="salary" ordinal="5" paramType="SCALAR" sqlType="DOUBLE" type="IN"/>

Therefore, when you use the "addEmployee" operation to add a new employee, if you do not specify an explicit salary value for the employee, the default salary will be added. For example, execute the "addEmployee" operation with the following parameter settings:

  • employeeNumber=6002;
  • lastName=Smith; 
  • firstName=John; 
  • email=john@smith.com
  • Remove <xs:salary xmlns:xs="http://ws.wso2.org/dataservice/samples/rdbms_sample"></xs:salary> from the operation to make sure that a salary value is not added.

Now, when you execute the "addEmployee" operation, the result will be the following:

Image Added

Note that the "salary" value is set to 1500. This is the default value for that field when the parameter value is not givenas specified in the .dbs file of the data service.