The "insert" data request can be used to populate datasets available in your Spotzi Account with new data. You can insert single or multiple records at a time. "Insert" data requests can be executed by including an INSERT request with the "q" parameter.
A typical insert query is generally as follows:
INSERT INTO name_dataset ('CODE','NAME','NUMBER')
VALUES ('A','B',3)
The above statement is divided into:
The field list:
INSERT INTO name_dataset ('CODE','NAME','NUMBER')
States which fields need to be inserted via the insert statement. While specifying these fields is not mandatory, it is strongly advised — If no fields are specified then the insert statement will expect all available fields to be inserted.
The second section of the insert query is the value list:
VALUES ('A','B',3);
This list states which values need to be inserted.
The columns described in the first part of this query must exist within the dataset for the query to work, and must also match the column type of the given values. Values that are not simple numeric values must usually be surrounded by single quotes (') such as in the following examples.
Below you will find some example queries that can be used with Spotzi's Webservice. The table names and fields used in these examples must be available in the requested webservice account in order to display a valid result.
INSERT INTO neighbourhood (neighbourhood_name, total_population)
VALUES ('Centre',100)
The above statement inserts a new record in the neighbourhood dataset with the neighbourhood_name "Centre" and a total_population of 100.
INSERT INTO neighbourhood (neighbourhood_name, total_population)
VALUES ('Centre', 100),('North',50)
The above statement inserts two records into the neighbourhood dataset simultaneously.
For more information about SQL INSERT statements please visit the SQL section in our help center, or the official PostgreSQL tutorial.