Difference between revisions of "ODATA READ()"

From Lianjapedia
Jump to: navigation, search
(See Also)
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
==Purpose==
 
==Purpose==
OData-compatible function to read records
+
OData-compatible function to return data
  
 
==Syntax==
 
==Syntax==
Line 6: 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 Operators]], [[OData URIs]], [[ODATA_CREATE()]], [[ODATA_DELETE()]], [[ODATA_UPDATE()]], [[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_UPDATE()]], [[PRINT_JSON()]], [[SQL SELECT|SELECT]], [[SET JSONBOOLEAN]], [[SQL UPDATE|UPDATE]]
  
 
==Description==
 
==Description==
The ODATA_READ() function is used to read records.  The data is returned as JSON.
+
The ODATA_READ() function is used to return data.  The data is returned as JSON.
  
 
{| class="wikitable" width="100%"
 
{| class="wikitable" width="100%"
Line 25: Line 25:
 
// Here 5 customers records are returned starting from record 10
 
// Here 5 customers records are returned starting from record 10
 
odata_read("/southwind/customers?$skip=10&$top=5")
 
odata_read("/southwind/customers?$skip=10&$top=5")
 +
 +
// Call a stored procedure 'sp_fetchcustomer' in the southwind database
 +
odata_read("odata?$eval=southwind!sp_fetchcustomer('ALFKI')")
 +
// or
 +
odata_read('odata?$eval=sp_fetchcustomer("ALFKI")&$database=southwind')
 +
 +
// Call a function 'fetchCustomer' in the 'mylibrary.prg' function library
 +
// mylibrary.prg should be in the current App or in the library
 +
odata_read('odata?$eval=mylibrary::fetchcustomer("ALFKI")')
 +
 +
// Call fetchcustomer.prg located in the myapp App
 +
odata_read('odata?$eval=fetchcustomer("ALFKI")&$app=myapp')
 +
 +
// Call a function 'fetchCustomer' in the 'mylibrary.prg' function library
 +
// located in the myapp App
 +
odata_read('odata?$eval=myapplibrary::fetchcustomer("ALFKI")&$app=myapp')
  
 
// OData-compatible functions
 
// OData-compatible functions

Latest revision as of 05:46, 22 February 2023

Purpose

OData-compatible function to return data

Syntax

ODATA_READ(<cURI> [,<cFilename>])

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_UPDATE(), PRINT_JSON(), SELECT, SET JSONBOOLEAN, UPDATE

Description

The ODATA_READ() function is used to return data. The data is returned as JSON.

Parameter Required Description
<cURI> Yes The OData URI - see OData URIs for full details.
<cFilename> No Name of file to which data will be saved.

Example

// Use URI arguments to select the required records
// Here 5 customers records are returned starting from record 10
odata_read("/southwind/customers?$skip=10&$top=5")
 
// Call a stored procedure 'sp_fetchcustomer' in the southwind database
odata_read("odata?$eval=southwind!sp_fetchcustomer('ALFKI')")
// or
odata_read('odata?$eval=sp_fetchcustomer("ALFKI")&$database=southwind')
 
// Call a function 'fetchCustomer' in the 'mylibrary.prg' function library
// mylibrary.prg should be in the current App or in the library
odata_read('odata?$eval=mylibrary::fetchcustomer("ALFKI")')
 
// Call fetchcustomer.prg located in the myapp App
odata_read('odata?$eval=fetchcustomer("ALFKI")&$app=myapp')
 
// Call a function 'fetchCustomer' in the 'mylibrary.prg' function library
// located in the myapp App
odata_read('odata?$eval=myapplibrary::fetchcustomer("ALFKI")&$app=myapp')
 
// 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")
 
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")