...
Code Block |
---|
result = DATABASESINK({connection='con1', table='main'}, datastream) |
This query opens connection con1 and writes the resulting data stream from the view/source datastream to the table main. This is, of course, simple PQL, so you may also use other operators instead of "datastream". If the table "main" does not exists, it is created before. Furthermore, notice, that the schema of the table main and the schema of the incoming "datastream" must be union compatible.
Since each tuple is just appended to an existing table, you can also drop the table when the query is started:
Code Block |
---|
result = DATABASESINK({connection='con1', table='main', drop='true'}, datastream) |
This makes it possible to create a new table with the according schema. Alternatively, you may just truncate (remove all entries but keep the table and its schema) the table:
Code Block |
---|
result = DATABASESINK({connection='con1', table='main', truncate='true'}, datastream) |
Using a connection in StreamSQL (CQL)
...