Are there date functions available in jpql? - jpql

I want to write query something like :-
Select u from bookmaster u order by Year(b.createDate),Month(b.createDate),day(b.createDate)
How do i do this in JPQL? Are there any date parsing functions available?

Well Brandizzi, theese function are in your list, but checked as 'not standard'
I've tried use them without success.
Here is an alternative:
JPA Query MONTH/YEAR functions

Related

What is the accepted syntax for PySpark's SQL expression-based filters?

The PySpark documentation for filters says that it accepts "a string of SQL expression".
Is there a reference of the accepted syntax for this parameter? The best I could find is the page about the WHERE clause in Spark SQL docs. Obviously some examples, like "id > 200", "length(name) > 3", or "id BETWEEN 200 AND 300", would work. But what about others? Filters like "age > (SELECT 42)" seem to work, so I assume nested expressions are OK. This just raises more questions:
What databases can these nested expressions refer to? Is there a way I can create a nested SELECT expression referring to the current dataframe, e.g. to do something like "age > (SELECT avg(age) FROM <current_dataframe>)" as a filter? (I know there are other ways of achieving this, I am only interested in what SQL expressions can do.)
Are there other, more advanced things that are allowed in filter expressions?
Finally, is there an online resource explaining this in more detail?

(Oracle) LIKE Clause not Working with Numeric Bind Variables

I'm having problems getting Oracle's LIKE clause working with numeric bind variables.
In the examples below the TABLEID column is numeric.
In SQLDeveloper I can write SELECT * FROM TABLEX WHERE TABLEID LIKE ('201%'); which works fine. However, when I try the same query in code using a bind variable: SELECT * FROM TABLEX WHERE TABLEID LIKE :bindVar
I get an ORA-01722: invalid number error.
I've tried surrounding the bind var with () and have tried adding the % symbol to the end of the bind value with no luck.
I'm using NodeJS to make the database calls.
Any ideas as to what I might be doing wrong here?
Datatypes should match.
If TABLEID column's datatype is NUMBER and you're comparing it to a string ( (in like '201%', '201%' is a string), then you'd apply TO_CHAR function to that column:
select * from tablex
where to_char(tableid) like :bindVar
So as it turns out the problem ended up being not with my code but the data within the table itself. Sorry to waste yall's time!

Can we write a Insert query Lookup Activity in ADF

At the end of the pipeline I wanted to write the below query
INSERT INTO [TestTable] (Job_name, status) VALUES (Job_name, current_timestamp()).
Jobname will be passed as a parameter.
Can this be written in Lookup, please let me know.
Definitely possible, but should you write massive inserts/scripts within a lookup... probably not a great idea, but see below (Truncate Example, but will work the same with an insert)
I use this method for small things like truncating a table, but never with big code that should be stored as source in the DB.
EDIT:
If you need to pass parameters or Variables into the lookup you should use string interpolation like so:
INSERT INTO dbo.MyTable
SELECT '#{variables('YourVariable')}' as Variable1,
'#{pipeline().Pipeline} as PipelineName

Excel: IF AND statement not working both ways

I'm using a IF AND statement to check a simple statement, for example A>B&BB, I get FALSE. How is that even possible?
My data sample:
It works both ways if I use AND(), but I prefer to use &.
You may "prefer to use &" but unfortunately this operator in Excel has a different meaning: string concatenation. If you dont want to use AND, you can use * instead; but you will need to parenthesize the terms.
=IF((A2>C2)*(C2<B2), TRUE, FALSE)
Use AND():
IF(AND(A2>C2,C2<B2),TRUE,FALSE)
Or as was written in comments you can use multiplication:
IF((A2>C2)*(C2<B2),TRUE,FALSE)
FYI - you don't need IF().
If you use AND(A2>C2,C2<B2) the result will be Boolean (TRUE/FALSE).

SSIS: Filtering Multiple GUIDs from String Variable as Parameter In Data Flow OLE Source

I have an SSIS package that obtains a list of new GUIDs from a SQL table. I then shred the GUIDs into a string variable so that I have them separated out by comma. An example of how they appear in the variable is:
'5f661168-aed2-4659-86ba-fd864ca341bc','f5ba6d28-7283-4bed-9f11-e8f6bef225c5'
The problem is in the data flow task. I use the variable as a parameter in a SQL query to get my source data and I cannot get my results. When the WHERE clause looks like:
WHERE [GUID] IN (?)
I get an invalid character error so I found out the implicit conversion doesn't work with the GUIDs like I thought they would. I could resolve this by putting {} around the GUID if this were a single GUID but there are a potential 4 or 5 different GUIDs this will need to retrieve at runtime.
Figuring I could get around it with this:
WHERE CAST([GUID] AS VARCHAR(50)) IN (?)
But this simply produces no results and there should be two in my current test.
I figure there must be a way to accomplish this... What am I missing?
You can't, at least not using the mechanics you have provided.
You cannot concatenate values and make that work with a parameter.
I'm open to being proven wrong on this point but I'll be damned if I can make it work.
How can I make it work?
The trick is to just go old school and make your query via string building/concatenation.
In my package, I defined two variables, filter and query. filter will be the concatenation you are already performing.
query will be an expression (right click, properties: set EvaluateAsExpression to True, Expression would be something like "SELECT * FROM dbo.RefData R WHERE R.refkey IN (" + #[User::filter] + ")"
In your data flow, then change your source to SQL Command from variable. No mapping required there.
Basic look and feel would be like
OLE Source query

Resources