Can't find what is wrong with filter syntax:
http://localhost:27161/NorthwindsService.svc/Categories?$select=CategoryName,CategoryID&$filter=CategoryName Eq 'Beverages'
Have error:
Syntax error at position 15 in 'CategoryName Eq 'Beverages''
OData queries are case sensitive. Eq is not a valid operator for the filter query, but eq is.
this should work :
http://localhost:27161/NorthwindsService.svc/Categories?$select=CategoryName,CategoryID&$filter=CategoryName eq 'Beverages'
Related
I have the form where user have to select the value from the list. List is created by administrators. In one of the lists there is an option for user to pick NO value that stands for some reserved code. Something like Not Occupied. So I use JQuery and AJAX to communicate with the server. On the back end I use ColdFusion 9 on my production server. So in order to bring back NO I have to convert that to 'NO ' with the space. If I don't do this function will return false value on the client side. Here is example of my code conversion:
<cfset convertYesNo = {
YES : "YES ",
NO : "NO "
}>
<cfset qryRecs['value'] = URLEncodedFormat(structKeyExists(convertYesNo, myInfo[CurrentRow]) ? convertYesNo[myInfo[CurrentRow]] : myInfo[CurrentRow])>
Code above worked fine on my development site. The only difference is that on development we have ColdFusion 10 and on the live we have ColdFusion 9. So once I moved the code to live I started getting error message:
ColdFusion was looking at the following text:<p>{</p><p>The CFML compiler was processing:<ul><li>A cfset tag beginning on line 1071, column 18.<li>A cfset tag beginning on line 1071, column 18.
<pre>1069 : }>
1070 :
<b>1071 : <cfset convertYesNo = {</b>
1072 : "Yes" : "Yes ",
1073 : "No" : "No "
</pre>
I have tried to put quotes around YES and NO but that did not help. If anyone knows the way how to fix this problem please let me know. thanks in advance!
I think structure notation for CF9 did not support this syntax. Try the following (= instead of : separating key-value pairs).
<cfset convertYesNo = {
YES = "YES ",
NO = "NO "
}>
<cfset qryRecs['value'] = URLEncodedFormat(structKeyExists(convertYesNo, myInfo[CurrentRow]) ? convertYesNo[myInfo[CurrentRow]] : myInfo[CurrentRow])>
Structs (HashTables) are great at fast finding of keys, but you only have 2 key here, so a much more efficient construct would be (example in cfscript syntax):
qryRecs['value'] = URLEncodedFormat(
listFindNoCase("YES,NO", myInfo[CurrentRow]) ?
uCase(myInfo[CurrentRow]) & " "
:
myInfo[CurrentRow]
);
Though for better readability and code maintenance you should consider to break it into multiple statements:
value = myInfo[CurrentRow];
if (value == "YES" || value == "NO") // use EQ operator in CFML syntax
value = uCase(value) & " ";
qryRecs['value'] = URLEncodedFormat(value);
Experimenting with the language I've found that select is defined in the global scope and its precedence is higher than local variables.
def example(select)
puts select
end
example 3
# Syntax error in eval:3: unexpected token: end (expecting when, else or end)
So experimenting with select step by step I get this:
select 1 end
# Syntax error in eval:3: unexpected token: end (expecting when, else or end)
and then
select when 1 end
# Syntax error in eval:1: invalid select when expression: must be an assignment or call
then
select when x = 1 end
# Syntax error in eval:1: invalid select when expression: must be an assignment or call
then
select when x
# Syntax error in eval:1: unexpected token: EOF (expecting ',', ';' or '
I'll skip ahead a few steps as you should have an idea of how I've come to my question…
select when x;
else y
end
# Error in line 1: undefined local variable or method 'x_select_action'
and lastly
x_select_action = 4
select when x;
else y
end
# Error in line 3: undefined method 'x_select_action' (If you declared 'x_select_action' in a suffix if, declare it in a regular if for this to work. If the variable was declared in a macro it's not visible outside it)
So there is this keyword in the language which precedes local variables precedence and I don't know what it's for. But apparently it looks for x_select_action when x is given as a when clause. What is this select for and how is it meant to be used?
Searching online I see select defined on Enumerable, Hash, Channel, and Array… but at first glance these don't seem to be it.
Thanks for the help!
It's similar to Go's select: https://tour.golang.org/concurrency/5
But it still needs some tweaks to be finished, that's why there are no docs about it yet.
I'm trying to use a regex pattern matching with PostgreSQL 9.4:
Have looked through previous answers but nothing I can find matches this particular problem
select 'apple' ~ '^.*pp.*$' returns 't' as expected
update <table> set column = 'value' where name ~* '^.*pp.*$' also works.
But:
update <table> set column = 'value' from <other_table> where name ~* '^.*pp.*$' produces an error:
The specific example:
update
members set
pattern = a.pattern
from
services a
where
organisation ~* '^.*' || replace(a.pattern, ' ', '.*') || '.*$';
ERROR: argument of WHERE must be type boolean, not type text
LINE 1: ...attern = a.pattern from services a where organisati...
It seems the where clause after the FROM table in the update is not recognising or processing the regex operator correctly.
Or, equally probably, I'm misunderstanding the UPDATE...FROM syntax
Many thanks if you can help
you are missing brackets around string expressions. These operators (~ and ||) has same priority and then are evaluated from left.
postgres=# update foo set b = a where a ~ 'ab';
UPDATE 1
postgres=# update foo set b = a where a ~ 'ab' || 'xxxx';
ERROR: argument of WHERE must be type boolean, not type text
LINE 1: update foo set b = a where a ~ 'ab' || 'xxxx';
^
postgres=# update foo set b = a where a ~ ('ab' || 'xxxx');
UPDATE 0
Could you please help me understand why this statement is incorrect (from a quiz). For some reason I can't see a problem.
if total = 140 then status EQ 'works';
Thanks!
eq is the comparison equals operator, not the assignment equals operator. = performs both roles.
So,
if total eq 140 then status='works';
would be perfectly legal.
I have just started learning SML and still in the process of making sense of its error messages.
when trying to input the function definition below
val rec : real->real = fn 0.0 => 0.0 | n:real => 1.0/n;
i get the following error :
stdIn:25.9-25.17 Error: syntax error: deleting COLON ID ARROW
stdIn:25.24-25.33 Error: syntax error: deleting FN REAL DARROW
stdIn:25.38 Error: syntax error found at BAR
can someone point out what i am doing wrong ?
thank you.
You have two errors in your code:
Between val rec and the type annotation there should be the name of the value you're defining.
You can't use pattern matching on reals. Since reals are inexact, they aren't equality types, so you can't use = on them either. You need to use Real.== to compare reals for equality (or better: don't compare them for equality, but compare them against some delta instead).