I need to implement SCD Type 2
this is my condition in my split condition before updating my RecordEndDate and eventually adding it in the database. But even though it does not satisfy the condition it still keeps on adding it in the database
((PlateNo == Stage_PlateNo)) && (([Car Name] != [Stage_Model]) ||
([Manufacturer] != [Stage_Manufacturer]) ||
[Year Model] != Stage_Year ||
[Car Body Type] != Stage_BodyType ||
Transmission != Stage_Transmission ||
[Daily Rate (in Peso)] != Stage_DailyRate
)
IMO your requirements are far too complex to attempt in an SSIS Expression. I recommend you recode this logic in a Script transformation. I would pre-create a new Column e.g. Include_Row and in the Script set it's value to yes or no.
This approach will give you much more code flexibility and better debugging possibilities.
Related
We created a helper function to create wheres easier. It works fine with eq, neq, lt and gt. Now we're trying to add is null/is not null (for a date column, not sure if that matters).
The critical part of the function looks like this:
// This is ran in a loop for every attribute
const query = `${attribute}` ${comparator} :value${index}`;
// if the checked 'value' is NULL then use IsNull(), same for NOT NULL, otherwise simply use value
const params = { [`value${index}`]: value == 'NULL' ? IsNull() : value === 'NOT NULL' ? Not(IsNull()) : value};
// Add this (sub)query to the qb
qb.andWhere(query, params);
Now we get an error saying this:
You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use
near ’_type = ‘not’, _value = ‘[object Object]‘, _useParameter =
true, `_multipl’ at line 1"
Value is [object Object] - which kind of makes sense if we use IsNotNull(), right?
As far as I understand from this comment, IsNull() and Not(IsNull()) should work like we are trying to.
We use #nestjs/typeorm 7.1.5.
To check for NULL you need
qb.andWhere(`${attribute} IS NULL`)
To check for NOT NULL you need
qb.andWhere(`${attribute} IS NOT NULL`)
(Note: Omit the second argument, parameters, for these cases).
From your code seems you are using string values 'NULL' and 'NOT NULL' as the value arguments and checking these as special cases. Your code will now look like this:
if ((value == 'NULL' && comparator == '=') || (value == 'NOT NULL' && comparator == '<>'))
qb.andWhere(`${attribute} IS NULL`);
if ((value == 'NOT NULL' && comparator == '=') || (value == 'NULL' && comparator == '<>'))
qb.andWhere(`${attribute} IS NOT NULL`);
else
qb.andWhere(`${attribute} ${comparator} :value${index}`, { [`value${index}`]: value});
(In the code above I check for '=' and '<>' which are standard SQL comparison operators. If your SQL dialect uses 'eq' and 'ne' in place of '=' and '<>', which you mention in your question, you will need to change the code above. If so please update your question and add the appropriate tag to say which SQL database you are using).
When you test this, I recommend that you turn on TypeOrm full logging so you can see the actual generated SQL and you be able to quickly solve any problems. See TypeOrm logging.
so, I want to use conditional logic in my code, which the condition is when I got response.response_code == '00' so it will run
And match response == res_3[0]
And match each response.data.bills == res_3[1]
And if response.response_code != '00' , it will run
And match response == res_3
And match each response.data.bills == res_3
so, what is the best conditional logic for this case ??
Read the docs please: https://github.com/intuit/karate#conditional-logic
Use a second feature file:
* eval if (response.response_code != '00') karate.call('it-will-run.feature')
Note: you can't use match where JavaScript is expected, refer: https://stackoverflow.com/a/53961806/143475
Hi im trying to do an event alarms system that It is thought to depend on a list of undeterminated concatened conditional rules. Here comes my logical problem, when im trying to structure the database to save this conditional rules in a table, i cant figure out how exactly trace the hierarchy of the expressions, for example if i wanna save the conditión
[(1 =< 2 && 2 == 2) || (0 == 0 || 1 == 1)] && (1 == 1) or any undeterminated number of concatened conditional rules. Can anybody help o almost understand me ?
P.D: Sorry my bad english (:
I am working with iReport. Here is the situation:
I have some parameters named branchID, spType.
I have created one variable named branchName (string) which is by default null.
What I need to do is, to change/ edit the value of the variable branchName depending on the values of branchID and spType
How can I do this with JasperReports using If Else. Is it something with the properties of the variable branchName? Any help/ Suggestion would be highly appreciated.
Expressions Scripting Language in Jasper reports is your friend!
What i can fathom from your query is that you want to compute the value of a variable based on values of two parameters. In short, you want to do something like:-
Simple if-else
If (branchId == 1 && spType == "abc")
branchName = "Xyz1";
else
branchName = "Xyz2";
In Jasper scripting language, the above expression can be written as :-
($P{branchId}==1 &&
$P{spType} != null &&
$P{spType}.equals("abc"))?"Xyz1":"Xyz2"
Nested If-else
If (branchId == 1 && spType == "abc")
branchName = "Xyz1";
else if (branchId = 2 && spType == "def")
branchName = "Xyz2";
else
branchName = "Xyz3";
Jasper expression:
( $P{branchId} ==1 &&
$P{spType} !=null &&
$P{spType}.equals("abc") ) ? "Xyz1" :
(($P{branchId} == 2 &&
$P{spType} != null &&
$P{spType}.equals("def")) ? "Xyz2" : "Xyz3");
For more details, have a look at this tutorial:
http://www.tutorialspoint.com/jasper_reports/jasper_report_expression.htm
Here is a similar stackoverflow question also:
doing comparison if else in JasperReports
For core concept, Page no. 10 of this pdf:
http://jasperreports.sourceforge.net/JasperReports-Ultimate-Guide-3.pdf
iReport support scripting using expressions.
You can right click on a report element and click edit expression to open the expression editor.
Some useful notes in this answer as well.
This question may have been answered somewhere (and if so I would love to have the link!). But since I don't know what type of linq query I'm trying to do, I haven't been able to find anything to help me.
I already have a very simple query setup to get all records of type DomainSequences.
var query = db.DomainSequences;
There are different types of domain sequences. I want to get all of them. However, for records that have a DomainType attribute equal to 'AT', then I only want to return some of those of 'AT' records (ie. do a where clause on those to filter the 'AT' records but still want to return all non 'AT' records.
More simply put, I want to get all DomainSequence records, but for the records that have a DomainType == "AT", then return those only if they meet certain conditions.
I can think of a way of doing it by doing something like:
query.Where(x => x.DomainType != "AT" || (x.DomainType == "AT" && AT conditions....));
I think this should work but the problem comes when I have to do subfilters on other columns and then it starts to get messier and complicated very quickly.
Ideally, I would like to do something like
query.Where(x => x.DomainType == "AT" || x.DomainType == "KS")
.WhereIf(y => y.DomainType == "AT" then apply filter on those)
.WhereIf(z => z.DomainType == "KS" then apply filter to these);
I'm not sure if there is a way to do this type of subfilter in LINQ or in SQL (though I imagine there is). Any suggestions on how this could be done relatively cleanly?
Thanks!
It's really not all that different than what you might write in SQL. In fact, if you would try the query expression syntax approach, you might find that particular connection easier to make.
var query = from domain in db.DomainSequences
where (domain.DomainType == "AT" && domain.Foo == 42 && ...)
|| (domain.DomainType == "KS" && domain.Foo = 117 && ...)
select domain;
That maps nicely to the SQL you might expect to write
SELECT *
FROM DomainSequences
WHERE
(DomainType = 'AT' AND Foo = 42 AND ...)
OR
(DomainType = 'KS' AND Foo = 117 AND ...)
You could, of course, keep it in the fluent extension method syntax using lambdas, of course, it's just a single .Where(...) invocation, after all.
query.Where(x => x.DomainType == "AT" || x.DomainType == "KS")
.Where(y => y.DomainType != "AT" || other filter)
.Where(z => z.DomainType != "KS" || other filter);