Using 'OR' in SphinxQL - sphinx

I can use pipes in side the MATCH in SphinxQl e.g.
Select * from idx_A where MATCH('(#(Title) Apple)|(#(Body) Orange)')
but not outside the match
Select * from idx_A where MATCH('(#(Title) Apple)|(#(Body) Orange)') and Title='Apple' or Body='Orange'
as I get an error similar to:
[Err] 1064 - sphinxql: syntax error, unexpected OR, expecting $end near 'or Body='Orange`
Am I using incorrect syntax outside of the MATCH() or is it not possible to construct here using 'OR'?

Related

Is there any way to add multiple labels to a node?

Let's say I'm creating a database about food and in it, I want to add Dal which would be both Curry and Lentil.
SELECT * FROM cypher('menu', $$
CREATE (:LENTIL:CURRY {name:"Dal"})
$$) AS (dal agtype);
2023-02-20 06:49:01.568 IST [145143] ERROR: syntax error at or near ":" at character 49
2023-02-20 06:49:01.568 IST [145143] STATEMENT: SELECT * FROM cypher('menu', $$
CREATE (:LENTIL:CURRY {name:"Dal"})
$$) AS (dal agtype);
ERROR: syntax error at or near ":"
LINE 2: CREATE (:LENTIL:CURRY {name:"Dal"})
That does not seem to be working.
It does not work with SET clause either: -
SELECT * FROM cypher('menu', $$
MATCH (dal:CURRY {name: "Dal Makhani"})
SET dal:LENTIL
RETURN dal
$$) AS (dal agtype);
2023-02-20 06:29:38.402 IST [145143] ERROR: syntax error at or near ":" at character 80
2023-02-20 06:29:38.402 IST [145143] STATEMENT: SELECT * FROM cypher('menu', $$
MATCH (dal:CURRY {name: "Dal Makhani"})
SET dal:LENTIL
RETURN dal
$$) AS (dal agtype);
ERROR: syntax error at or near ":"
LINE 3: SET dal:LENTIL
Is there any work-around for this?
This feature is currently in development. Through label inheritance it will be possible to set multiple labels for a single node in AGE.
Keep an eye on this branch for more updates:
https://github.com/apache/age/tree/AGE_label_inheritance

In Postgres how do I apply UPPER/LOWER on a list of strings? I am able to apply UPPER/LOWER on a single String

However when I tried on a list of String it is throwing error.
select distinct(tx.sub_tran_type)
from tran.txn tx
where tx.sub_tran_type = UPPER('homede')
limit 100
This query runs fine . However if you look at
select distinct(tx.sub_tran_type)
from tran.txn tx
where tx.sub_tran_type in UPPER('homede','online','omni-online','amznow')
limit 100
It throws this error:
SQL Error [42601]: ERROR: syntax error at or near "UPPER"`
This is just a trick. You can try this with your case:
select distinct tx.sub_tran_type
from tran.txn tx
where tx.sub_tran_type in (SELECT upper(unnest(array['homede','online','omni-online','amznow'])))
limit 100

Unable To Assign Query Result To A Variable In PostgreSQL

I have been struggling to assign the query result to a temp variable in PostgreSQL and I just can't get it to work. Can anyone guide please?
I tried with the both the below queries and I get the error shown below. I then tried with temp table. But it still fails during the assignment to the temp variable.
set var.ITEM_ID =(select t.item_id from api_item t inner join api_identifier i on i.item_id=t.item_id where i.value='99999');
set var.ITEM_ID = select t.item_id from api_item t inner join api_identifier i on i.item_id=t.item_id where i.value='99999';
The first statement throws the error :-
[2020-03-03 08:10:50] [42601] ERROR: syntax error at or near "("
[2020-03-03 08:10:50] Position: 23
Second one throws the below error:-
[2020-03-03 08:10:55] [42601] ERROR: syntax error at or near "select"
[2020-03-03 08:10:55] Position: 24

Expression for Lookup activity result when stored procedure returns scalar value

I'm using a Lookup activity that returns an scalar result and I want to use that result to build a dinamic query using a concat expression. However, I'm receiving an error complaining that my SQL query is not well formated. This is how I'm building the query:
#concat('SELECT v.CscadaEventId as EventId,
v.EndDate as EndDateUtc
FROM v_cscadaevents v
INNER JOIN cscadaevents e
ON e.cscadaeventId = v.CscadaEventId
WHERE v.CscadaEventId IN(', activity('LookupUnfinishedAlarms').output.firstRow, ') AND e.EndDate IS NOT NULL;')
I expect that to return a query like this:
SELECT v.CscadaEventId as EventId,
v.EndDate as EndDateUtc
FROM v_cscadaevents v
INNER JOIN cscadaevents e
ON e.cscadaeventId = v.CscadaEventId WHERE v.CscadaEventId IN(2329390,2340616,2342078,2345857,2361240,2362088,2362574,2377062,2378594,2379357) AND e.EndDate IS NOT NULL;
I had see some examples where the lookup return multiple columns, and the right expression is activity('LookupUnfinishedAlarms').output.firstRow.myColumnName but what about when the lookup activity return an scalar value, as in my case?
This is the full error so far:
You have an error in your SQL syntax; check the manual that
corresponds to your MariaDB server version for the right syntax to use
near
'\"output\":\"2329390,2340616,2342078,2345857,2361240,2362088,2362574,2377062,237859'
at line
6,Source=Microsoft.DataTransfer.Runtime.GenericOdbcConnectors,''Type=System.Data.Odbc.OdbcException,Message=ERROR
[42000] [Microsoft][MariaDB] You have an error in your SQL syntax;
check the manual that corresponds to your MariaDB server version for
the right syntax to use near
'\"output\":\"2329390,2340616,2342078,2345857,2361240,2362088,2362574,2377062,237859'
at line 6,Source=MariaDBODBC_sb64.dll
Ok, just for the records, I found the solution. The expression must be:
#concat('SELECT v.CscadaEventId as EventId,
v.EndDate as EndDateUtc
FROM v_cscadaevents v
INNER JOIN cscadaevents e
ON e.cscadaeventId = v.CscadaEventId
WHERE v.CscadaEventId IN(', activity('LookupUnfinishedAlarms').output.firstRow.output, ') AND e.EndDate IS NOT NULL;')
So, the default column becomes output

intersystem cache C# query with datetime

When I use cache sql query in C# I'm getting an error:
SQLtext1 = "SELECT top 10 * FROM dbo.DAPPLICATIONSTAT where TIMESTAMP = '2015-02-01 00:00:00'"
I would like to use a where clause with a datetime filter.
I am using InterSystems.Data.CacheClient.dll to execute the query.
Error Messge :
[SQLCODE: <-4>:<A term expected, beginning with one of the following: identifier, constant, aggregate, %ALPHAUP, %EXACT, %MVR, %SQLSTRING, %SQLUPPER, %STRING, %UPPER, $$, :, +, -, (, NOT, EXISTS, or FOR>]
[Cache Error: <<SYNTAX>errdone+2^%qaqqt>] [Details: <Prepare>]
[%msg: < SQL ERROR #4: A term expected, beginning with either of: (, NOT, EXISTS, or FOR^SELECT top :%qpar(1) * FROM dbo . DAPPLICATIONSTAT where TIMESTAMP>
I think that you have reserved word TIMESTAMP and so, you have that error
Try this SQL query, where filedname TIMESTAMP in dobled quotas
SELECT top 10 * FROM dbo.DAPPLICATIONSTAT where "TIMESTAMP" = '2015-02-01 00:00:00'