Difference between revisions of "ODATA UPDATE()"
From Lianjapedia
Yvonne.milne (Talk | contribs) (Created page with "''Under Construction'' ==Purpose== Update records ==Syntax== ODATA_UPDATE(<cURI>,<cJSONdatastring>) ==See Also== APPEND BLANK, APPEND FROM, APPEND FROM ARRAY, ...") |
Yvonne.milne (Talk | contribs) |
||
(5 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
− | |||
==Purpose== | ==Purpose== | ||
− | + | OData-compatible function to update records | |
==Syntax== | ==Syntax== | ||
Line 7: | Line 6: | ||
==See Also== | ==See Also== | ||
− | [[APPEND BLANK]], [[APPEND FROM]], [[APPEND FROM ARRAY]], [[DELETE|DELETE (NoSQL)]], [[SQL DELETE|DELETE (SQL)]], [[INSERT]], [[JSON_DECODE()]], [[JSON_DECODE_FILE()]], [[JSON_ENCODE()]], [[ODATA_CREATE()]], [[ODATA_DELETE()]], [[ODATA_READ()]], [[PRINT_JSON()]], [[SQL SELECT|SELECT]], [[SQL UPDATE|UPDATE]] | + | [[APPEND BLANK]], [[APPEND FROM]], [[APPEND FROM ARRAY]], [[DELETE|DELETE (NoSQL)]], [[SQL DELETE|DELETE (SQL)]], [[INSERT]], [[JSON_DECODE()]], [[JSON_DECODE_FILE()]], [[JSON_ENCODE()]], [[OData Operators]], [[OData URIs]], [[ODATA_CREATE()]], [[ODATA_DELETE()]], [[ODATA_READ()]], [[PRINT_JSON()]], [[SQL SELECT|SELECT]], [[SQL UPDATE|UPDATE]] |
==Description== | ==Description== | ||
The ODATA_UPDATE() function is used to update records. | The ODATA_UPDATE() function is used to update records. | ||
+ | |||
+ | {| class="wikitable" width="100%" | ||
+ | !width="20%"|Parameter||width="20%"|Required||Description | ||
+ | |- | ||
+ | |valign="top"|<cURI>||valign="top"|Yes||valign="top"|The OData URI - see [[OData URIs#OData_Functions|OData URIs]] for full details. | ||
+ | |- | ||
+ | |valign="top"|<cJSONdatastring>||valign="top"|Yes||valign="top"|JSON string containing the name/value pair(s) for the column(s) to be updated and the "__olddata" name containing the name/value pair(s) to identify the record(s) to be updated. | ||
+ | |- | ||
+ | |} | ||
==Example== | ==Example== | ||
<code lang="recital"> | <code lang="recital"> | ||
+ | // All records that match the name/value pairs in __olddata will be updated | ||
+ | // Here all the order_details records with an orderid of 10951 | ||
+ | // will have their discount field set to 6 | ||
+ | cUpdateString = '{"discount":6, "__olddata":{"orderid":10951}}' | ||
+ | odata_update("/southwind/order_details",cUpdateString) | ||
+ | |||
+ | // OData-compatible functions | ||
odata_read("/southwind/shippers") | odata_read("/southwind/shippers") | ||
odata_read("/southwind/shippers","readresults.txt") | odata_read("/southwind/shippers","readresults.txt") | ||
Line 22: | Line 37: | ||
odata_read("/southwind/shippers") | odata_read("/southwind/shippers") | ||
+ | // Specify a unique name/value pair identifier to update an individual record | ||
cUpdateString = '{"phone":"(503) 555-5678", "__olddata":{"shipperid":4}}' | cUpdateString = '{"phone":"(503) 555-5678", "__olddata":{"shipperid":4}}' | ||
odata_update("/southwind/shippers",cUpdateString) | odata_update("/southwind/shippers",cUpdateString) |
Latest revision as of 12:45, 1 February 2017
Contents
Purpose
OData-compatible function to update records
Syntax
ODATA_UPDATE(<cURI>,<cJSONdatastring>)
See Also
APPEND BLANK, APPEND FROM, APPEND FROM ARRAY, DELETE (NoSQL), DELETE (SQL), INSERT, JSON_DECODE(), JSON_DECODE_FILE(), JSON_ENCODE(), OData Operators, OData URIs, ODATA_CREATE(), ODATA_DELETE(), ODATA_READ(), PRINT_JSON(), SELECT, UPDATE
Description
The ODATA_UPDATE() function is used to update records.
Parameter | Required | Description |
---|---|---|
<cURI> | Yes | The OData URI - see OData URIs for full details. |
<cJSONdatastring> | Yes | JSON string containing the name/value pair(s) for the column(s) to be updated and the "__olddata" name containing the name/value pair(s) to identify the record(s) to be updated. |
Example
// All records that match the name/value pairs in __olddata will be updated // Here all the order_details records with an orderid of 10951 // will have their discount field set to 6 cUpdateString = '{"discount":6, "__olddata":{"orderid":10951}}' odata_update("/southwind/order_details",cUpdateString) // OData-compatible functions odata_read("/southwind/shippers") odata_read("/southwind/shippers","readresults.txt") ? filetostr("readresults.txt") cCreateString = '{"shipperid":4,"companyname":"Acme Inc.","phone":"(503) 555-1234"}' odata_create("/southwind/shippers",cCreateString) odata_read("/southwind/shippers") // Specify a unique name/value pair identifier to update an individual record cUpdateString = '{"phone":"(503) 555-5678", "__olddata":{"shipperid":4}}' odata_update("/southwind/shippers",cUpdateString) odata_read("/southwind/shippers") cDeleteString = '{"shipperid":4}' odata_delete("/southwind/shippers",cDeleteString) odata_read("/southwind/shippers")