Please review the following code and help me in fixing the error.
When i'm trying to execute it i'm getting only the records which were starting with the ENTBI-Q.But the two conditions which were written below(task%,INC%) were not getting executed.
I want the records which starts with task,incident and entbi-q.
Please note that the task and incident are the field values of one column and the entbi-q is the field values of the another coloumn.
SELECT
S1."NAME" AS "NAME",
S1."SYS_ID" AS "SYSID",
T2."ASSIGNMENT_GROUP" AS "ASSIGNMENTGROUP",
T2."NUMBER_" AS "NUMBER",
T2."CLOSED_AT" AS "CLOSEDAT",
T2."OPENED_AT" AS "OPENEDAT"
FROM
"IOD"."SYS_USER_GROUP" S1,
"IOD"."TASK" T2
WHERE
(S1."SYS_ID"=T2."ASSIGNMENT_GROUP")
AND S1."NAME" LIKE 'ENTBI-Q%'
AND T2."NUMBER" LIKE 'TASK%'
AND T2."NUMBER" LIKE 'INC%'
AND T2."NUMBER" LIKE 'TASK%'
AND T2."NUMBER" LIKE 'INC%'
This can never be true. If a string starts with TASK it cannot start with INC. You probably wanted to OR the two conditions:
AND (T2."NUMBER" LIKE 'TASK%'
OR T2."NUMBER" LIKE 'INC%')
Related
I am trying to find a way to capture relevant errors from oracle alertlog. I have one table (ORA_BLACKLIST) with column values as below (these are the values which I want to ignore from
V$DIAG_ALERT_EXT)
Below are sample data in ORA_BLACKLIST table. This table can grow based on additional error to ignore from alertlog.
ORA-07445%[kkqctdrvJPPD
ORA-07445%[kxsPurgeCursor
ORA-01013%
ORA-27037%
ORA-01110
ORA-2154
V$DIAG_ALERT_EXT contains a MESSAGE_TEXT column which contains sample text like below.
ORA-01013: user requested cancel of current operation
ORA-07445: exception encountered: core dump [kxtogboh()+22] [SIGSEGV] [ADDR:0x87] [PC:0x12292A56]
ORA-07445: exception encountered: core dump [java_util_HashMap__get()] [SIGSEGV]
ORA-00600: internal error code arguments: [qercoRopRowsets:anumrows]
I want to write a query something like below to ignore the black listed errors and only capture relevant info like below.
select
dae.instance_id,
dae.container_name,
err_count,
dae.message_level
from
ORA_BLACKLIST ob,
V$DIAG_ALERT_EXT dae
where
group by .....;
Can someone suggest a way or sample code to achieve it?
I should have provided the exact contents of blacklist table. It currently contains some regex (perl) and I want to convert it to oracle like regex and compare with v$diag_alert_ext message_text column. Below are sample perl regex in my blacklist table.
ORA-0(,|$| )
ORA-48913
ORA-00060
ORA-609(,|$| )
ORA-65011
ORA-65020 ORA-31(,|$| )
ORA-7452 ORA-959(,|$| )
ORA-3136(,|)|$| )
ORA-07445.[kkqctdrvJPPD
ORA-07445.[kxsPurgeCursor –
Your blacklist table looks like like patterns, not regular expressions.
You can write a query like this:
select dae.* -- or whatever columns you want
from V$DIAG_ALERT_EXT dae
where not exists (select 1
from ORA_BLACKLIST ob
where dae.message_text like ob.<column name>
);
This will not have particularly good performance if the tables are large.
My query in access works fine if i only use the below query with a select statement. As soon as it becomes an append query it produces an "invalid procedure call" error.
I have narrowed down the offending columns as being "Publ" and "PublLong". Both are long text strings. If I remove these two columns the query updates without an error.
Here is a sample data point found in the [Bezeichung] Field:
publications.bank.com/publ-dl-ch/pdf/WhatsUp_20181113_en.pdf
I checked the table that it is being inserted to and the data types are the same nor did i see any other setting that would block the insertion.
How can i get it to work?
INSERT INTO tbl_MatomoRaw ( DownloadDate, IntExt, Publ, PublLong,
PublDate, [Language], Download_Visits, PublMonth )
SELECT
Date() AS DownloadDate,
Left([Bezeichnung],InStr([Bezeichnung],".")-1) AS IntExt,
Nz(Mid([Bezeichnung],InStrRev([Bezeichnung],"/")+1,InStr([Bezeichnung],"_")-
InStrRev([Bezeichnung],"/")-1),"") AS Publ,
Mid([Bezeichnung],InStrRev([Bezeichnung],"/")+1,InStrRev([Bezeichnung],"_")-
InStrRev([Bezeichnung],"/")-1) AS PublLong,
Mid([Bezeichnung],InStr([Bezeichnung],"_")+1,8) AS PublDate,
Mid([Bezeichnung],Len([Bezeichnung])-5,2) AS [Language],
xlsx_Output.[Eindeutige Downloads] AS Download_Visits,
Mid([Bezeichnung],InStr([Bezeichnung],"_")+1,6) AS PublMonth
FROM xlsx_Output
WHERE
(((Nz(Mid([Bezeichnung],InStrRev([Bezeichnung],"/")+1,InStr([Bezeichnung],"_")-
InStrRev([Bezeichnung],"/")-1),"")) Not Like "#Func!"));
#Func! indicates one of your functions is causing an error.
Your query uses multiple functions that run into trouble when your input doesn't meet that format, pre-filter instead of filtering on an error, since you can't filter on an error when appending:
INSERT INTO tbl_MatomoRaw ( DownloadDate, IntExt, Publ, PublLong,
PublDate, [Language], Download_Visits, PublMonth )
SELECT
Date() AS DownloadDate,
Left([Bezeichnung],InStr([Bezeichnung],".")-1) AS IntExt,
Nz(Mid([Bezeichnung],InStrRev([Bezeichnung],"/")+1,InStr([Bezeichnung],"_")-
InStrRev([Bezeichnung],"/")-1),"") AS Publ,
Mid([Bezeichnung],InStrRev([Bezeichnung],"/")+1,InStrRev([Bezeichnung],"_")-
InStrRev([Bezeichnung],"/")-1) AS PublLong,
Mid([Bezeichnung],InStr([Bezeichnung],"_")+1,8) AS PublDate,
Mid([Bezeichnung],Len([Bezeichnung])-5,2) AS [Language],
[Eindeutige Downloads] AS Download_Visits,
Mid([Bezeichnung],InStr([Bezeichnung],"_")+1,6) AS PublMonth
FROM (SELECT * FROM xlsx_Output WHERE Len(Bezeichnung) > 5 AND Bezeichnung LIKE "*?.?*" AND Bezeichnung LIKE "*_????????*" AND Bezeichnung LIKE "*?\?*")
WHERE
(((Nz(Mid([Bezeichnung],InStrRev([Bezeichnung],"/")+1,InStr([Bezeichnung],"_")-
InStrRev([Bezeichnung],"/")-1),"")) Not Like "#Func!"));
Since I don't know exactly where the errors occur, I can't write up a proper filter to identify them, but judging by your query they should include a slash and a symbol after that slash, an underscore and at least 8 symbols after that underscore, and a dot with at least one symbol before and after the dot.
I have a following table:
EstimatedCurrentRevenue -- Revenue column value of yesterday
EstimatedPreviousRevenue --- Revenue column value of current day
crmId
OwnerId
PercentageChange.
I am querying two snapshots of the similarly structured data in Azure data lake and trying to query the percentage change in Revenue.
Following is my query i am trying to join on OpportunityId to get the difference between the revenue values:
#opportunityRevenueData = SELECT (((opty.EstimatedCurrentRevenue - optyPrevious.EstimatedPreviousRevenue)*100)/opty.EstimatedCurrentRevenue) AS PercentageRevenueChange, optyPrevious.EstimatedPreviousRevenue,
opty.EstimatedCurrentRevenue, opty.crmId, opty.OwnerId From #opportunityCurrentData AS opty JOIN #opportunityPreviousData AS optyPrevious on opty.OpportunityId == optyPrevious.OpportunityId;
But i get the following error:
E_CSC_USER_SYNTAXERROR: syntax error. Expected one of: AS EXCEPT FROM
GROUP HAVING INTERSECT OPTION ORDER OUTER UNION UNION WHERE ';' ')'
','
at token 'From', line 40
near the ###:
This expression is having the problem i know but not sure how to fix it.
(((opty.EstimatedCurrentRevenue - optyPrevious.EstimatedPreviousRevenue)*100)/opty.EstimatedCurrentRevenue)
Please help, i am completely new to U-sql
U-SQL is case-sensitive (as per here) with all SQL reserved words in UPPER CASE. So you should capitalise the FROM and ON keywords in your statement, like this:
#opportunityRevenueData =
SELECT (((opty.EstimatedCurrentRevenue - optyPrevious.EstimatedPreviousRevenue) * 100) / opty.EstimatedCurrentRevenue) AS PercentageRevenueChange,
optyPrevious.EstimatedPreviousRevenue,
opty.EstimatedCurrentRevenue,
opty.crmId,
opty.OwnerId
FROM #opportunityCurrentData AS opty
JOIN
#opportunityPreviousData AS optyPrevious
ON opty.OpportunityId == optyPrevious.OpportunityId;
Also, if you are completely new to U-SQL, you should consider working through some tutorials to establish the basics of the language, including case-sensitivity. Start at http://usql.io/.
This same crazy sounding error message can occur for (almost?) any USQL syntax error. The answer above was clearly correct for the provided code.
However since many folks will probably get to this page from a search for 'AS EXCEPT FROM GROUP HAVING INTERSECT OPTION ORDER OUTER UNION UNION WHERE', I'd say the best advice to handle these is look closely at the snippet of your code that the error message has marked with '###'.
For example I got to this page upon getting a syntax error for a long query and it turned out I didn't have a casing issue, but just a malformed query with parens around the wrong thing. Once I looked more closely at where in the snippet the ### symbol was, the error became clear.
I'm trying to make a query to search items structured as follows:
IssueCategory --* Issue (one to many)
using the following JPQL
select count(z) from IssueCategory z join z.issues x
where
lower(cast(function('lo_get', cast(x.diagnosis as integer)) as text)) like lower(concat('TEXT TO SEARCH', '%'))
where diagnosis is a Issue's String field with #Lob annotation, mapped as a text field in postgres:
CREATE TABLE issues (
...
diagnosis text,
...
)
this query produces the following query
select count(issuecateg0_.id) as col_0_0_
from issue_categories issuecateg0_
inner join issues issues1_ on issuecateg0_.id=issues1_.category_id
where lower(cast(lo_get(cast(issues1_.diagnosis as int4)) as text)) like lower(('TEXT TO SEARCH'||'%'))
Obviously in origin the "TEXT TO SEARCH" was passed as a parameter to the query.
The problem is: when I execute the JPQL query, it returns 0, but if I execute the generated query directly in postgres, I get 1.
Does anyone know of behaviours like this one?
I finally changed to the following conditions:
lower(function('encode', (function('lo_get', cast(x.diagnosis as integer))), 'escape') like lower(concat('TEXT TO SEARCH', '%'))
Please help as this is aquery with many parameters but when it said
" ((OrderProdDetails.DeliveryDate) Like IIf([Forms]![ReportCriteriaSelection]![NoDevDate]=-1,"*","")) " it should have included null values aswell but it is not if I am putting or Is null with this criteria then it is being applied for both conditions regardless of check box is checked or not. Please help getting the null values included when checkbox is checked.
Please have look on screenshots:
Query in design View
Criteria Selection Screen
Query:
SELECT OrderCustMain.OdrID, OrderCustMain.CustName, OrderCustMain.CustEmail,
OrderCustMain.OdrDate, OrderProdDetails.DeliveryDate, Date()-
[OrderCustMain]![OdrDate] AS [Days Past], OrderCustMain.OrderStatus,
OrderProdDetails.BrandName, OrderProdDetails.ModelName,
OrderProdDetails.Priority, SupplierDetails.SupEmail, OrderProdDetails.Status
FROM SupplierDetails INNER JOIN (OrderCustMain INNER JOIN OrderProdDetails
ON OrderCustMain.[OdrID] = OrderProdDetails.[OrdID]) ON
SupplierDetails.SupOrgName = OrderProdDetails.BrandName WHERE
(((OrderCustMain.OdrDate) Like IIf([Forms]![ReportCriteriaSelection]!
[NoStDate]=-1,"*","")) AND ((OrderProdDetails.DeliveryDate) Like
IIf([Forms]![ReportCriteriaSelection]![NoDevDate]=-1,"*","")) AND ((Date()-
[OrderCustMain]![OdrDate])>=[Forms]![ReportCriteriaSelection]![cboDaysPast])
AND ((OrderCustMain.OrderStatus) Like IIf(IsNull([Forms]!
[ReportCriteriaSelection]![RepCritOdrStatus]),"*",[Forms]!
[ReportCriteriaSelection]![RepCritOdrStatus])) AND
((OrderProdDetails.BrandName) Like IIf(IsNull([Forms]!
[ReportCriteriaSelection]![RepCritBrandName]),"*",[Forms]!
[ReportCriteriaSelection]![RepCritBrandName]))) OR
(((OrderCustMain.OdrDate)>=[Forms]![ReportCriteriaSelection]!
[RepCritOdrStDate] And (OrderCustMain.OdrDate)<=[Forms]!
[ReportCriteriaSelection]![RepCritOdrEndDate]) AND
((OrderProdDetails.DeliveryDate)>=[Forms]![ReportCriteriaSelection]!
[RepCritDlvryStDate] And (OrderProdDetails.DeliveryDate)<=[Forms]!
[ReportCriteriaSelection]![RepCritDlvryEndDate]) AND ((Date()-
[OrderCustMain]![OdrDate])>=[Forms]![ReportCriteriaSelection]![cboDaysPast])
AND ((OrderCustMain.OrderStatus) Like IIf(IsNull([Forms]!
[ReportCriteriaSelection]![RepCritOdrStatus]),"*",[Forms]!
[ReportCriteriaSelection]![RepCritOdrStatus])) AND
((OrderProdDetails.BrandName) Like IIf(IsNull([Forms]!
[ReportCriteriaSelection]![RepCritBrandName]),"*",[Forms]!
[ReportCriteriaSelection]![RepCritBrandName]))) OR (((OrderCustMain.OdrDate)
Like IIf([Forms]![ReportCriteriaSelection]![NoStDate]=-1,"*","")) AND
((OrderProdDetails.DeliveryDate)>=[Forms]![ReportCriteriaSelection]!
[RepCritDlvryStDate] And (OrderProdDetails.DeliveryDate)<=[Forms]!
[ReportCriteriaSelection]![RepCritDlvryEndDate]) AND ((Date()-
[OrderCustMain]![OdrDate])>=[Forms]![ReportCriteriaSelection]![cboDaysPast])
AND ((OrderCustMain.OrderStatus) Like IIf(IsNull([Forms]!
[ReportCriteriaSelection]![RepCritOdrStatus]),"*",[Forms]!
[ReportCriteriaSelection]![RepCritOdrStatus])) AND
((OrderProdDetails.BrandName) Like IIf(IsNull([Forms]!
[ReportCriteriaSelection]![RepCritBrandName]),"*",[Forms]!
[ReportCriteriaSelection]![RepCritBrandName]))) OR
(((OrderCustMain.OdrDate)>=[Forms]![ReportCriteriaSelection]!
[RepCritOdrStDate] And (OrderCustMain.OdrDate)<=[Forms]!
[ReportCriteriaSelection]![RepCritOdrEndDate]) AND
((OrderProdDetails.DeliveryDate) Like IIf([Forms]![ReportCriteriaSelection]!
[NoDevDate]=-1,"*","")) AND ((Date()-[OrderCustMain]![OdrDate])>=[Forms]!
[ReportCriteriaSelection]![cboDaysPast]) AND ((OrderCustMain.OrderStatus)
Like IIf(IsNull([Forms]![ReportCriteriaSelection]![RepCritOdrStatus]),"*",
[Forms]![ReportCriteriaSelection]![RepCritOdrStatus])) AND
((OrderProdDetails.BrandName) Like IIf(IsNull([Forms]!
[ReportCriteriaSelection]![RepCritBrandName]),"*",[Forms]!
[ReportCriteriaSelection]![RepCritBrandName]))) ORDER BY
OrderCustMain.OdrID, OrderProdDetails.Priority;
The primary source for your trouble is that dates are not strings, so "Date Like some-string" will either fail or return unintended results.
You'll have to redesign this from scratch. Exactly how depends on the context.
Would something like this help?
WHERE Nz(OrderCustMain.OdrDate, #1/1/1900#) >= IIf([Forms]![ReportCriteriaSelection]!
[NoStDate]=-1,Nz(OrderCustMain.OdrDate, #1/1/1900#),[Forms]![ReportCriteriaSelection]!
[RepCritOdrStDate])
It might simplify the code.