DB2WSE REST Request Format
From Wiki
|
| User Guide |
Contents |
Key to Syntax Diagrams
- {required-string} A required string (may be a single value or multiple options)
- [optional-string] An optional string (may be a single value or multiple options)
- option-1|option-2 Separate options are separated by a vertical bar (|)
- repeated-string... Repeated strings are suffixed with an ellipsis (...)
In addition to DB2WSE requests using Full Format, which can specify any SQL statement type (SELECT, INSERT, UPDATE or DELETE), DB2WSE can also be invoked using a simple URL in the REST format. REST-format DB2WSE requests can only be SELECT statements.
The generic format of a REST DB2WSE URL is as follows:
http[s]://{server-address}[:{port}]/db2wse/[{userid}:{password}/]{library}/{file}[/{key}[:{key}...]where each {key} is a value for a key column in the order they are defined for the table being accessed.
The number of key values specified (if any) must be less than or equal to the number of key columns defined for the table being accessed. DB2WSE parses any key values specified and maps them to the correct key column in the table.
Values specified for character key columns will automatically be converted to upper-case - DB2WSE does not currently support mixed-case or lower-case key column values.
When a REST-style URL is used to access DB2WSE, a BASIC Response is returned.
Examples
Example 1
The following REST-format URL:
http://red.rpg-xml.com/db2wse/demo:demo/petstore/item/est-1
can be specified instead of the following full DB2WSE request:
<DB2WSEREQ> <STATEMENT> select * from petstore/item where itemid = 'EST-1' </STATEMENT> <USER>DEMO</USER> <PASSWORD>DEMO</PASSWORD> </DB2WSEREQ>
This example assumes that ITEMID is the first key column specified for the PETSTORE/ITEM table.
Example 2
The following REST-format URL:
http://red.rpg-xml.com/db2wse/demo:demo/petstore/lineitem/1:2
can be specified instead of the following full DB2WSE request:
<DB2WSEREQ> <STATEMENT> select * from PETSTORE/LINEITEM where ORDERID = 1 and LINENUM = 2 </STATEMENT> <USER>DEMO</USER> <PASSWORD>DEMO</PASSWORD> </DB2WSEREQ>
This example assumes that ORDERID and LINENUM are the first and second key columns specified for the PETSTORE/LINEITEM table.
