In this section: |
You can create an SQL statement even when using the adapter for non-relational databases. iWay Explorer provides the convenience to browse and view database tables and its metadata while you create a statement. You can also edit existing SQL statements and parameters. The edit feature also allows you to view tables while you edit.
After you create the statement, you can generate schemas that define request and response documents. The metadata is stored in the iWay Repository, which can be implemented in an RDBMS (such as Oracle or Microsoft SQL Server), a file system, or a specialized XML database.
You can generate the following types of statements:
You can generate request and response schemas for:
This section explains how to create and test a regular SQL statement. In addition, it describes how to edit an existing SQL statement.
To create an SQL statement:
The Create Prepared Statement options open in the right pane, as shown in the following image.
iWay Software recommends that you specify a name that describes the service. For example, a name of CustomerIntField could represent a request against the Customer Interface table returning a Field format response document.
Note: If the user is not the owner of the table(s), the table name must be fully qualified.
To view table metadata while you edit:
The Schema drop-down list is now available at the bottom of the pane.
The Table drop-down list is now available under the Schema field.
The table metadata appears at the bottom of the Create Prepared Statement pane. Use the horizontal and vertical scroll bars to view the entire table. An example of a table displayed in the Create Prepared Statement pane is shown in the following image.
You can browse additional tables if needed using Get Tables and View Another Table found at the bottom of this pane.
After the SQL statement node is built, you are ready to test the statement.
To test an SQL statement:
The Test Run pane opens on the right.
The results appear in the Test Run pane in a table format. The following image is an example of an SQL statement test results.
To see the results in XML, click View XML. The following image is an example of test results in XML format.
Click Table View to return to the table format display.
You can follow this procedure to edit the SQL for a parameterized SQL statement as well.
To edit an SQL statement:
The Edit SQL pane opens on the right, as shown in the following image.
You can view table metadata by clicking View Table. For more details see How to Create a Regular SQL Statement.
Parameterized SQL allows an SQL statement to be stored within the repository system with parameters imbedded within it. These parameters can be retrieved from XML documents at run time and executed against the SQL statements specified at design time. iWay Explorer creates and maps parameters for the parameterized SQL at design time.
To create a parameterized SQL statement:
The Create Prepared Statement pane opens on the right, as shown in the following image.
Note: If you are not the owner of the table(s), the table name must be fully qualified.
To view table metadata while you edit:
The Schema drop-down list is now available at the bottom of the pane.
The Table drop-down list is now available under the Schema field.
The table metadata appears at the bottom of the Create Prepared Statement pane. Use the horizontal and vertical scroll bars to view the entire table. An example of a table displayed in the Create Prepared Statement pane is shown in the following image.
You can browse additional tables if needed using Get Tables and View Another Table found at the bottom of this pane.
The Parameter Name, Data Type, and Value selection information appears at the bottom of the pane, as shown in the following image.
The properties table for the newly created statement appears in the right pane containing Property and Value columns. The Value column contains a description of the SQL statement, the actual SQL statement, and ellipsis symbols you can click to access parameters and database properties.
Depending on the properties you want to view, click the ellipsis symbol in the Parameters or Database Properties row.
If your statement is not accurate, an error message appears at the bottom of the pane.
The date on which the statement is created is saved along with other data about the statement. In addition, the date for each parameter is saved. The date information can help debug problems. For example, if a batch statement that references a prepared statement has a modified date earlier than the date listed for the prepared statement, the batch might behave differently than expected. Also, when the design-time and run-time repositories are the same, a deployed service with a date earlier than the modified date shown for the service in design-time might mean that the service behaves differently than intended. In this case, the service should be redeployed.
For information on testing a parameterized SQL statement, see How to Test a Parameterized SQL Statement.
For information on creating schemas for both parameterized and regular SQL statements, see How to Generate a Schema for a Prepared Statement.
To test a parameterized SQL statement:
The Test Run pane opens on the right for the SQL statement. This pane contains the parameter name, data type, and an input box where you can type the parameter value, as shown in the following image.
For example, provide a sample character value, for example, SMITH, for the following SQL statement:
select * from employee where lname=?
In this example, the values correspond to values of fields found in a table. Parameterized statements may include parameters that are input for SQL functions, for example, the Oracle SQL function TO_DATE(StringParm). In this case, the data type selected is the expected data type of the SQL function. This is why you provide the SQL type when you create the prepared parameterized SQL statement.
The results appear in the Test Run results window in a table format. An example of test results is shown in the following image.
To see the results in XML, click View XML. The following image is an example of test results in XML format.
Click Table View to return to the table format display.
You can edit the parameter name, data type, and value through the Edit Parameters pane.
To edit a Parameterized SQL statement:
To view table metadata while you edit, click View Table. For more details see How to Create a Parameterized SQL Statement.
If your statement is not accurate, an error message appears at the bottom of the pane.
For example, the following image shows a parameterized statement before it is edited:
When a new parameter is added to the SQL statement, iWay Explorer adds the new, unnamed parameter automatically to the parameter list. The following image shows the edited SQL statement and the parameters listed below the SQL Statement box:
You can edit the parameter name and data type.
The following image shows the edited parameter in the parameter table.
You can change the position of the parameters in the parameter table to match the order of parameters in the SQL statement by specifying the position in the Position/Delete column. The following image shows the reordering of the parameter rows in the Parameter table based on the position selected. As shown in the image, the third row will become the top row, followed by the two other rows.
The delete setting appears by default in the Position/Delete column of one of the parameter rows. If it is not the parameter you want to delete, you can change the setting for that row.
The following image shows delete selected in the second row, which contains the Company parameter:
You can also change the position of a parameter relative to other parameters in the list by selecting a position number in the parameter row whose position you want to change. This is useful if you delete the middle parameter from a SQL statement and want to reposition the other parameters in the parameter table to match the sequence of parameters in the SQL statement. The following image shows delete selected in the middle row and a position of 1 selected in the third row of the parameter table. This will move the position of the this parameter from the third row to the second row:
Because dates can be formatted in many different ways, some applications might have to take extra time transforming a date and time string to the correct XML format. By default, the XML date format is used for a request/input document. The iWay Technology Adapter for RDBMS allows you to specify the date and time format when you design a service so that it does not have to be done in the flow of the message. Editing a date format can only be performed for parameterized SQL statements, which include a DATE or TIMESTAMP datatype. You can configure and test the date formatter the adapter uses at runtime to parse the request value.
Note: The date format you specify structures the date format for the request document. The date format returned in the response will conform to the date format defined in the database.
To specify the date and time format in a request:
The Customize Datetime Formatter pane appears on the right, as shown in the following image:
The Examples and Pattern tables appear. The following image shows the Examples Table and the Pattern Table. The Examples Table lists date examples. The Pattern Table specifies the letter, component of the date, the date presentation, and examples.
The following image shows sample test results.
The iWay Technology Adapter for RDBMS allows you to execute a prepared SQL statement or stored procedure multiple times with different input parameters each time in a batch. The major benefits of this feature are as follows:
Note: Multiple processes in one message are not supported. Only one SQL statement or stored procedure can be executed in a single XML execution request block.
You must first create the prepared statement before generating a schema for it. For more information on creating prepared statements, see the following procedures:
To generate a schema for a prepared statement:
A table that lists the available schemas appears.
The schema is generated and ready to use. You can use the generated request schema to create a sample XML document to be used by the adapter. To add a schema to a business service, see Understanding iWay Business Services.
iWay Software |