Project file:C:\Users\Demo\Desktop\TechForum2017 Mappningar\Rest\CRUD_Update.EDS
Date and time for documentation: den 5 december 2017 10:50

SOURCE file
File type: JSON
TARGET file
File type: SQL

### element: Order

Container type | Name | Data type | Mapping
--- | --- | --- | ---
element (_value_) | Sender | Single occurance |
element | Articles | Max occurrences (99999) : complex type | SQL.Article

### element: Articles

Parent: Order

Container type | Name | Data type | Mapping
--- | --- | --- | ---
element (_value_) | ArticleNr | Single occurance | SQL.Article.Id
element (_value_) | quantity | Single occurance | SQL.Article.Quantity

### table group: SQL

Container type | Name | Data type | Mapping
--- | --- | --- | ---
virtual | Extract Id from metadata | Single occurance |
update | [Order] | Single occurance |
delete | Article | Single occurance |
insert | Article | Max occurrences (2) | Order.Articles

### insert: Article

Parent: SQL

Container type | Name | Data type | Mapping
--- | --- | --- | ---
column | [Order] | bigint |
    <target>=orderid;
column | Id | varchar | Order.Articles.ArticleNr._value_
column | Quantity | bigint | Order.Articles.quantity._value_

### delete: Article

Parent: SQL

Container type | Name | Data type | Mapping
--- | --- | --- | ---
where |  |  |
    WHERE [Order] = :orderid

### update: [Order]

Parent: SQL

Container type | Name | Data type | Mapping
--- | --- | --- | ---
column | Received | datetime |
    <target>=timestamp();
where |  |  |
    WHERE Id = :orderid

### virtual: Extract Id from metadata

Parent: SQL

Container type | Name | Data type | Mapping
--- | --- | --- | ---
edi-c code | code |  |
    integer iTable = tableload ("table1",argv[8] , ":");
    string  url = tablematch (iTable, "X-Inobiz-URL");
    string orderid = filename(url); //Picks up the last section separated by "/"

Mappings
- SQL..code
      integer iTable = tableload ("table1",argv[8] , ":");
      string  url = tablematch (iTable, "X-Inobiz-URL");
      string orderid = filename(url); //Picks up the last section separated by "/"
- SQL.[Order].Received
      <target>=timestamp();
- SQL.[Order].
      WHERE Id = :orderid
- SQL.Article.
      WHERE [Order] = :orderid
- - Order.Articles -> SQL.Article SQL.Article.[Order]
        <target>=orderid;
Order.Articles.ArticleNr._value_ -> SQL.Article.Id Order.Articles.quantity._value_ -> SQL.Article.Quantity