Webservice insert

Webservice insert

Introduction


The insert data request can be used to populate one of the datasets available in your Spotzi Mapbuilder Account with new data. You can insert a single record or multiple records at the same time. You can execute an insert data request by adding an INSERT request with the ‘q’ parameter.

Basic INSERT Query


A typical insert query is generally of the following form:

INSERT INTO name_dataset ('CODE','NAME','NUMBER')
VALUES ('A','B',3)

The above statement is divided into:

  • a field list (the part that lists the columns to be inserted)
  • a value list (the part that lists the values to be inserted)

Field list

The field list:

INSERT INTO name_dataset ('CODE','NAME','NUMBER')

States which fields need to be inserted with the insert statement. Specifying the fields is not mandatory, but Spotzi strongly advises to do this. If no fields are specified, the insert statement expects all fields to be inserted. 

Value List

The second part of the insert query, the value list:

VALUES ('A','B',3);

States which values need to be inserted.
The columns described in the first part of the query must exist in this dataset for the query to work and must match the column type of the given values. Values that are not simple numeric values usually must be surrounded by single quotes (‘), as in the example.

Examples


Below you will find some example queries that can be used with the Spotzi Webservice. The table names and fields that are used in these examples need to be available in the requested webservice account to show 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 at the same time in the neighbourhood dataset.

For more information about SQL INSERT statements, please see the SQL section in our help center or see the official PostgreSQL tutorial.