Creatio development guide
PDF
This documentation is valid for Creatio version 7.12.0. We recommend using the newest version of Creatio documentation.

Composing modify data queries

Glossary Item Box

The Update class is used to update data in the bpm'online database.

The Update class constructor uses the following objects as parameters:

  • User connection (Update (UserConnection)).
  • User connection and schema name in which the data will be updated (Update (UserConnection,String)).
  • User connection and query source object (Update (UserConnection,ModifyQuerySource)).
  • Other object Update (Update (Update)). This will create a copy of an Update query included in the parameter.

The following are the examples of using the Update class method used to build queries of varying complexity. In each example an Update object is created and then an SQL query is provided that will be generated for each different DBMS (MS SQL).

Example 1

ShowC#

var update = new Update(userConnection, "Contact")
        .Set("Name", Func.IsNull(Column.SourceColumn("Name"), Column.Parameter("ParameterValue"))); 

ShowMS SQL

UPDATE [dbo].[Contact] SET [Name] = ISNULL([Name], @P1)

Example 2

ShowC#

var update = new Update(userConnection, "City")
        .Set("CreatedById",
             new Select(userConnection).Top(1)
                 .Column("Id")
                 .From("Contact")
                 .Where("Name").IsEqual(Column.Parameter("Supervisor")))
        .Set("ModifiedById",
             new Select(userConnection).Top(1)
                 .Column("Id")
                 .From("Contact")
                 .Where("Name").IsEqual(Column.Parameter("User1"))); 

ShowMS SQL

UPDATE [dbo].[City]

SET [CreatedById] = (SELECT TOP 1 [Id]

FROM [dbo].[Contact]

WHERE [Name] = @P1),

[ModifiedById] = (SELECT TOP 1 [Id]

FROM [dbo].[Contact]

WHERE [Name] = @P2)

© bpm'online 2002-2019.

Did you find this information useful?

How can we improve it?