
Creating a Db2 REST service
You can create a new Db2 REST service in Db2 Admin Tool if you have the appropriate authority.
Before you begin
- Db2 REST services must be enabled. For instructions, see Enabling Db2 REST services (Db2 12 for z/OS).
- You must have the required authority to create a service and bind the package. For more information, see Creating a Db2 REST service (Db2 12 for z/OS).
-
You must be authorized to access SYSIBM.DSNSERVICE. You can use the following statement to grant access:
GRANT SELECT ON TABLE SYSIBM.DSNSERVICE TO PUBLIC;
PUBLIC
is site-specific.
Procedure
To create a Db2 REST service:
- On the DB2 Administration Menu (ADB2) panel, specify option 1, and press Enter.
-
On the System Catalog
(ADB21) panel, specify option RS, and
press Enter.
If no REST services exist, the Create Rest Service (ADB21RSB) panel is displayed. Skip to step 4.
If REST services exist, the REST Services (ADB21RS) panel is displayed with information about any existing REST services:
Figure 1. REST Services (ADB21RS) panel ADB21RS n ---------------------- DD1A Rest Services ---------- Row 1 to 4 of 4 More: > Line commands: DIS - Display REST service DISG - Display REST group F - Free service K - Package SQ - Show SQL STA - Start REST service STO - Stop REST service ? - Show all line commands Sel Collection Name E Description * * * * ---- ----------------> -------------- - -------------------------------------> ASMCOL ASMSELECT Y Select department na db2ar getdb2metric Y Select metrics for table abc ASMCOL ASMSELECT2 Y Select my tables ASUCOL ASUSELECT9 Y Select my tables ******************************* END OF DB2 DATA *******************************
Tip: If the name, collection, or version of your rest service will have lowercase characters or special characters, specify the CAPS OFF primary command on this panel before preceding to the next step. - Specify the CRE or B line command, and press Enter.
-
On the Bind Rest Service
(ADB21RSB) panel or Create Rest Service
(ADB21RSB) panel, specify the appropriate BIND options and press
Enter:
Figure 2. Create Rest Service (ADB21RSB) panel ADB21RSB DC1A Create Rest Service 11:04 Command ===> More: + Verify the BIND parameters and press ENTER to EDIT SQL statement: BIND SERVICE( Location . . . . . . Collection . . . . . NAME . . . . . . . . > DESCRIPTION . . . . OWNER . . . . . . . > QUALIFIER . . . . . > VERSION . . . . . . SQLENCODING . . . . (EBCDIC, ASCII, UNICODE, or ccsid) DATE . . . . . . . . (EUR, ISO, JIS, LOCAL, or USA) TIME . . . . . . . . (EUR, ISO, JIS, LOCAL, or USA) DEC . . . . . . . . (15/31) DECDEL . . . . . . . (PERIOD/COMMA) STRDEL . . . . . . . (APOSTROPHE/QUOTE) ACTION . . . . . . . (Add or blank) CURRENTDATA . . . . (No or blank) DEFER(PREPARE) . . . (Yes/No) DEGREE . . . . . . . (1/Any) DESCSTAT . . . . . . (Yes or blank) ENCODING . . . . . . (UNICODE, or blank) SQLERROR . . . . . . (NOpackage) EXPLAIN . . . . . . (Yes/No) GETACCELARCHIVE . . (Yes, No, or blank) IMMEDWRITE . . . . . (Yes/No) ISOLATION . . . . . (CS, RR, RS, UR, or NC) REOPT . . . . . . . (N - None, Y - Always, 1 - Once or A - Auto) OPTHINT . . . . . . (hint id) ACCELERATOR . . . . PATH . . . . . . . . ROUNDING . . . . . . (HalfEven, Ceiling, Down, Floor, HalfDown, HalfUp, Up) QUERYACCELERATION . (N - None, EN - ENable, EL - ELigible, EWF - EnableWithFailback, or A - All) RELEASE . . . . . . (C - Commit, D - Deallocate, or blank) VALIDATE . . . . . . (Run or Bind, Bind preferred) CONCURRENTACCESSRES (U - Usecurrentlycommitted, W - Waitforoutcome) APREUSE . . . . . . (NONE, WARN or ERROR) APCOMPARE . . . . . (NONE, WARN or ERROR) BUSTIMESENSITIVE . . (Yes/No) SYSTIMESENSITIVE . . (Yes/No) ARCHIVESENSITIVE . . (Yes/No) APPLCOMPAT . . . . . (VnnRn/VnnRnMnnn) )
Note: The title of panel ADB21RSB can be either Bind Rest Service or Create Rest Service, depending on the line command that you used to display this panel. - On the Edit Statement (ADB2PRED) panel, enter the SQL statement that you want in the service, and press End (PF3).
- After you create the service, issue the REF command on the REST Services (ADB21RS) panel to refresh the list and see your new service.
