How to combine a control command with a parameterized query in Kusto? - azure-data-explorer

According to this doc page the result of a control command can be used in a query by using $command_results.
Now, how to achieve that when the query makes use of query_parameters?
.show tables;
declare query_parameters(_rootPath:string = "root")
$command_results
| where Folder startswith _rootPath
This throws
400 - "General_BadRequest: Request is invalid and cannot be executed.
Syntax error: Query could not be parsed: SYN0002: A recognition error occurred. [line:position=3:0]

you're missing a semicolon (;) after declare query_parameters(_rootPath:string = "root")

Related

Simplest way to validate non-library module

What is the simplest way to validate there are no syntax errors in an XQuery file? I want to test a number of xquery files as a part of routine testing to verify that no bad files exist with simple syntax errors. Generally for library modules I import the library module and that is enough to validate syntax of the file.
BaseX has an option RUNQUERY that can be used to disable query execution, so it only gets parsed. For using the command line, use the -R off flag.
The query can be passed as string, here I'm using the very simple query 1+1, which is totally valid and will not return any output, but a return value of 0.
basex -R off "1+1"
Passing an invalid query will return a syntax error message, and a non-zero return code.
basex -R off "1foo"
Stopped at [snip], 1/2:
[XPST0003] Expecting separator after number.
I guess there will be similar options for other XQuery implementations, but they're not standardized, so you'll have to look them up in the individual manuals.

Sparql Query at endpoint

I want to run the following sparql query at an endpoint:
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
SELECT DISTINCT ?name WHERE{?person foaf:name ?name.FILTER regex(str(?name), "+ns+","i")}
I'm coding in C# on Visual Studio, and would send this query to the endpoint. It should check the results without any case-senstivity, but writing the query this way gives an error in visual studio. How do I correct it?
Update (based on author's clarification that "i" is where the problem lies):
You need to properly escape the " symbol so that it gets included in the SPARQL query string. Currently the ["] before [i] signals the end of the text string. No wonder you get an error message.
See MSDN: String literals for escaping rules:
either " escape as \" or make the string a C# verbatim literal and escape as ""
Check DotNetRdf documentation for Querying with SPARQL examples.
It shows both how to run SPARQL queries (using DotNetRdf) and how to inject variable values into queries (what you are trying to do with "+ns+" and "i").
Also:
answers.semanticweb.com is a good place to ask Semantic Web / RDF / SPARQL questions
please describe the error you are getting (what Ren asked in comments above)

Fql access error in C# .net?

I am trying to access the following info using FQL in c# .However am getting an HTTP bad request error
string Frnds = api.Get("/fql?q=SELECT+uid+name+username+locale+affiliations+timezone+birthday+sex+proxied_email+current_location+FROM+user+WHERE+uid=me()");
Is there some problem with my query , It seems to look fine to me ?
Have you tried separating each field name with a comma (,) then urlencoding it
you can test out your query here - please note in the following link I added in ","
https://developers.facebook.com/tools/explorer?method=GET&path=fql%3Fq%3DSELECT%20uid%2C%20name%2C%20username%2C%20locale%2C%20affiliations%2C%20timezone%2C%20birthday%2C%20sex%2C%20proxied_email%20%2Ccurrent_location%20FROM%20user%20WHERE%20uid%3Dme%28%29
your query can't parse the fields correctly
https://developers.facebook.com/tools/explorer?method=GET&path=fql%3Fq%3DSELECT%20uid%20name%20username%20locale%20affiliations%20timezone%20birthday%20sex%20proxied_email%20current_location%20FROM%20user%20WHERE%20uid%3Dme%28%29

Using ora:view with XMLTable to Query a Relational Table as XML

I have an Oracle relational table called DOCTYPES with columns ID, DOCTYPE, SUBTYPE.
When I run the following statement in Oracle SQL Developer
SELECT * FROM XMLTable('for $i in ora:view("LAZ", "DOCTYPES")/ROW
return $i/SUBTYPE')
I get back the results between tags as expected. But when I run the following statement I get an error:
SELECT * FROM XMLTable('for $i in ora:view("LAZ", "DOCTYPES")/ROW
return <SUBTYPE="{$i/SUBTYPE}"/>')
LPX-00801: XQuery syntax error at '='. I don't understand why the second statement doesn't work.
Thank you very much for your help in advance.
Don't know what Oracle makes of XQuery, but the statement between the apostrophes clearly has an XQuery syntax error at '=', as IMO was correctly diagnosed.
This is because you are opening a direct element constructor, but an equals sign incorrectly follows the tag name. An equals sign is used inside of a direct element constructor to separate attribute names from attribute values. So the following might work:
SELECT * FROM XMLTable('for $i in ora:view("LAZ", "DOCTYPES")/ROW
return <SUBTYPE name="{$i/SUBTYPE}"/>')
For the specification, please refer to 3.7.1 Direct Element Constructors in the XQuery recommendation.
Syntax was wrong.
SELECT * FROM XMLTable('for $i in ora:view("LAZ", "DOCTYPES")/ROW
return <SUBTYPE="{data($i/SUBTYPE)}"/>')

ASP Classic page quit working

I've had a set of legacy pages running on my IIS7 server for at least a year. Sometime last week something changed and now this line:
Response.Write CStr(myRS(0).name) & "=" & Cstr(myRS(0).value)
which used to return nothing more exciting than the string: 'Updated=true' (the sproc processing input params, stores them to a table, checks for errors and when that's all done returns a success code by executing this statement:
select 'true' as [Updated]
Now my pageside error handler is being involved and offers:
myError=Error from /logQuizScore.asp
Error source: Microsoft VBScript runtime error
Error number: 13
Error description: Type mismatch
Important to note that all lots of pages use the same framework - same db, same coding format, connecitonstrings and (so far as I can tell) all others are working.
Troubleshot to this point:
The call to the stored procedure is working correctly (stuff is stored to the given table). The output from the stored procedure is working correctly (i can execute a direct call with the given parameters and stuff works. I can see profiler calling and passing. I can replace all code with 'select 'true' as updated' and the error is the same.
everything up to the response.write statement above is correct.
So something changed how ADO renders that particular recordset.
So i try: Response.Write myRS.Item.count
and get:
Error number: 424
Error description: Object required
The recordset object seems not to be instantiating but the command object _did execute. Repeat - lots of other pages just the same basic logic to hit other sprocs without a problem.
full code snippet
set cmd1 = Server.CreateObject("ADODB.Command")
cmd1.ActiveConnection = MM_cnCompliance4_STRING
cmd1.CommandText = "dbo._usp_UserAnswers_INSERT"
...
cmd1.CommandType = 4
cmd1.CommandTimeout = 0
cmd1.Prepared = true
set myRS = cmd1.Execute
Response.Write CStr(myRS(0).name) & "=" & Cstr(myRS(0).value)
It seems to me that the sproc has changed and returns a scalar instead of a result set.
Changing CommandType = 1 (adCmdText) is need to match with your query changed to SELECT 'whateveryouwannatry' AS [updated].
Since you stated that nothing in the asp code changed we can rule out that the return type of your command/sproc was altered by specifying an output parameter.

Resources