- How to?
- Creating an insert query
An insert query
statement) is used to add records to a database file.
The following information is required to perform an insert query:
- the data file into which the data will be inserted.
- the items into which new values will be inserted.
For example, creating a new customer in the "Customer" data file:
The query editor automatically generates the SQL code of this query.
To see the SQL code of a query:
- Open the context menu of the query graph.
- Select "SQL code".
You also have the ability to press the F2 key.
In our example:
INSERT INTO CUSTOMER
|Reports & Queries cannot be used to create insert queries.|
Creating an insert query
To create a new insert query:
- Click in the quick access buttons.
- The creation window appears: click "Query".
- The query creation wizard starts.
- Specify that you want to create an insert query ("Insert" option).
- If your project is linked to no analysis, specify the analysis to which the query will be attached.
Go to the next step of the wizard.
- Select the data file into which the data will be inserted.
Go to the next step.
- The new values will be inserted into the different items of the data file. For each relevant item:
- Click the "Value/Parameter" column.
- In the popup window that appears, specify the value or the parameter that contains the value to be inserted.
The new values to be inserted can be:
- the default value defined in the analysis.
- a value that must be specified. Specify this value.
- a value contained in a parameter. Specify the name of the parameter.
- a null value.
- Validate your choice.
- Repeat the previous steps for each item into which you want to insert a value .
Remark: the button automatically generates a parameter for each item without a value.
- Go to the next step.
- Type the query name (name of ".WDR" file corresponding to the query). This name will be used to identify the query in your programs.
- Specify the caption of the query by briefly describing the purpose of query. This caption will be used in the project documentation.
Remark: The query name is automatically defined from the caption typed.
- Validate the query description. The graphic representation of query is automatically displayed in the query editor.
- To modify the characteristics of a query: on the "Query" tab, in the "Edit" group, click "Description". For more details, see Description of a query.
- To generate the SQL code corresponding to this query, select "SQL code" in the context menu of the query. If changes are made in the query description, these changes will be automatically reflected in the corresponding SQL code.
- You also have the ability to create a query from one or more data files described in the data model editor: to do so, drag the data files selected in the "Analysis" pane and drop them in the query editor.
- The test of the created query can be run from the query editor. For more details, see Testing a query.
This page is also available for…