Variables
In the process of work, you may need to use the same value for different objects in the database - tables, views, columns, etc. For example, suppose you have an hourly rate value equal to $15. If you need to use this value in formulas for various database objects (in more than one table, view, etc.), you may choose one of the following options:
- Either enter this value anew for each formula;
- Or create a Variable and set the necessary value ($15) for it.
Imagine that you need to increase the value of your hourly rate from $15 to $18. In the first case, you will need to change all formulas manually, which may take a lot of time and effort. If you used the variable, you would only need to change its value once, after which it would be applied to all formulas automatically.
Add Variable
TeamDesk allows you to create new variables to use them later in the system. To add a variable:
- Click the
Setup
link in the top right corner of the window. - Select the
Database
tab. - Choose
Database
>Variables
in the setup menu. On the displayed page, click theNew
button. The following form will appear on the page:
The following properties have to be filled when creating a variable:
- Name
- Enter the name of the new variable.
- Value
- Enter the variable’s value.
When entering a variable name, make sure that it is unique, meaning it does not coincide with the name of any other variable or the name of any existing table column. In formulas, variables and column references are formatted in the same way - enclosed within square brackets, for example, [Hourly Rate]. If the variable name coincides with the name of any table column, there may be reference confusion.
Click Save
to add the variable; click Cancel
to discard changes.
Variable values are treated by the system as text. If you need to use variables in date or numeric formats, you will have to convert them into the necessary format later on when creating formulas.
The following table shows how you should enter text values if you need to convert variables into different formats later on:
Will be converted to format | Variable Value |
---|---|
Numeric | Enter the number without any additional characters (e.g., "10"). Use periods "." for decimal fractions (e.g., "10.05"). |
Date | Enter the date in the "yyyy-mm-dd" or "mm/dd/yyyy" format (e.g., "2006/10/28" or "10/28/2006"). |
Time | Enter the time in the "hh:mm:ss" format (e.g., "23:00:40"). |
Timestamp | Enter the timestamp in the "yyyy-mm-dd hh:mm:ss" format (e.g., "2006-10-28 23:00:40"). |
Edit Variable
To edit a variable:
- Go to
Setup
>Database
>Variables
. - Choose the necessary variable from the list and click
Edit
in the corresponding table row. - Make necessary modifications to the variable name and value.
- Click
Save
to apply changes.
Delete Variable
To delete a variable:
- Go to
Setup
>Database
>Variables
. - Choose the necessary variable from the list and click
Del
in the corresponding table row. In the displayed dialog box, chooseOK
to confirm the deletion.