IExtensionsQuery
- Last UpdatedJan 25, 2021
- 1 minute read
This API allows querying the SQLite database of the AVEVA Mobile Operator app.
Method
Execute(sql,parameters)
Parameters
-
SQL: SQL string to execute.
-
Parameters: Array of parameters to be passed for query parameterization.
For example:
IExtensionsQuery.Execute("select Col1 , Col2 from Table where colx1=@0 and colx2 =@1",{val1,val2});
Return
Table with the following properties:
-
Status: 0 or 1 , 0 for success 1 for failure
-
Error: error message if any
-
ColumnCount: number of columns fetched
-
ColumnNames: Array of column names
-
RowCount: No of rows in result
-
Rows: Array of rows fetched
Example 1
IExtensionsQuery.Execute("select AssetName from SATM_Assets where TypeOfAsset=@0 and Allow_WOR =@1",{0,1});
Example 2
IExtensionsQuery.Execute("select AssetName from SATM_Assets LIMIT 100",{});
Example 3
AssetNames contains all the fetched assets from dataset.
local queryResult2 = IExtensionsQuery.Execute('SELECT SATM_ASSETS.AssetPK as Asset, SATM_ASSETS.AssetName as AssetName FROM SATM_ASSETS WHERE SATM_ASSETS.Owner_FK IN(SELECT AssetPK FROM SATM_ASSETS WHERE SATM_ASSETS.AssetName = @0)',{assetName})
local data2 = queryResult2["Rows"]
local col2 = queryResult2["ColumnCount"]
local row2 = queryResult2["RowCount"]
IExtensionsLog.Log("Query result2 : " .. queryResult2["Status"],"Debug")
IExtensionsLog.Log("Error : " .. queryResult2["Error"],"Debug")
IExtensionsLog.Log("ColumnCount : " .. queryResult2["ColumnCount"],"Debug")
IExtensionsLog.Log("RowCount : " .. queryResult2["RowCount"],"Debug")
for i=1,row2,1
do
AssetNames[i]= data2[i][2]
end
Notes:
- Allow only Select queries.
- Block the queries on below Security Sync related tables.
- - DBVersion
- - ISMGTM_PERMISSION
- - ISMGTM_USER_DEPARTMENT_LINK
- - SATM_ProcedureRoleLink
- - SATM_Sync_Info
- - SATM_User
- - SATM_Role_user_Base_Link
- - SAT_COR_ORG
- - SAT_COR_SHIFTINFO
- - SAT_SEC_ROLE
- - SATM_Password_History
- - SAT_COR_SHIFTINFO
- - SAT_COR_CREWINFO
- - SAT_COR_CREWROTATION
- - SAT_FAV_USER