It is possible to insert objects into the network and insert rows into blobs. As with SQL in relational databases such as Access, Oracle etc. it is possible to
- Insert individual objects (and rows in arrays) with the values supplied
- Insert multiple objects based on selections from another table
The former of these is likely to be most use in conjunction with prompts and loops as described later in the paper.
To add individual objects the syntax is:
INSERT INTO <table name> (field1,field2,... fieldn) VALUES (val1,val2,val3...,valn)
e.g.
INSERT INTO node (node_id,x,y) VALUES ('bert',123,456)
The number of values must match the number of values. All the values can be scalar expressions e.g. scalar variables, expressions including scalar variables e.g. bert+$i etc. (see below)
To insert values into a table from a SELECT statement the syntax is
INSERT INTO <table Name> (field1,field2,... fieldn) SELECT <select statement>
To add individual rows into an array field the syntax is
INSERT INTO <table name>.<blob name> (field1,field2... fieldn) VALUES (val1,val2,val3,... valn)
e.g.
The field names must be either
- key field name of the table or
- the array name followed by a . followed by a field in the array
All key field names of the table must be specified and objects into which lines in the array are being inserted must exist.
To insert values into a structure blob from a SELECT statement the syntax is
INSERT INTO <table name>.<array name> SELECT <select statement>
e.g.
INSERT INTO [CCTV Survey].resource_details
(id, resource_details.resource_id, resource_details.estimated_hours)
SELECT id, 'TBD', 5 FROM [CCTV Survey]
WHERE COUNT(resource_details.*)=0
The number of items being selected must match the number of fields being set in the INSERT.
The select statement can include WHERE and ORDER BY but not GROUP BY or HAVING, and can include TOP and BOTTOM, and SELECTED etc.