Hi,
From each selected record I have to update the "UsrAmountForTheMonth" column from "UsrDueAmount" using script task element.
var select = new Select(UserConnection)
.Column("Id")
.From("UsrBeta")
.Where("UsrConfirmationId").IsNotEqual(new Select(UserConnection)
.Column("Id")
.From("UsrCorrect")
.Where("Name").IsEqual(Column.Parameter("Yes"))) as Select;
var up = (Update) new Update(UserConnection,"UsrBeta").Set("UsrAmountForTheMonth",new Select(UserConnection)
.Column("UsrDueAmount")
.From("UsrBeta")
.Where("Id").IsEqual(select))
.Where("Id").In(select);
But this way I got the error: Subquery returned more than 1 value
Please help !
Many thanks.
Like
Smile samples
var delete = new Delete(UserConnection) .From("PersonalAccountRegistration") .Where("Id").In(new Select(UserConnection) .Column("par","Id") .From("PersonalAccountRegistration").As("par") .LeftOuterJoin("VerificationCode").As("hvc") .On("hvc", "Id").IsEqual("par", "HashId") .LeftOuterJoin("VerificationCode").As("svc") .On("svc", "Id").IsEqual("par", "VerificationCodeId") .Where("hvc", "ExpiresOn").IsLess(Column.Const(nowDate)) .Or("svc", "ExpiresOn").IsLess(Column.Const(nowDate)) ); delete.Execute();
Hi Grigoriy,
I make the changes as per your suggestion but still It shows the same error.
I think the problem is with this bolded select query inside Set method :
var up = (Update) new Update(UserConnection,"UsrBeta").Set("UsrAmountForTheMonth", new Select(UserConnection)
.Column("UsrDueAmount")
.From("UsrBeta")
.Where("Id").In(select) )
.Where("Id").In(select);
Beacause I have to update the value of "UsrAmountForTheMonth" column with the value of "UsrDueAmount" column for each selected record in the select query.
But the bolded subquery inside Set method returns the collection of "UsrDueAmount" values.
This is how my section looks like!
Please suggest any solution to the same.
Thanks.
Akshit,
As I wrote above, for complex cases, try writing and debugging a sql query and calling it as in the example below
var sqlText=@"update ....";
var customQuery = new CustomQuery(UserConnection, sqlText);
var rowCount = customQuery.ExecuteScalar<int>();
or
var selectQueryString = @"update ""Lead"" set ""ScpTimer"" = QS.""ScpLifetimeDays"" - (CAST(NOW() AT TIME ZONE 'UTC' AS date) - CAST(LD.""ScpDateTransitionNewStatus"" AS date)) from ""Lead"" as LD inner join ""QualifyStatus"" as QS on QS.""Id"" = LD.""QualifyStatusId"" where LD.""Id"" = ""Lead"".""Id"" and ""Lead"".""QualifyStatusId"" in ( 'd790a45d-03ff-4ddb-9dea-8087722c582c', 'ceb70b3c-985f-4867-ae7c-88f9dd710688', '128c3718-771a-4d1e-9035-6fa135ca5f70', '7a90900b-53b5-4598-92b3-0aee90626c56')"; var selectQuery = new CustomQuery(userConnection, selectQueryString); selectQuery.Execute();