How can I use "Expression.Not" with text field? - nhibernate

How can I use "Expression.Not" with text field?
I need to select all records from NHQuestionCount except "ktest"
for example this code return runtime error
NHQuestionCount[] stats = NHQuestionCount.FindAll(Order.Asc("NameFull"), Expression.Not(Expression.Eq("NameFull", "ktest")));

I can't comment on the rest of your code, but your use of Expression is exactly right.

Related

Can't Access a global view table with SQL by a selected field code converted from a dropdown selection

I am using a SQL notebook in Databricks/Spark community edition
%python
education_DF = sqlContext.sql('select * from global_temp.population_Globaltmp_view where `Education` = "2YD"')
display(education_DF)
The above code cell works fine and retrieves the desired rows from the view.
However the following code cell gives an error.
I am supbstituting the hard-coded value "2YD" in the WHERE clause, with a variable call education_choice that contains the same value.
It seems that I am not using variables correctly in SQL. How would I make this work?
%python
education_DF = sqlContext.sql('select * from global_temp.population_Globaltmp_view where `Education` = education_choice')
display(education_DF)
(This is the error)
org.apache.spark.sql.AnalysisException: cannot resolve '`education_choice`' given input columns: [global_temp.population_globaltmp_view.Salary, global_temp.population_globaltmp_view.Address, global_temp.population_globaltmp_view.Race, global_temp.population_globaltmp_view.MiddleI, global_temp.population_globaltmp_view.Education, global_temp.population_globaltmp_view.HairColor, global_temp.population_globaltmp_view.Age, global_temp.population_globaltmp_view.FullName, global_temp.population_globaltmp_view.City, global_temp.population_globaltmp_view.FirstName, global_temp.population_globaltmp_view.State, global_temp.population_globaltmp_view.LastName, global_temp.population_globaltmp_view.Height, global_temp.population_globaltmp_view.Fertility, global_temp.population_globaltmp_view.Employment, global_temp.population_globaltmp_view.Zip, global_temp.population_globaltmp_view.Weight, global_temp.population_globaltmp_view.Gender]; line 1 pos 72;
I tried the injection method suggested, but got a slightly different error this time. I included a screen shot of the relevant code cells. It seems that the education_choice "2YD" isn't being recognized as a literal but a field or something like that.
Shouldn't 2YD have quotes around it like "2YD"
If I hard code the WHERE clause like this: WHERE Education = "2YD" the queries works fine.
The image bellow is small but if you right click on it and "open in new tap, it is very readable.
*EDIT
You use the variable education_choice as a hardcoded string. Instead, you should inject the value of education_choice inside the SQL expression string like that.
*edit - wrap the variable with quoets.
%python
education_DF = sqlContext.sql('select * from global_temp.population_Globaltmp_view where `Education` = "{}"'.format(education_choice))
display(education_DF)

Why am I getting a `Data type mismatch` error when I add "CF" to the end of my search string in a SQL statement in Access?

The following query (qryCurLotNewProducts) produces a data set that I want process further with another query (qryBNP_CFRecordset):
//qryCurLotNewProducts
SELECT tblNewProducts.*
FROM tblNewProducts INNER JOIN tblCurLot ON (tblCurLot.CatalogNum = tblNewProducts.CatalogNum) AND
(tblNewProducts.LotNum = tblCurLot.CurLot);
When I run this second query to list only the "CF" products found in the first query, I get the `Data type mismatch in criteria expression' error.
//qryBNP_CFRecordset
SELECT qryCurLotNewProducts.*, tblABCategory.UNSPSC, tblAmount.ProductSize
FROM tblAmount RIGHT JOIN (tblABCategory RIGHT JOIN qryCurLotNewProducts ON tblABCategory.ABCategory = qryCurLotNewProducts.ABCategory) ON tblAmount.Amount = qryCurLotNewProducts.Amount
WHERE (((qryCurLotNewProducts.CatalogNum) Like "A700-###CF") AND ((qryCurLotNewProducts.DateEntered) Between #1/1/2000# And #3/1/2020#))
ORDER BY qryCurLotNewProducts.CatalogNum, Abs(qryCurLotNewProducts.LotNum);
If I remove the CF from the search string (so "A700-###"), the query correctly outputs a list containing all items that contain that pattern:
If I use strings like "A700-####F" or "A700-###ZZ" or other combinations like that, I don't get an error but rather an empty results set.
Notably, "A700-001CF", "A700-002CF", etc all create the data type error. It seems there is something about the CF key combination that is causing trouble.
Has anybody else ever seen this issue? Do I need to use some kind of delimiter to tell SQL to not view CF as some kind of special switch?
Abs(qryCurLotNewProducts.LotNum) wont work with the values for Products ending in CF. Your LotNum-Column has a text-type.
Edit: Your LotNum-Column has a text-type as you can see in your first screenshot.

Populate the data in its own field

How can the data be populated in its own field? See the field called 'vSoup Text'.
SELECT [iFormID]
,[iPracID]
,[iPatID]
,[vFormName]
,[vSoapText]
,[tHTML]
,[iUserID]
,[dDATE] FROM CustomForm where iPatID = 40 and vFormName = 'Diabetes Screening'
I need to break the data when you see '/br'
The only way that I've found to do this is by using a function. You could use SSIS, but the way that I've used is using a function.
https://sqlperformance.com/2012/07/t-sql-queries/split-strings

REGEXP Oracle SQL

I am having a clob field rq_dev_comments which should replace the username with "anonymous"
Update <TABLE>.req
Set rq_dev_comments = regexp_REPLACE(rq_dev_comments,
'\<[bB]\>.*gt;,', '<b>anonymous ')
where length(rq_dev_comments) > ...
Now my question is, if there is a way to check before wheather "anonymous" is already set or not and how to reduce the datasets?
Example:
rq_dev_comments = "<html><b>HendrikHeim</b>: I found an error....</html>"
Desired: "<html><b>Anonymous</b>: I found an error....</html>"
The following solution will not catch cases where "username" may appear more than once, and some but not all occurrences have already been replaced with "anonymous". So think twice before you use it. (The same would apply to ANY solutions along the lines of what you asked!)
Add the following to your WHERE clause:
... where length(...) ....
and dbms_lob.instr(rq_dev_comments, '<b>Anonymous') = 0
"= 0" means the search pattern wasn't found in the input string.
Another thing: In the example you show "anonymous" capitalized (with upper case A), but in your code you have it all lower case. Decide one way or another and be consistent. Good luck!

SQL Full Text Contains not returning expected rows

I have a Body column that is full text indexed and is nvarchar(max)
One row has this in the Body column
You want slighty mad this sat the 60th runing of the 3peaks race! Peny-ghent whernside and inglbauher! Only in yorkshire!
If I run: select body from messages where CONTAINS(Body,'you') it doesn't return any data.
If I run the below adding wildcards select messageid,body from messages where CONTAINS(body,'"*you*"') it still doesnt return the data.
Can you help me understand what's going on please?
Thanks
UPDATE : It makes no difference if its you or You, either way no results
It can be case sensitivity issue. Try with select messageid,body from messages where CONTAINS(body,'"*You*"') and see if you are getting the result or not
A full text catalog has a set of words in a “stoplist” that it won’t search on as SQL Server considers them “unimportant for search purposes”
To get this you can run
select ssw.*
from sys.fulltext_system_stopwords ssw
where ssw.language_id = 1033;
Below are the words it won’t search on and you’ll see it contains “you” hence why it didn’t find my data.