Skip to main content
Nintex Community Menu Bar

Execute SQL AC: How to use Json_Extract function while executing the query


MillaZ
Nintex Employee
Forum|alt.badge.img+21
  • Nintex Employee
  • 652 replies
Product: Kryon RPA
Product Version:19.1
Components: Database; Kryon Studio
Article Contributors: Zakir Khan
Purpose of creating this article: 1- Kryon Execute SQL query AC can run Queries with JSON functions (e.g. JSON_Extract ) functions 2- To showcase how to run / check it step by step 3- For this example using MYSQL but same can be achieved with MSSQL

Prerequisites:1- Kryon Studio v19.1 or above 2- MySQL Workbench to create DB/Table 3- Access to database
 
Steps:
Set up Table with JSON parameter using MySQL workbench:
Note: Click this Link to download MySQL Workbench​  
 Please find below full script:
  1. Create the table tj10 :
Use rpadb;CREATE TABLE tj10 (a JSON, b INT);INSERT INTO tj10 VALUES ("[3,10,5,17,44]", 33), ("[3,10,5,17,[22,44,66]]", 0);INSERT INTO tj10 VALUES ('[3,10,5,"x",44]', 33), ('[3,10,5,17,[22,"y",66]]', 0);
  1. Run the following query to check the table as shown below :
SELECT * FROM rpadb.tj10;


23847iCF365B8336C79EFB.jpg


Getting an element from Nested Array:

 

Note: Table we created having two column "a" and "b". Column "a" is of nested array type 
SELECT JSON_UNQUOTE(JSON_EXTRACT(a, "$[4][1]")) FROM rpadb.tj10;
There is one more way but this doesn't works with Kryon Studio:
 
SELECT a->"$[4][1]" FROM rpadb.tj10;
23848iA452E0519AFFE053.jpg
 

 

Action to be performed in Kryon Studio:
  1. Open Studio and create a new blank wizard
  2. Get Execute SQL AC and setup the query string
  3. If you already having query string the paste in required connection string field or else use Builder option (See pic3)
  4. If using Builder then select appropriate driver and select appropriate DSN (Data source name) created for MySQL server instance using ODBC data source 64-bit. And check if connection is successful. (See pic 4 , 5, 6 & 7))
23849iBB61BD67E23214EC.jpg

 23850i16DF8C6C1F6009B2.jpg

 

23851i5B5D5E9FB4F1937D.jpg

23852iB885F02A5A67C185.jpg

 

Info for Pic7: Search for ODBC Data source 64-bit in Start search menu and then add system data source under System DSN tab. Same you will be able to see in Kryon studio under connection string builder

 Pic 7:

23853i56134B31CFEE6D89.jpg

 

Final Query Inside Kryon Studio:

 

Note: Make sure to replace "$" sign from MySql query with a variable inside Kryon Studio. 
  1. Final query to be written in SQL AC:
SELECT JSON_UNQUOTE(JSON_EXTRACT(a, "$dollar$[4][1]")) as name FROM rpadb.tj10;

23854i72815715CCF7E94C.jpg

 

See the following output:

 

23855iF35DFE9C37621ED3.jpg

 

 

Translate
Did this topic help you find an answer to your question?

0 replies

Be the first to reply!

Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie Settings