# updateData

## Description

Update a record from a staging database.

## Input / Parameters

| No | Name    | Description                                                                         | Data Type | Required |
| -- | ------- | ----------------------------------------------------------------------------------- | --------- | -------- |
| 1  | dataset | Name of the dataset in staging table where record will be updated.                  | String    | Yes      |
| 2  | \_id    | Value from the staging database and used for identify which record will be updated. | Integer   | Yes      |
| 3  | param   | The data to be updated from the staging database.                                   | Object    | Yes      |

## Output

## Callback

## Video

## Example

The user wants to update the data from staging table.

### Step

1. Create a table with a table name and field in staging table and create a dataset in Services. (We assumed that the table , field and dataset have been created.)\
   table name: customer\
   Fields name: tel, name and add\
   Dataset: customer\_1\
   Set value: tel:111222333, name: abc, add:124,jalan tresa

![](https://399701567-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwmJ1RKjM2uNFaL6fO3Xu%2Fuploads%2Fgit-blob-c04b2cdcbb44c44c2900d41d6f1205756d846fe0%2Fupdatedata-step-1.png?alt=media)

![](https://399701567-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwmJ1RKjM2uNFaL6fO3Xu%2Fuploads%2Fgit-blob-9098f9967b9410bc992ba1b465d57be57760a87e%2Fupdatedata-step-2.png?alt=media)

2. Call the function "updateData", define the dataset & id and set function "toObject"to param.\
   dataset: customer\_1\
   \_id: 4\
   param: toObject

![](https://399701567-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwmJ1RKjM2uNFaL6fO3Xu%2Fuploads%2Fgit-blob-efb76d660308300212d67e38615425a2e1e111e4%2Fupdatedata-step-3.png?alt=media)

3. Define the tel.\
   tel: 123<br>

![](https://399701567-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwmJ1RKjM2uNFaL6fO3Xu%2Fuploads%2Fgit-blob-9de7217bd1aa0b2003c2b63bb5e98325bf931a51%2Fupdatedata-step-4.png?alt=media)

4. Call the function "loadData" and set the dataset.\
   dataset: customer\_1<br>

![](https://399701567-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwmJ1RKjM2uNFaL6fO3Xu%2Fuploads%2Fgit-blob-f1e26c32837fb1387e522e01f79edc917e101ca2%2Fupdatedata-step-5.png?alt=media)

5. Add a console after callback for display the response from console.

![](https://399701567-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwmJ1RKjM2uNFaL6fO3Xu%2Fuploads%2Fgit-blob-56b5e933f8c244e2105791aabdfce60b82423b72%2Fupdatedata-step-6.png?alt=media)

### Result

![](https://399701567-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwmJ1RKjM2uNFaL6fO3Xu%2Fuploads%2Fgit-blob-9ad65d48e32c455055b0e2f73777c8ad381f207c%2Fupdatedata-result-1.png?alt=media)

![](https://399701567-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwmJ1RKjM2uNFaL6fO3Xu%2Fuploads%2Fgit-blob-d516b16c28e8ac97974dfccc52c4f2a09d97def1%2Fupdatedata-result-2.png?alt=media) ( The row 2, tel no have been successful to be update into no 123.)

## Notes

* N/A
