en:db_api
Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| en:db_api [2026/06/03 09:34] – created administrator | en:db_api [2026/06/05 07:14] (current) – administrator | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== iGarment API: Query ====== | + | ====== Database API ====== |
| + | |||
| + | ===== iGarment API: Query ===== | ||
| Method: POST ~/db/query | Method: POST ~/db/query | ||
| + | |||
| Content Type: text/plain | Content Type: text/plain | ||
| Line 8: | Line 11: | ||
| This service is READ ONLY. | This service is READ ONLY. | ||
| - | Respone (application/ | + | **Respone (application/ |
| The response of the service is an XJSON object with the following specification. | The response of the service is an XJSON object with the following specification. | ||
| - | A note on data type. | + | '' |
| - | Since XJSON is a typed serial notation, you can determine the return data type from the notation. Thus, the attributes is provided additional type information. Use the following table to decode the data type. | + | Since XJSON is a typed serial notation, you can determine the return data type from the notation. Thus, the attributes is provided additional type information. Use the following table to decode the data type.'' |
| + | |||
| + | {{: | ||
| - | type size data type description | ||
| - | A - string | ||
| - | I 11 integer | ||
| - | N 11 double | ||
| - | $ n, | ||
| - | D 8 date | ||
| - | D 16 datetime | ||
| - | @ - datetime | ||
| - | L - boolean | ||
| - | B - binary data | ||
| - | M - text | ||
| - | [ | ||
| { | { | ||
| columns: [ columnName, ... ], | columns: [ columnName, ... ], | ||
| Line 40: | Line 33: | ||
| ], | ], | ||
| } | } | ||
| - | ] | + | |
| Example, single SQL | Example, single SQL | ||
| - | select orderNo from saomstr where issdate >= ' | + | select orderNo from saomstr where issdate >= ' |
| - | select a.orderno, a.issdate, b.style, b.description from SAOMSTR a inner join t_Filter o on o.OrderNo = a.OrderNo inner join SAOSTYLE b on b.OrderNo = a.OrderNo | + | |
| - | Reutrn | + | |
| + | Return | ||
| - | [ | ||
| { | { | ||
| " | " | ||
| Line 61: | Line 54: | ||
| ] | ] | ||
| } | } | ||
| - | ] | + | |
| - | Query procedure | + | ==== Query procedure |
| Instead of running a single SQL SELECT, you can provide multiple SQLs where each SQL end with a semicolon. When providing multiple SQL, the server will only return data from the last SELECT statment. But if you want to get data from other SELECT statement, you need to specify explicitly. | Instead of running a single SQL SELECT, you can provide multiple SQLs where each SQL end with a semicolon. When providing multiple SQL, the server will only return data from the last SELECT statment. But if you want to get data from other SELECT statement, you need to specify explicitly. | ||
| Example, multiple select | Example, multiple select | ||
| - | SELECT * FROM table1; | + | |
| - | SELECT * FROM table2; | + | SELECT * FROM table2; |
| You should get the select data of ' | You should get the select data of ' | ||
| Example, multple select return mutlipe dataset | Example, multple select return mutlipe dataset | ||
| - | SELECT * FROM table1 into table1; | + | |
| - | SELECT * FROM table2; | + | SELECT * FROM table2; |
| The return data will be a list of two elements with the following structure. | The return data will be a list of two elements with the following structure. | ||
| - | [ | + | |
| { last select result }, | { last select result }, | ||
| { | { | ||
| Line 83: | Line 79: | ||
| ... | ... | ||
| } | } | ||
| - | ] | + | |
| **Using Temporay Table** | **Using Temporay Table** | ||
| Line 89: | Line 85: | ||
| You may also store data into temporay table to be used by subsequence select. | You may also store data into temporay table to be used by subsequence select. | ||
| - | ~~~sql | + | |
| - | SELECT * FROM table1 INTO TEMPORARY TABLE T_A; | + | CREATE INDEX T_A_KEY1 ON (order); |
| - | CREATE INDEX T_A_KEY1 ON (order); | + | |
| + | SELECT * FROM table2 LEFT JOIN T_A WHERE T_A.order > 1000; | ||
| + | DROP INDEX T_A_KEY1; | ||
| + | |||
| + | ===== iGarment API: Get file ===== | ||
| - | SELECT * FROM table2 LEFT JOIN T_A WHERE T_A.order > 1000; | ||
| - | DROP INDEX T_A_KEY1; | ||
| - | iGarment API: Get file | ||
| API to download file. Supported method is GET. | API to download file. Supported method is GET. | ||
| Line 101: | Line 98: | ||
| < | < | ||
| - | Request Example | + | |
| + | **Request Example** | ||
| eg: get style image (example with trial505, https:// | eg: get style image (example with trial505, https:// | ||
| + | |||
| step 1. get real file name from system image table: ~/db/query | step 1. get real file name from system image table: ~/db/query | ||
| - | sql: select b.ImageType, | + | |
| return: | return: | ||
| [{ | [{ | ||
| Line 113: | Line 112: | ||
| " | " | ||
| }] | }] | ||
| + | | ||
| step 2. url: ~/ | step 2. url: ~/ | ||
| - | Return Example | + | **Return Example** |
| - | { | + | |
| " | " | ||
| " | " | ||
| " | " | ||
| # file data, encoded in Base64 | # file data, encoded in Base64 | ||
| - | } | + | |
| - | If file_type is blank, can get file type from system image table. | + | |
| + | '' | ||
en/db_api.1780479274.txt.gzip · Last modified: by administrator
