Skip to main content

sql_select

Definition

sql_select is a property used in Veezoo's configuration to specify the SQL equivalent of a function when it appears in the SELECT clause of an SQL query. This property is crucial in translating Veezoo's language to SQL, enabling users to execute advanced database functions without needing to know SQL.

Usage

sql_select is a string that holds the actual SQL code, with placeholders ($1, $2, $3, etc.) representing the arguments that the function accepts. These placeholders correspond to the first, second, third, etc., arguments and will be replaced with the actual values when the function is called.

Example

Let's consider the Length function from our examples here. The sql_select property is used to define the SQL operation that calculates the length of a string:

function Length {
name: "Length"
// Rest of function definition...
sql_select: "LENGTH($1)"
}

In this example, LENGTH($1) is an SQL function that calculates the length of a string. The $1 is a placeholder for the first argument, which in this case would be a string. If the function is called with an argument "email", LENGTH(email) will be inserted in the SELECT clause of the SQL query.

Guidelines

When defining sql_select:

  • Use valid SQL syntax corresponding to your database engine.
  • Make sure to correctly map the function's arguments to the placeholders.
  • The resulting SQL function should return a value that matches the function's specified return type.

Remember, sql_select is essential for the correct transformation of Veezoo's natural language questions into SQL queries. It enables the use of advanced database functions directly within Veezoo, enhancing the analytical capabilities offered to the user.