Declare Function in SQL Editor

When defining an action, the Declare command is used to define variables in the SQL editor.

In general, this command allows you to specify the name of a variable, its data type and, if necessary, its initial value.

General Declare format;

DECLARE @variable_name data_type;

Declares that a variable named @variable_name is of type data_type.

data_type is sql data type (nvarchar, int, bit etc.)

Assigning a value can be done in two ways. Select @variable = deger from table_name or SET command is used SET @variable = deger.

Example1:

DECLARE @top1Product nvarchar(256)

SELECT top1 @top1Product = productName from table_name

Example2:

DECLARE @rowCount int

SET @rowCount=(select count(Id) from table_name)

In these SQL code examples, two variables (@top1Product and @rowCount) are defined using the DECLARE statement and then values are assigned to these variables.

If you want to write the Declare function in the SQL Editor within the Kuika platform, you can manually enter the queries in the SQL Editor or you can get support from the Artificial Intelligence Assistant. For this, you can activate the Generate with AI switch, select the table of the Declare function you want to write and enter a prompt such as "write declare command in table_name table" in the searchbox field. The AI assistant will easily create the function for you.

Last updated