DMN Feel multiple Not Equals (!=) - operators

I am reaching out to inquire about a challenge with DMN FEEL Logical Operator not equals.
Basically we are not getting a correct result when placing multiple Not Equals (!=) in a single field. From the attached example, we basically placed a condition in the 3rd column where if the Input.CallPurpose.Code is not equals to 2 or 1 - !="2", !="1" - then it should hit that row and return the output, but if we pass "2" or "1" then it should skip this row and try to hit the following rows accordingly.
In our case, If we pass (2) It hits the first operator (!= 2) and will skip the row which is the expected result; however if we pass (1) it will not compare to the second (!=) and it will not skip the row which is the incorrect result
If we pass a single != it works
Any help at this point would be much appreciated
Thanks

Possibly the most idiomatic way to do this, is to do something like:
not("B", "A")
So you want that if you supply either "A" or "B" it would match the first row.
Example supplying C:
In this case matches the first row because C is not A, not B.
Example supplying A:
In this case A is matched in the first row using basic unary tests.
If you wanted a generalized extended unary test you could write
not( ? in ["A", "B"])
too.

For future reference, this was solved by using the below syntax:
!=["option 1", "option 2", "option 3"]

Related

Regex match first number if it does not appear at the end

I am currently facing a Regex problem which apparently I cannot find an answer to.
My Regex is embedded in a teradata SQL of the form:
REGEXP_SUBSTR(column, 'regex_pattern')
I want to find the first appearance of any number except if it appears at the end of the string.
For Example:
"YEL2X30" -> "2"
"YEL19XYZ05" -> "19"
"YELLOW05" -> ""
I tried it with '[0-9]+(?!$)/' but this returns me a blank String always.
Thanks in Advance!
Shot in the dark here since I'm unfamiliar with teradata and the supported SQL-functionality. However, reading the docs on the REGEXP_SUBSTR() function it seems like you may want to use the 3rd and 4th possible argument along with a slightly different regular expression:
[0-9]+(?![0-9]|$)
Meaning: 1+ Digits that are not followed by either the end of the string or another digit.
I'd believe the following syntax may work now to retrieve the 1st appearance of any number from the matching results:
REGEXP_SUBSTR(column, '[0-9]+(?![0-9]|$)', 1, 1)
The 3rd parameter states from which position in the source-string we need to start searching whereas the 4th will return the 1st match from any possible multiple matches (is how I read the docs). For example: abc123def456ghi789 whould return 123.
Fiddling around in online IDE's gave me that:
CREATE TABLE TBL (TST varchar(100));
INSERT INTO TBL values ('YEL2X30'), ('YEL19XYZ05'), ('YELLOW05'), ('abc123def456ghi789');
SELECT REGEXP_SUBSTR(TST, '[0-9]+(?![0-9]|$)', 1, 1) as 'RESULTS' FROM TBL;
Resulted in:
RESULTS
2
19
NULL
123
NOTE: I also noticed that leaving out the 3rd and 4th parameter made no difference since they will default back to 1 without explicitly mentioning them. I tested this over here.
Possibly the simplest way is to look for digits followed by a non-digit. Then keep all the digits:
regexp_substr(regexp_substr(column, '[0-9]+[^0-9]'), '[0-9]+')

What does command LIKE '[atoz:a]%' mean in SQL Server?

I've inherited a database and application from a project and I'm trying to debug a problem with a database query.
There's a line in the query that reads:
WHERE property_title LIKE '[atoz:a]%'
I'm struggling to understand what the atoz command is doing as I've never come across it before - I assumed it was stating that it would only allow characters in the title - but some of the titles contain symbols such as () or -
I've tried searching for it on Google but I must be using the wrong terminology as nothing is appearing. If someone could explain it to me, or point me to a resource that would be great!
Thanks
This is looking for property_title that starts with the letters "a", "t", "o", "z" and ":". The second "a" is redundant.
I would guess the intention is actually:
WHERE property_title LIKE '[a-z]%'
which would specify that the property title starts with a letter (or a lower case letter, depending on the collation being used).
This is just part of the LIKE operator of T-SQL:
[ ]
Any single character within the specified range ([a-f]) or set ([abcdef]).
WHERE au_lname LIKE '[C-P]arsen' finds author last names ending with arsen and starting with any single character between C and P, for example Carsen, Larsen, Karsen, and so on. In range searches, the characters included in the range may vary depending on the sorting rules of the collation.
The exact expression you're seeing:
'[atoz:a]%'
basically means this:
First any single character that can be one of the following:
a, t, o, z, or :
Then followed by anything (even nothing)
Note that atoz does not mean any character from a to z, it literally means the 4 characters a, t, o and z. To get any character from a to z you would use [a-z]. The second a in the expression is redundant, as [aa] means the same as [a].

StringTemplate 3: how to filter a list?

How can I remove specific elements from a list(=multi-valued-attribute) using a map? For example, let's say I want to filter out all b's in a given list:
<["a", "b", "c", "b"]: {<table.(it)>}; separator=",">
table ::= ["b":, default: key]
The desired outcome would be "a,c" but the actual result is "a,,c,"
The thing is that the map successfully turn b's into nulls, but then they're wrapped in an anonymous template {} and become non-null values. So they won't go away with strip() function, either.
So the question is, would it be possible to filter a list using a map by slightly modifying the code above?
update
I've found a workaround:
filter(it) ::= "<if(it)><it><endif>"
<["a", "b", "c", "b"]: {<table.(it)>}: filter(); separator=",">
This gives the result I wanted: a,c
Might not want to filter in your template, but nonetheless, could be a bug.
Ok, i checked it out. That gives empty not null so it thinks it's an item. ST treats false conditionals same way: empty not null. I think you need to filter in model.

What does this JDBC snippet achieves?

String q = "SELECT attr FROM students foo =? AND bar = ?";
PreparedStatement s= connection.prepareStatement(q);
s.setString(1,"a");
s.setString(2."b");
ResultSet rs = s.executeQuery();
if(rs.next())
{
System.out.println("aba");
}
else
{
System.out.println("zab");
}
I'm not entirely sure, but my interpretation is that it performs query to find "attr" from "students" where foo is something and bar is something. In case of successful results from query it prints out aba, otherwise it will print out zab.
Correct me if i'm wrong.What s.setStrings(1,"a") are for? What exactly question mark stands for?
You are mostly right. If there is at least one row in the students table, with field foo='a' and bar='b', this prints out aba, if no such line exists, it prints out zab
The question marks and the0 .setString(1,"a") statements are closely related. The ? denotes a parameter (placeholder, if that is more convenient to grasp) to the query, and the s.set<datatype>() methods 'fill these in'. The first parameter specifies the parameter to fill in, the second specifies the value.
Recommended reading: Using PreparedStatements
The question mark in the query represents the values to be added later on. They act as placeholders.
So you prepare the query once and then just set the values using, e.g.,
s.setString(1,"a");
This sets the first value (aka the first question mark) to a string value of a. There are respective functions for other types like, for example, setInt() or setLong().

How SQL/sqlite wildcars work? LIKE operator

How wildcards in sqlite work. Or how LIKE operator matches.
For examle lets say:
1: LIKE('s%s%', 's12s12')
2: LIKE('asdaska', '%sk%')
In 1st example what % matches after 1st s, and how it decides to continue matching % or s after %.
In 2nd example if s matches first then FALSE returned.
Both examples return TRUE. From my Programming knowledge I came up with that LIKE function is some like a recursive function that when 2 possibilities appear function calls itself with 2 different params and uses OR between them, then obviously if one call returns true, upper function directly returns true. If it is so, then LIKE operator is quiet slow to use on large DBs.
P.S. There is one more '_' wildcard which matches exactly one character
I couldnt find any detailed documentation of LIKE operator.
% matches zero or more characters, _ matches exactly one.
Your first pattern 's%s%' would match, 'ss', 's1s', 's1111s', 'ss1111', etc. etc.
However if you wrote 's_s_' it would match 's1s1', but none of the above.