Description:
Query data and return result as a cursor or a table sequence.
Syntax:
ali_query(ali_open, tableName, keyName, keyValue, selectCol, filter) |
Return a table sequence. |
ali_query(ali_open, tableName, keyName, startValue:endValue, selectCol, filter) |
Query a certain part of a table and return the result as a cursor. |
Note:
Alicloud External library function (See External Library Guide).
Parameter:
ali_open |
An object to be connected on Alibaba Cloud. |
tableName |
A table name. |
keyName |
For a one-field key, the parameter is the key name; for a composite key, it is a sequence consisting of field names. |
keyValue |
Primary key value. If it is a single value or a sequence of values, query one record; if it is a sequence or a sequence of sequences, perform batch query on multiple records. |
startValue |
The starting value of the range of primary key values. When it is null or omitted, it represents an infinitesimal value and the colon shouldn’t be omitted. The parameter value is represented by a sequence when there are multiple primary key fields. |
endValue |
The ending value of the range of primary key values. When it is null or omitted, it represents an infinite value; and the colon shouldn’t be omitted. The parameter value is represented by a sequence when there are multiple primary key fields. |
selectCol |
The column(s) to be returned. The parameter will be a column name when the target is a single column; and a sequence of column names when multiple columns are desired. All fields will be selected when the parameter isn’t supplied. |
filter |
A filtering expression, which can be omitted. In the expression, following operators are allowed: Logical operators including &&, ||, and ! Relational operators including >, >=, ==, <, <=, and != The format of the expression is like this: <field name> relational operator <value expression> For instance: col1 > arg1 && col1 < arg2 || col2 != arg3 A Boolean field needs to be written in a format like this: <boolean field == false>, instead of <!boolean field>. |
Option:
@x |
Close the connection to Alibaba Cloud after the query finishes. |
@z |
Perform a query on a certain range of data in reverse order. |
Return value:
Cursor/Table sequence
Example:
|
A |
|
1 |
=ali_open("http://test.ots.aliyuncs.com","LTAIXZNG5zzSPHTQ","sa","test") |
|
2 |
=ali_query(A1,"test",["id1","id2"],[1,"10001"]:[10,"70001"], ["id1","id2","f1","f2"],f1>=2000.0) |
|
3 |
=ali_query(A1, "test",["id1","id2"],,,f1>=2000.0&&f1<=10000.0&&(id2=="10003"||id2=="10004"||id2=="10005")) |
The query doesn’t supply parameters startValue:endValue and selectCol, and uses a composite filtering. |
4 |
=ali_query@z(A1,"test",["id1","id2"],[10,"70001"]:[1,"10001"],,f1>=2000.0 && f1<=10000.0 && (id2=="10003" || id2=="10004" || id2=="10005")) |
|
5 |
=ali_query@x(A1,"test",["id1","id2"],[3,"10003"],,) |
|
Related functions: