sorry if the title is a bit confusing, honestly i did not know how to put it in plain words or what exactly to search for. I have an output from command line showing as per below.
Remote Copy System Information
Status: Started, Normal
Target Information
Name ID Type Status Options Policy
3PARSYSTEM1 2 IP ready - mirror_config
Link Information
Target Node Address Status Options
3PARSYSTEM1 0:3:1 xxx.xxx.xxx.xxx Up -
3PARSYSTEM1 1:3:1 xxx.xxx.xxx.xxx Up -
receive 0:3:1 receive Up -
receive 1:3:1 receive Up -
Group Information
Name Target Status Role Mode Options
GRP001Temp 3PARSYSTEM1 Started Primary Periodic Last-Sync 2018-11-04 00:08:09 MYT, Period 3h,over_per_alert
LocalVV ID RemoteVV ID SyncStatus LastSyncTime
LUN001-Temp 13304 LUN001-TempDR 16914 Synced 2018-11-04 00:08:10 MYT
Name Target Status Role Mode Options
GRP002-PHY01 3PARSYSTEM1 Started Primary Periodic Last-Sync 2018-11-04 01:17:54 MYT, Period 2h,auto_recover,over_per_alert
LocalVV ID RemoteVV ID SyncStatus LastSyncTime
LUN001-VVT2.12 120 LUN001-VVT2.12 210 Syncing (33%) 2018-11-03 23:51:04 MYT
Name Target Status Role Mode Options
GRP003-PHY02 3PARSYSTEM1 Started Primary Periodic Last-Sync 2018-11-04 01:27:12 MYT, Period 1h45m,auto_recover,over_per_alert
LocalVV ID RemoteVV ID SyncStatus LastSyncTime
LUN002-VVT2.14 130 LUN002-VVT2.14 207 Syncing (49%) 2018-11-03 23:59:27 MYT
Name Target Status Role Mode Options
GRP001-PRD-ORA 3PARSYSTEM1 Started Primary Periodic Last-Sync 2018-11-04 00:45:09 MYT, Period 2h,auto_recover,over_per_alert
LocalVV ID RemoteVV ID SyncStatus LastSyncTime
ORA-PROD-VG01.35 97 ORA-PROD-VG01.35 2451 Synced 2018-11-04 00:45:54 MYT
ORA-PROD-VG02.36 98 ORA-PROD-VG02.36 2452 Synced 2018-11-04 00:46:10 MYT
ORA-PROD-VG03.37 99 ORA-PROD-VG03.37 2453 Synced 2018-11-04 00:45:48 MYT
ORA-PROD-VG04.38 100 ORA-PROD-VG04.38 2454 Synced 2018-11-04 00:45:12 MYT
ORA-PROD-VG05.39 101 ORA-PROD-VG05.39 2455 Synced 2018-11-04 00:45:12 MYT
Name Target Status Role Mode Options
GRP001-PRD-SAP 3PARSYSTEM1 Started Primary Periodic Last-Sync 2018-11-04 01:24:25 MYT, Period 23m,auto_recover,over_per_alert
LocalVV ID RemoteVV ID SyncStatus LastSyncTime
SAP-PROD-APPS.4 80 SAP-PROD-APPS.4 1474 Synced 2018-11-04 01:24:28 MYT
SAP-PROD-LOCK.19 95 SAP-PROD-LOCK.19 1490 Synced 2018-11-04 01:24:25 MYT
SAP-PROD-SAPDT1.5 81 SAP-PROD-SAPDT1.5 1475 Synced 2018-11-04 01:25:16 MYT
SAP-PROD-SAPDT2.6 82 SAP-PROD-SAPDT2.6 1476 Synced 2018-11-04 01:25:05 MYT
SAP-PROD-SAPDT3.7 83 SAP-PROD-SAPDT3.7 1477 Synced 2018-11-04 01:25:07 MYT
SAP-PROD-SAPDT4.8 84 SAP-PROD-SAPDT4.8 1478 Synced 2018-11-04 01:25:41 MYT
SAP-PROD-SAPDT5.9 85 SAP-PROD-SAPDT5.9 1479 Synced 2018-11-04 01:25:35 MYT
SAP-PROD-SAPDT6.10 86 SAP-PROD-SAPDT6.10 1480 Synced 2018-11-04 01:25:56 MYT
Name Target Status Role Mode Options
GRP002-PRD-SAP 3PARSYSTEM1 Started Primary Periodic Last-Sync 2018-11-04 01:24:55 MYT, Period 23m,over_per_alert
LocalVV ID RemoteVV ID SyncStatus LastSyncTime
SAP-PROD-VG01.10 15 SAP-PROD-VG01.10 29769 Synced 2018-11-04 01:28:44 MYT
and i want to use powershell to capture the group information and so that i can get the groupname and run another command to loop through the group name. example output is as per below.
GRP001Temp
GRP002-PHY01
GRP003-PHY02
GRP001-PRD-ORA
GRP001-PRD-SAP
GRP002-PRD-SAP
Hope you can help me with my problem. Thank You in advance.
if every group is in the Role "Primary" one easy way might be the following statement:
get-content Demo.txt | where { $_ -match "Primary" } | % { $_.Split(" ")[0] }
It gets the lines which contain the word "Primary" and takes the first word (in your case the group name)
You can split the output by the linebreak and loop over the result.
If a line starts with Name, split the next line by a space and write the first element to the output.
Something like:
param($output)
$lines = $output -split [Environment]::NewLine
$name = $false
foreach($line in $lines) {
if($name) {
($line -split ' ')[0] | Write-Output
$name = $false
}
if($line.Startswith('Name')) {
$name = $true
}
}
Obviously you are after the first word following the Header
Name Target Status Role Mode Options
Not including the false header
Name ID Type Status Options Policy
the other answers aren't excluding.
So I'd split the file content with a RegEx by this Header into sections and skip the first one.
Then split each section into words separated with white space \s and get the first [0]
(Get-Content .\SO_53154266.txt -raw) -split "(?sm)^Name\s+Target.*?`r?`n" |
Select-Object -skip 1|
ForEach-Object { ($_ -split '\s')[0] }
Sample output:
GRP001Temp
GRP002-PHY01
GRP003-PHY02
GRP001-PRD-ORA
GRP001-PRD-SAP
GRP002-PRD-SAP
Related
How to check the execution state of “scheduledJob”?
How to check whether the function “scheduledJob” execute completely or not?
1. See how scheduleJob is defined
getScheduledJobs()
userId
jobId
jobDesc
startDate
endDate
frequency
scheduleTime
days
admin
daily000
Daily Job 1
2021.09.27
2021.09.27
'D'
12:03m 13:08m
admin
daily
Daily Job 1
2021.09.27
2021.09.27
'D'
12:53m 13:58m
View the completed scheduleJob
select * from getRecentJobs() where jobDesc like "%Daily%" order by startTime desc
node
userID
jobId
jobDesc
priority
parallelism
receivedTime
startTime
endTime
errorMsg
local8848
admin
daily000
Daily Job 1
8
64
2021.09.27T12:03:06.784
2021.09.27T12:03:06.785
2021.09.27T12:03:06.785
getJobMessage and getJobReturn to view the running log and return value of each job
The running log is saved in the jodId.msg file, and the return value of the scheduled job is saved in the jobId.object file. These files are saved in the directory /batchJobs
Using a simple example: count the number of events for each host name
... | timechart count BY host
> ... | timechart count BY host
>
> This search produces this results table:
>
> _time host1 host2 host3
>
> 2018-07-05 1038 27 7
> 2018-07-06 4981 111 35
> 2018-07-07 5123 99 45
> 2018-07-08 5016 112 22
What I want is to add a column to show the total events for that day and the percentage of each http status code.
I tried
... | timechart count BY host
| eval total= host1 + host2 + host3
| eval host1_percent = host1 / total
| eval host2_percent = host2 / total
| eval host3_percent = host3 / total
| table _time, host1_percent, host2_percent, host3_percent
This works most of the time, but I found out if for certain day, a host was offline (no record for a particular host), then the search doesn't work (return blank results), I have to remove that particular host from the "total = host1 + host2 + host3" to get it to work.
So my question is: is there a way to get the total number of record for for every day (row) without having to add them together, e.g. replace the "total = host1 + host2 + host3" with a count or sum, I tried couple of thing, none of them work.
It would help to know what you've tried so far so we don't suggest the same things.
Have you tried addtotals?
| timechart count by host
| addtotals row=true fieldname=total host*
So I have a table that has an ArticleID (GUID), RevisionNumber (integer), and StatusCode (text).
An Article can have any number of revisions but each time a new revision is created, the StatusCode of the previous revision should be "Revised" and the newest revision's StatusCode could be "Active" or "Draft" or "Canceled". However the data is messed up and I need to identify which records (out of 100's of thousands) do not have the correct status.
Sample data:
Article ID RevisionNumber StatusCode
========== ============== ==========
xx-xxxx-xx 7 Active
xx-xxxx-xx 6 Revised
xx-xxxx-xx 5 Active
xx-xxxx-xx 4 Draft
xx-xxxx-xx 3 Revised
xx-xxxx-xx 2 Active
xx-xxxx-xx 1 Revised
xx-xxxx-xx 0 Revised
xx-yyyy-yy 1 Active
xx-yyyy-yy 0 Active
In the above scenario, I would need to know that xx-xxxx-xx Revision 5, 4, and 2 are not the proper status and xx-yyyy-yy Revision 0 is incorrect. How could I get this information from a sql query using sql server 2012?
To identify any revisions that are not "Revised" if there is a higher number revision.
Then it seems just a matter of knowing what the latest revision is.
A MAX OVER can do that.
SELECT ArticleID, RevisionNumber, StatusCode
FROM
(
SELECT ArticleID, RevisionNumber, StatusCode
, MAX(RevisionNumber) OVER (PARTITION BY ArticleID) AS MaxRevisionNumber
FROM YourTable
) q
WHERE (RevisionNumber < MaxRevisionNumber AND StatusCode != 'Revised')
You can do this with a left join -- for each record we look for one with a greater revision -- like this:
SELECT *
FROM table_you_did_not_name base
LEFT JOIN table_you_did_not_name next ON base.ArticleID = next.ArticleID and base.revisionnumber = next.revisionnumber + 1
WHERE status <> 'Revised' and next.ArticleID is not null
I have been trying a few various methods to see if I can get this to work, but I haven't had any luck.
Here is what I am trying to accomplish.
Every day, there are cases that get closed. We are wanting to track cases that have been 're-opened' after having been already closed once, but there is nothing in the information provided that tells us this is a re-opened case. The only way to do this is to check to see if the Case ID and the Report Date and see if the there is a duplicate Case Id that exists and was closed prior to this report date. To complicate matters, here is some additional info:
1) A common situation is that a case is closed, re-opened and then closed again within the same day(sometimes multiple times). This should count as a re-open, each time it is done after the first instance, even if it's the same day ( I assume we would group by case ID?)
2) I run a 5 Day reporting window, so a case should NOT count as a re-open if for instance on 3/20/2019 the case was closed for the first time, and then re-opened at some point and closed again 3/26/2019 until 3/26/2019. On 3/20, 3/21, 3/22, and 3/25(report days skips weekends and holidays, this is already built in, do not need anything fo that) it should NOT be marked as a re-open because the case still only has one instance on or before the report date we are looking at. On 3/26 it would be marked as a re-open because it would then have been closed for a second time on or before the report date.
Here are some queries:
CREATE TABLE ResolvedCases(
Case_ID varchar(20),
Case_Closed_On datetime,
Report_Date date,
Is_ReOpened_Case VarChar(3) NULL
)
INSERT INTO ResolvedCases VALUES('US1236', '2019-02-16 12:30:45', '2/16/2019')
INSERT INTO ResolvedCases VALUES('US1238', '2019-02-28 15:30:45', '2/28/2019')
INSERT INTO ResolvedCases VALUES('US1234', '2019-03-19 12:30:45', '3/19/2019')
INSERT INTO ResolvedCases VALUES('US1234', '2019-03-19 15:30:45', '3/19/2019')
INSERT INTO ResolvedCases VALUES('US1235', '2019-03-20 9:30:45', '3/20/2019')
INSERT INTO ResolvedCases VALUES('US1235', '2019-03-23 12:40:45', '3/23/2019')
INSERT INTO ResolvedCases VALUES('US1236', '2019-03-20 12:30:45', '3/24/2019')
INSERT INTO ResolvedCases VALUES('US1237', '2019-03-25 12:30:45', '3/25/2019')
Expected Results(Only showing the cases with Report_Date between 3/20 and 3/26):
Case_ID Case_Closed_On Report_Date Is_ReOpened_Case
US1234 2019-03-19 12:30:45 3/19/2019 No (There is a duplicate case Id on 3/19 but it didn't happen until 3:30 PM---at 12:30PM this hadn't occurred yet so it was not a re-open at that time)
US1234 2019-03-19 15:30:45 3/19/2019 Yes
US1235 2019-03-20 9:30:45 3/20/2019 No (There is a duplicate case Id on 3/23 but on 3/20 this hadn't occurred yet so it was no a re-open on that date)
US1235 2019-03-23 12:40:45 3/23/2019 Yes
US1236 2019-03-20 12:30:45 3/24/2019 Yes (Because of the case closed on 2/16/2019 even though it doesn't show in this query)
US1237 2019-03-25 12:30:45 3/25/2019 No
Any help would be appreciated with this...
I have something that shows the count of the case ID which shows me all the duplicates for a given date range and have them grouped by Case_ID but I am not sure how to just mark each individual row as a re-open or not based on the requirements above...
For your immediate problem, you can use LAG to update your table with the flag you're looking for. (It returns a NULL if there's no preceding value, hence the logic in the CASE statement.)
UPDATE rc
SET rc.Is_ReOpened_Case = sq.Is_ReOpened_Case
FROM
#ResolvedCases AS rc
LEFT JOIN
(
SELECT
Case_ID
,Case_Closed_On
,Report_Date
,Is_ReOpened_Case =
CASE
WHEN LAG(Case_ID) OVER (PARTITION BY Case_ID ORDER BY Case_Closed_On) IS NOT NULL
THEN 'Yes'
ELSE 'No'
END
FROM #ResolvedCases
) AS sq
ON sq.Case_ID = rc.Case_ID
AND sq.Case_Closed_On = rc.Case_Closed_On
WHERE
COALESCE(rc.Is_ReOpened_Case,'') <> COALESCE(sq.Is_ReOpened_Case,'')
SELECT
rc.*
FROM #ResolvedCases AS rc
WHERE rc.Report_Date >= '20190319' AND rc.Report_Date < '20190326'
ORDER BY Case_ID, Case_Closed_On;
Results:
+---------+-------------------------+-------------+------------------+
| Case_ID | Case_Closed_On | Report_Date | Is_ReOpened_Case |
+---------+-------------------------+-------------+------------------+
| US1234 | 2019-03-19 12:30:45.000 | 2019-03-19 | No |
| US1234 | 2019-03-19 15:30:45.000 | 2019-03-19 | Yes |
| US1235 | 2019-03-20 09:30:45.000 | 2019-03-20 | No |
| US1235 | 2019-03-23 12:40:45.000 | 2019-03-23 | Yes |
| US1236 | 2019-03-20 12:30:45.000 | 2019-03-24 | Yes |
| US1237 | 2019-03-25 12:30:45.000 | 2019-03-25 | No |
+---------+-------------------------+-------------+------------------+
But thereafter you'll need to do something with the code that populates this table to maintain those values for future entries. That might require a two-step solution, but you'll have to decide after you review that code set. Maybe just run that UPDATE after the data load.
I have a file,
ID,DNS,R_D,R_A
1,123456,2014/11/17,10
2,987654,2016/05/20,30
3,434343,2017/08/01,20
that I'm trying to load to oracle using External Tables. I have to skip the header row and also load the date column.
This is my query:
DECLARE
FILENAME VARCHAR2(400);
BEGIN
FILENAME := 'actual_data.txt';
EXECUTE IMMEDIATE 'CREATE TABLE EXT_TMP (
ID NUMBER(25),
DNS VARCHAR2(20),
R_D DATE,
R_A NUMBER(25)
)
ORGANIZATION EXTERNAL (
TYPE ORACLE_LOADER
DEFAULT DIRECTORY USER_DIR
ACCESS PARAMETERS (
RECORDS DELIMITED BY NEWLINE
FIELDS TERMINATED BY '',''
MISSING FIELD VALUES ARE NULL
SKIP 1
(
"ID",
"DNS",
"R_D" date "dd-mon-yy",
"RECHARGE_AMOUNT"
)
)
LOCATION (''' || FILENAME || ''')
)
PARALLEL 5
REJECT LIMIT UNLIMITED';
END;
I get following exception:
ERROR at line 1:
ORA-29913: error in executing ODCIEXTTABLEOPEN callout
ORA-29400: data cartridge error
KUP-00554: error encountered while parsing access parameters
KUP-01005: syntax error: found "skip": expecting one of: "column, exit, (,
reject"
KUP-01007: at line 4 column 5
ORA-06512: at "SYS.ORACLE_LOADER", line 19
I'm using sqlplus.
Could some oracle veterans please help me out and tell me what I'm doing wrong here? I'm very new to oracle.
You don't want to create any kind of tables (including external ones) in PL/SQL; not that it is impossible, but it is opposite of the best practices.
Have a look at my attempt, based on information you provided - works OK.
SQL> alter session set nls_date_format = 'dd.mm.yyyy';
Session altered.
SQL> create table ext_tmp
2 (
3 id number,
4 dns varchar2(20),
5 r_d date,
6 r_a number
7 )
8 organization external
9 (
10 type oracle_loader
11 default directory kcdba_dpdir
12 access parameters
13 (
14 records delimited by newline
15 skip 1
16 fields terminated by ',' lrtrim
17 missing field values are null
18 (
19 id,
20 dns,
21 r_d date 'yyyy/mm/dd',
22 r_a
23 )
24 )
25 location ('actual_data.txt')
26 )
27 parallel 5
28 reject limit unlimited;
Table created.
SQL> select * from ext_tmp;
ID DNS R_D R_A
---------- -------------------- ---------- ----------
1 123456 17.11.2014 10
2 987654 20.05.2016 30
3 434343 01.08.2017 20
SQL>
In my case skip 1 didn't work even with placing it between records delimited by newline and fields terminated by ',' lrtrim until I used load when. Now skip 1 works with the following access parameters:
access parameters (
records delimited by newline
load when (someField != BLANK)
skip 1
fields terminated by '','' lrtrim
missing field values are null
reject rows with all null fields
)