Skip to main content

cud (Stream Processor)

This function performs SQL CUD (INSERT, UPDATE, DELETE) queries on data sources.

Syntax

rdbms:cud(<STRING> datasource.name, <STRING> query)
rdbms:cud(<STRING> datasource.name, <STRING> query, <STRING|BOOL|INT|DOUBLE|FLOAT|LONG> parameter)
rdbms:cud(<STRING> datasource.name, <STRING> query, <STRING|BOOL|INT|DOUBLE|FLOAT|LONG> parameter, <STRING|BOOL|INT|DOUBLE|FLOAT|LONG> ...)

Query Parameters

NameDescriptionDefault ValuePossible Data TypesOptionalDynamic
datasource.nameThe name of the datasource for which the query should be performed.STRINGNoNo
queryThe update, delete, or insert query(formatted according to the relevant database type) that needs to be performed.STRINGNoYes
parameterIf the second parameter is a parametrised SQL query, then stream processor attributes can be passed to set the values of the parametersSTRING BOOL INT DOUBLE FLOAT LONGYesYes

System Parameters

NameDescriptionDefault ValuePossible Parameters
perform.CUD.operationsIf this parameter is set to true, the RDBMS CUD function is enabled to perform CUD operations.falsetrue false

Extra Return Attributes

NameDescriptionPossible Types
numRecordsThe number of records manipulated by the query.INT

Example 1

insert into  RecordStream
select numRecords
from TriggerStream#rdbms:cud("SAMPLE_DB", "UPDATE Customers_Table SET customerName='abc' where customerName='xyz'");

This query updates the events from the input stream named TriggerStream with an additional attribute named numRecords, of which the value indicates the number of records manipulated. The updated events are inserted into an output stream named RecordStream.

Example 2

insert into  RecordStream
select numRecords
from TriggerStream#rdbms:cud("SAMPLE_DB", "UPDATE Customers_Table SET customerName=? where customerName=?", changedName, previousName);

This query updates the events from the input stream named TriggerStream with an additional attribute named numRecords, of which the value indicates the number of records manipulated. The updated events are inserted into an output stream named RecordStream. Here the values of attributes changedName and previousName in the event will be set to the query.