...
Code Block |
---|
DELIMITER // CREATE PROCEDURE GetNewOrderNum() BEGIN SELECT max(orderNumber) + 1 as onum FROM Orders; END // DELIMITER ; |
To call this from the mySql command line you would use the command: call GetNewOrderNum(); To call this from the database connector you would add the following to configuration.xml:
Code Block |
---|
<query name="getOrderNumber"> <retrieve> <statement> call GetNewOrderNum() </statement> </retrieve> </query> |
To retrieve the next order number from your database and populate that value into a control in your form named 'onum', add the following business rule to your form:
...
Code Block |
---|
<query name="getOrderNumber"> <retrieve> <statement> exec GetNewOrderNum </statement> </retrieve> </query> |
To pass form field values to your SQL server stored procedure, append the variables to the end of the exec line. For example if your form contains a field named customerId and department, and your sproc takes two arguments @cust and @dept:
Code Block |
---|
<query name="getOrderNumber"> <retrieve> <statement> exec GetNewOrderNum @cust = {customerId}, @dept = {department} </statement> </retrieve> </query> |
Auto Create Rows
...