The SQL component allows executing any SQL statement. You can also execute a Stored Procedure and Functions.
In the Connection section, select a database connection. If you don't have a connection, then you need to create a Database Connection.
The service flow makes a number of pre-built objects available that you can access from any component. Go to the Components Data section to learn about these objects and how to use them.
In the SQL section, you can write a SQL query or a Stored Procedure.
Here is an example using a very simple query that retrieves all the objects:
select * from icecream
Here is another example where a parameter is specified:
select * from icecream where id =: id
Here is another example:
select * from icecream where id = :id and flavor = :flavor
Any parameters are specified in :param format.
When you specify one or more query parameters you need to click on the Parse SQL parameters button. This action will parse the query and display any parameters in SQL Parameters section. This way API Express knows which parameters can be passed to this particular component.
This section lists all the parameters that were automatically parsed from the SQL query. Each parameter has a name and type, which you can also map into a variable from the service flow. This means when the service flow is executed, the variables you map will be automatically passed into this component (and used in where-clause in the SQL query).
The last section of the SQL component is the Response body section. This is where you define the output of this component. You can manually enter the response but we recommend to click the Generate button to test the component and set its response this way.
When you click the Generate button, a popup will open where you test the SQL query. You will need to enter any parameter values (if any). Once you tested the SQL query, click Import response button to set the response (template) for this component.
Updated over 2 years ago