ChannelDB.ChannelDB
- Last UpdatedAug 22, 2023
- 2 minute read
The ChannelDB.ChannelDB channel enables connection to a database and performs queries on it.
The channel is platform independent because it is based on ODBC protocol.
Note: DB channels queries can also be accessed from outside with rest calls to bridge by using REST node. This avoids the need to define complex trigger chains with one trigger to activate the query and another to move the result back.
Code example
This is a code example for ChannelDB.ChannelDB.
<channel name="db" class="ChannelDB.ChannelDB" connectionString="Driver={SQL Server};Server=INTOUCH;Database=dbtest;Uid=sa;Pwd=aPassword;"/>
Parameters
These are parameters for the channel connection.
|
Parameter |
Type |
Description |
|---|---|---|
|
name |
Mandatory |
The name of the channel. |
|
class |
Mandatory |
Must be ChannelDB.ChannelDB. |
|
connectionString |
Mandatory |
ODBC format connection string. |
Simulation
There is no <simulation/> related configuration for this channel type.
Code example
This is a code example for a simulation parameter.
<db>
<query name="select_List_Ordinary" sql="SELECT * FROM italpresse.dbo.MAI_Ordinary as ordinary left JOIN (SELECT id_events, max(dateStart) as dateStart from italpresse.dbo.MAI_Achive group by id_events) as achive ON ordinary.id = achive.id_events ORDER BY id;"/>
<nonquery name="insert_Extraordinary" sql="INSERT INTO Italpresse.dbo.MAI_Achive (id_events, dateReset, dateStart, engineer, title, comment) VALUES (%id%, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP,'%user%', '%title%', '%comment%')"/>
</db>
Note: SQL text may contain %name% parameters that can be replaced with proper values when invoking the query. SQL code can be both standard SQL and platform dependent.
Query parameter
Use the Query parameter to perform a query that should return a table result (STABLE type).
Code example
This is a code example for the query parameter.
<query name="test_select" sql="SELECT id, title, description, creationDate FROM test_table1"/>
|
Attribute |
Type |
Description |
|---|---|---|
|
name |
Mandatory |
The name of the variable. |
|
type |
SQL |
Query SQL text. |
Nonquery parameter
Use the Nonquery parameter to perform a query that returns a table result (STABLE type).
Code example
This is a code example for the nonquery parameter.
<nonquery name="test_insert" sql="INSERT INTO test_table1 (title, description, creationDate) VALUES ('cane','canorro',now())"/>
|
Attribute |
Type |
Description |
|---|---|---|
|
name |
Mandatory |
The name of the variable. |
|
type |
SQL |
Nonquery SQL text. |