Splunk count ORA error group by - splunk

I am new to Splunk, I want to implement below however stuck there:
I could get results as below format:
ORA-01033: ORACLE initialization or shutdown in progress
ORA-XXXXX: ....
What I want is to see the count value for each ORA error. Can anybody help me?

You probably want to create a field extraction. A regular expression for your field might look like this ^ORA-\d+. When you got the field you can simply group and count by it:
* | stats count by <your-new-field>

Related

Invalid Position in SQL WHERE Clause

I have a query I am writing that examines an ID field and derives an ID number from that column based on several criteria. Now that I have its logic written, I want to run the query on each criteria to see if the logic is working. So, the last part of my query for doing so is as follows:
FROM TABLE1
WHERE SOURCE_SYSTEM_NM = 'XYZ' AND ((STRLEFT(SOURCE_ARRANGEMENT_ID,4)) NOT IN ('23CC','21CC'))
LIMIT 10000
Essentially what I am trying to do here is tell it to return to me only items with SOURCE_SYSTEM_NM equal to 'XYZ', while eliminating any with a SOURCE_ARRANGEMENT_ID not having the first 4 characters equal to '21CC' or '23CC'. I have a third criteria I want to filter on as well, which is that the first three characters must be '0CC'.
My problem when I run this is I get back an "Invalid Position" error. I removed one of the strings from the criteria, and it works. So, I decided to add the second in its own 'NOT IN...' clause with an AND between them, but that resulted in the same error.
If I had to guess, the NOT IN ('21CC','23CC') puts an AND between them and I think that must be the root of my issue. The criteria in my CASE statement derives the ID number with the following:
WHEN (M_CRF_CU_PRODUCT_ARRANGEMENT.SOURCE_SYSTEM_NM) IN ('XYZ') AND STRLEFT(SOURCE_ARRANGEMENT_ID, 4) IN ('23CC','21CC') THEN STRRIGHT(SOURCE_ARRANGEMENT_ID, LENGTH(SOURCE_ARRANGEMENT_ID)-4)
WHEN (M_CRF_CU_PRODUCT_ARRANGEMENT.SOURCE_SYSTEM_NM) IN ('XYZ') AND STRLEFT(SOURCE_ARRANGEMENT_ID, 3) IN ('0CC') THEN STRRIGHT(SOURCE_ARRANGEMENT_ID, LENGTH(SOURCE_ARRANGEMENT_ID)-3)
WHEN (M_CRF_CU_PRODUCT_ARRANGEMENT.SOURCE_SYSTEM_NM) IN ('XYZ') AND (STRLEFT(SOURCE_ARRANGEMENT_ID, 4) NOT IN ('23CC','21CC') OR STRLEFT(SOURCE_ARRANGEMENT_ID, 3) NOT IN ('0CC')) THEN (SOURCE_ARRANGEMENT_ID)
So with that, I am just trying to check each criteria to make sure the ID derived/created is correct. I need to filter down to get results for that last WHEN statement above, but I keep getting that "Invalid Position" in my WHERE statement at the end. I am using Aginity to run this query and it's running against an IBM Netezza database. Thanks in advance!
I figured out what the issue was on this - when performing
STRRIGHT(SOURCE_ARRANGEMENT_ID, LENGTH(SOURCE_ARRANGEMENT_ID)-4)
There are some of those Arrangement IDs that do not have 4 characters, thus I was getting an "Invalid Position". I fixed this by updating this query to use substring() instead:
SUBSTRING(SOURCE_ARRANGEMENT_ID,5,LENGTH(SOURCE_ARRANGEMENT_ID))
This fixed my issue. Just wanted to post an answer in case others have this issue. It s not Netezza specific, this will react this way with any SQL variant.

MS Access Having Clause

Alright so I understand the point of the HAVING clause. I am having an issue and I am wondering if I can solve this the way I want to.
I want to execute one query using ADODB.Recordset and then use the Filter function to sift through the data set.
The problem is the query at the moment which looks like this:
SELECT tblMT.Folder, tblMT.MTDATE, tblMT.Cust, Sum(tblMT.Hours)
FROM tblMT
GROUP BY tblMT.Folder, tblMT.MTDATE, tblMT.Cust
HAVING tblMT.Cust LIKE "TEST*" AND Min(tblMT.MTDATE)>=Date()-30 AND MAX(tblMT.MTDATE)<=Date()
ORDER BY tblMT.TheDATE DESC;
So the above works as expected.... however I want to be able to use the tblMT.Cust as the filter without having to keep re querying the database. If I remove it I get a:
Data type mismatch in criteria expression.
Is what I am trying to do possible? If someone can point me in the right direction here would be great.
Ok... the type mismatch is caused because either tblmt.mtdate isn't a date field or tblmt.hours isn't a number field AND you have data that either isn't a date or isn't a number when the customer isn't like 'TEST*'. Or, for some customers, you have a NULL in mt.date and null can't be compared with >=. you'd still get the error if you said where tblMt.cust not like "TEST*" too.
Problem is likely with the data or your expectation and you need to handle it.
What data types are tblMT.hours and tblMt.MtDate?

Get Full Executed Query in Postgresql

Halo,
first, i say thank you for helping me solve my problem before.
I'm really newbie using Postgresql.
now i have new problem,
i do select statement like this one :
select * from company where id=10;
when i see the query in pg_stat_statements, i just get the query like this :
select * from company where id=?;
from the result the value of id is missing,
how i can get the complete query without missing the value??
Thank you :)
Alternatively you could set log_min_duration to 0 which will lead Postgres to log every statement.
Pg_stat_statements is meant to be for stats and these are aggregated, if every lookup value would be in there the stats would be useless because it would be hard to group.
If you want to understand a query just run it with explain analyze and you will get the query plan.

Access SQL Query using BETWEEN Statement and dates from a form

I'm probably missing something basic here, but I can't for the life of me get this working.
I have a database that is tracking when certain projects are completed, and I want to be able to show in a list the completed projects between a date range.
The date range to check between is set by the user on a form.
I have built a query in Access:
SELECT Logs.Completed
FROM Logs
WHERE Logs.Completed BETWEEN Forms!UIBrowseCompleted!Text53 AND Forms!UIBrowseCompleted!Text55
ORDER BY Logs.Completed;
I have got the dates formatted in the text box so they are in #MM/DD/YYYY# format (I have manually put these dates direct in the query and this works) but when I run the query I get the following error:
This expression is typed incorrectly, or it is too complex to be evaluated. For example, a numeric expression may contain too many complicated elements. Try simplifying the expression by assigning parts of the expression to variables.
I have tried modifying the query to take the # out of the text fields in the form, and including ' around the Forms!UIBrowseCompleted!Text53 but I've still not got any joy from it.
has anyone had this issue before, or can anyone point me in the right direction.
Thanks
Do you want MS Access query or SQL query?
If you want MS Access query then you can try with following
SELECT Logs.Completed
FROM Logs
WHERE Logs.Completed >= Forms!UIBrowseCompleted!Text53 AND Logs.Completed <= Forms!UIBrowseCompleted!Text55
ORDER BY Logs.Completed;
between query will take time normally we use >= and <= to check date range
like
>= Forms!UIBrowseCompleted!Text53 AND Logs.Completed <= Forms!UIBrowseCompleted

Change data greater than a given date to NULL in one column. Getting key error

I have a column filled with dates, some of which are duplicates, and I want to change all the ones greater than 2012-05-28 to NULL. Here is the statement I'm using:
UPDATE my_data SET date_firstnewtumor=NULL
WHERE date_firstnewtumor>2012-05-28;
However, MySQL Workbench is giving me this error message: "...you tried to update a table without a WHERE that uses a key column."
I then tried the above code in MySQL Command Line Client and it changed the entire column date_firstnewtumor to NULL.
I've looked at examples of code online and I could swear their WHERE statement was similar to mine. What am I doing wrong?
Thank you for your advice!
I think you'll just want to specify the date literal correctly:
WHERE date_firstnewtumor > '2012-05-28';
Or simply:
WHERE date_firstnewtumor > 20120528;