Overview
In this documentlesson, we will learn how to create a new function in SQL and associate this new object in Wayfast. If you we have to repeatedly write large SQL scripts to perform the same task, you we can create a function that performs that task. Instead of rewriting the SQL, you
Let’s review how we can simply call that function instead of rewriting scripts.
Create a Function in SQL and link to the Project’s DB
Let’s First we need to create an easy function in SQL to establish a currency format in our application. You We can follow these stepsrecommendations to create the function:
Define the CREATE FUNCTION statement:
-Specify a name for the function.
-Specify a name and data type for each input parameter.
-Specify the RETURNS keyword and the data type of the scalar return value.
-Specify the BEGIN keyword to introduce the function-body.
-Specify the function body. Specify the RETURN clause and a scalar return value or variable.
-Specify the END keyword.Code Block language sql CREATE FUNCTION fn_getMoneyFormat ( @variable money ) RETURNS varchar(max) AS BEGIN DECLARE @Value varchar(max) SELECT @Value = FORMAT(@variable,'#,###.00','EN-us') --Result RETURN @Value END
Execute the CREATE FUNCTION statement
...
Automatically the new function is displayed on the “Functions” section
How to associate an existing Function in Wayfast?
In case you we want to include functions previously generated in the new project, we can assign the elements selecting the specific database where they are allocated and include them for development.
Turn to “Database” section at top menu and click on “Functions” tab
...
Click on “Associating Functions” button
...
A popup is displayed on screen. You can retrieve all the “function” objects from the specific instance and database selection. Click on “Assign” button
...
The new object is displayed on “Functions” dashboard. In case you need to add multiple functions at the same time from one specific database, we can check “Multi Assign” checkbox
...
In case we need to review the “Function” script in Wayfast, click on “Edit Script” pencil icon and you we can review the function associated to the project. Query Analyzer will be opened in another tab to verify the syntax
...
In case you we have to edit the script, we can use “Synchronize” button will to establish the connection to the DB database and update what we modified in Wayfast.
Recap
Wayfast brings multiple tools to develop your our projects. In this documentlesson, we learnt how to create and edit function’s statements. Then we can easily This approach give us an easy wat to synchronize the objects between database and application by selecting the correct instance.
...