Is the function Now() in ColdFusion case sensitive? Can I use now() instead of Now()?
Nope, not case sensitive. No ColdFusion functions are case sensitive.
Related
In the documentation, https://docs.spring.io/spring-data/neo4j/docs/current/reference/html/
it uses {0} to reference the parameter 'movieTitle'.
#Query("MATCH (movie:Movie {title={0}}) RETURN movie")
Movie getMovieFromTitle(String movieTitle);
However, in my own code, if I use "{title={0}", my IntelliJ always reports a syntax error. I can resolve the issue by changing it to
{title:{movieTitle}
Here I have to use the actual argument name and the colon plus {}.
Is there any trick for this? I don't think the documentation is wrong.
Question 2:
If I want the node label "Movie" to be a parameter, it also shows an error message:
#Query("MATCH (movie:{label} {title={0}}) RETURN movie")
Movie getMovieFromTitle(String movieTitle, String label);
I do not know what version of IntelliJ you are using but the first query is right. There is also a test case for this in the spring-data-neo4j project.
It is not possible to use the second query syntax because there is no support for this on the database level where the query gets executed. If it would be supported in SDN before making the call to the DB the query has to be parsed (and the pattern replaced) every time when the query get executed and SDN will loose the possibility to parse the query once and then just add the parameter values in subsequent calls. This will lower the performance of executing annotated query functions.
We're storing organization names in a DynamoDB table on AWS, and would like to maintain official capitalization in those business names, for example in "TNT" and "FedEx".
Our use case is that users of the application can search for organizations by name, but we'd like that their queries are interpreted case-insensitively. So, queries for "FedEx", "Fedex" or "fedex" should all return the correct item in the table.
Other databases have ways to perform queries ignoring case (for example by the ILIKE key word in PostgreSQL), by expressing queries via regular expressions, or by applying functions in the condition (for example the LOWER() function).
How can this be done in DynamoDB? The documentation on Amazon DynamoDB's Query does not provide an answer.
(The best work-around seems to be storing the name twice: once with the official capitalization in effect, and once in another field with the name converted to lowercase. Searching should then be done on the latter field, with the query search term also converted to lowercase. Yes, I know it adds redundancy to the table. It's a work-around, not an optimal solution.)
yes, exactly, when you add the new item/row, add also a new field searchName, that is the lowercase (even more, maybe only letters/numbers/spaces) of the your name field. and then search by that searchName field
Writing duplicate data in dynamodb is not a good design. The best solution would be to add ' elastic search ' to dynamodb. You can connect this component ' out of the box' using the aws console. Then use custom anayzer in elastic search to get case insensitive data.
Is it possible? I'm building a REST Api with vibe.d and implementing token authentication. Because I'm not aware in which casing the user will send me Authorization header parameter, I need to query it in case insensitive manner. For example:
string[string] foo;
foo["XXX"] = "YYY";
logInfo(*("xxx" in foo)); // BOOM. Exception here
Is it possible..?
Thanks
Simply lowercase all keys of the associative array before you store or query them.
if the case is either all lower or all upper, then you might have something like
"xxx" in foo && logInfo(foo["xxx"]);
"XXX" in foo && logInfo(foo["XXX"]);
maybe there's more efficient way to do this. If you don't have control over how the keys are entered in the AA, then it seems you have to check all casing variants when querying a specific key.
CF allow the query string to be on multiple lines. So I had my query string stored in a variable in multiple lines like
var strSQL="select
a.col1,
a.col2,
b.col3,
b.col4,
CASE WHEN Some_XYZ>0.1 THEN 'Y' ELSE 'N' END as kStatus
FROM (A_Derived_Table)
";
This is a part of REST API and query either will take too long or just times out (api service does not return results). I have many other queries written in same manner for sake of readability and never had any issue with them.
In sql server same query runs under a second.
When I modified API and returned back the generated sql, I noticed lot of \t (tab) being added to sql string. I changed the string to
var strSQL="select a.col1, a.col2, b.col3, b.col4, CASE WHEN Some_XYZ>0.1 THEN 'Y' ELSE 'N' END as kStatus FROM (A_Derived_Table)";
and everything started working well.
What/why is this behavior? Environment CF10, SQL server 2008 on IIS7
From the comments
I believe that is a known issue/limitation with writing queries in cfscript - Tip using ColdFusion query in cfscript and something to watch out for and this similar question - Error using Query Paramaters with cfscript query. There is also a mention of it here - Learning ColdFusion 9: Using CFQuery (And Other Service Tags) In CFScript
I am writing simple SELECT queries which involve parsing out date from a string.
The dates are typed in by users manually in a web application and are recorded as string in database.
I am having CASE statement to handle various date formats and use correct format specifier accordingly in TO_DATE function.
However, sometimes, users enter something that's not a valid date(e.g. 13-31-2013) by mistake and then the entire query fails. Is there any way to handle such rougue records and replace them with some default date in query so that the entire query does not fail due to single invalid date record?
I have already tried regular expressions but they are not quite reliable when it comes to handling leap years and 30/31 days in months AFAIK.
I don't have privileges to store procedures or anything like that. Its just plain simple SELECT query executed from my application.
This is a client task..
The DB will give you an error for an invalid date (the DB does not have a "TO_DATE_AND_FIX_IF_NOT_CORRECT" function).
If you've got this error- it means you already tried to cast something to an invalid date.
I recommend doing the migration to date on your application server, and in the case of exception from your code - send a default date to the DB.
Also, that way you send to the DB an object of type DbDate and not a string.
That way you achieve two goals:
1. The dates will always be what you want them to be (from the client).
2. You close the door for SQL Injection attacks.
It sounds like in your case you should write the function I mentioned...
it should look something like that:
Create or replace function TO_DATE_SPECIAL(in_date in varchar2) return DATE is
ret_val date;
begin
ret_val := to_date(in_date,'MM-DD-YYYY');
return ret_val;
exception
when others then
return to_date('01-01-2000','MM-DD-YYYY');
end;
within the query - instead of using "to_date" use the new function.
that way instead of failing - it will give you back a default date.
-> There is not IsDate function .. so you'll have to create an object for it...
I hope you've got the idea and how to use it, if not - let me know.
I ended up using crazy regex that checks leap years, 30/31 days as well.
Here it is:
((^(0?[13578]|1[02])[\/.-]?(0?[1-9]|[12][0-9]|3[01])[\/.-]?(18|19|20){0,1}[0-9]{2}$)|(^(0?[469]|11)[\/.-]?(0?[1-9]|[12][0-9]|30)[\/.-]?(18|19|20){0,1}[0-9]{2}$)|(^([0]?2)[\/.-]?(0?[1-9]|1[0-9]|2[0-8])[\/.-]?(18|19|20){0,1}[0-9]{2}$)|(^([0]?2)[\/.-]?29[\/.-]?(((18|19|20){0,1}(04|08|[2468][048]|[13579][26]))|2000|00)$))
It is modified version of the answer by McKay here.
Not the most efficient but it works. I'll wait to see if I get a better alternative.