assistance-engine/docs/developer.avapframework.com/appendices_23.md

31 lines
1.7 KiB
Markdown

## ormAI()
The `ormAI()` command uses an artificial intelligence model to convert a natural language query into an SQL statement, which is then executed against a database. This command processes a natural language query to generate an SQL statement that is executed on the table specified in the `source` parameter, and stores the result in a target variable.
### Parameters
* prompt Type: `variable` Description: A string in natural language that describes the query to be made. For example, "get the value of the row with id 5".
* source Type: `variable` Description: The name of the table on which the generated query should be executed. It must be a variable containing the name of the table in the database.
* TargetVariable Type: `variable` Description: The variable in which the result of the query will be stored. It must be a variable that will receive the result of the generated and executed SQL query.
### Command Flow
### Example Usage
Suppose you want to retrieve all the data from the row with id equal to 5 from a table called `users` .
```javascript
// Define variables
prompt = "get the value of the row with id 5"
source = "users"
queryResult = ''
// Call the command to process the query
ormAI(prompt, source, queryResult)
// Return the query result via addResult
addResult(queryResult)
```
In this example, the `ormAI()` command will convert the `prompt` into an SQL query: `SELECT * FROM users WHERE id = 5;` . This query will be executed on the `users` table, and the results will be stored in the `queryResult` variable. The `queryResult` variable will be returned via `addResult(queryResult)` . The output will be the dataset retrieved by the executed SQL statement.