I have this sparql query that I need to modify. I have the example instance, which has the exampleID 12345. For this case, if the :hasRelatedExample connection exists, the ?test variable will become 2. If the :hasRelatedExample connection doesn't exist from the example instance, the ?test variable doesn't get assigned the 1 value as it should. How could I fix this query to reflect the needed behavior?
PREFIX : <http://www.example.com#>
Select distinct ?test
where
{
?ex a :Example ;
:exampleID "12345" ;
:hasRelatedExample ?relatedExample .
BIND (IF(BOUND(?relatedExample),2,1) as ?test)
}
Related
IDENTIFIER
31-03-2022_13636075
01-04-2022_13650262
04-04-2022_13663174
05-04-2022_13672025
20220099001
11614491_R
10781198
00000000000
11283627_P
11614491_R
-1
how can i remove (only) the "XX-XX-XXXXX_" Part in certain values of a column in SSIS but WITHOUT affecting values that doesn't have this format? For example "21-05-2022_12345678" = "12345678" but the other values i don't want them affected. This are just examples of many rows from this column so i want only the ones that have this format to be affected.
SELECT REVERSE(substring(REVERSE('09-03-2022_13481330'),0,CHARINDEX('_',REVERSE('09-03-2022_13481330'),0)))
result
13481330
but this also affects others values.Also this is in ssms not ssis because i am not sure how to transform this expression in ssis code.
Update : Corrected code in SSIS goes as following:
(FINDSTRING(IDENTIFIER,"__-__-____[_]",1) == 1) ? SUBSTRING(IIDENTIFIER,12,LEN(IDENTIFIER) - 11) : IDENTIFIER
Do you have access to the SQL source? You can do this on the sql by using a LIKE and crafting a match pattern using the single char wildcard _ please see below example
DECLARE #Value VARCHAR(50) = '09-03-2022_13481330'
SELECT CASE WHEN #Value LIKE '__-__-____[_]%' THEN
SUBSTRING(#Value,12,LEN(#Value)-11) ELSE #Value END
Please see the Microsoft Documentation on LIKE and using single char wildcards
If you don't have access to the source SQL it gets a bit more tricky as you might need to use regex in a script task or maybe there is a expression you can apply
In Camunda (7.12) I can query processes by variable value:
runtimeService.createProcessInstanceQuery()
.variableValueEquals("someVar", "someValue")
.list();
I can even query processes for null-value variables:
runtimeService.createProcessInstanceQuery()
.variableValueEquals("someVar", null)
.list();
But how can I query processes that do not have variable someVar?
I am not sure why you wouldn't have figured that out, but if i am correct what i think you are looking for , then looks like its pretty simple . The ProcessInstanceQuery class has also a method called variableValueNotEquals(String name, Object value) , that allows you select the processes that do not match a variable . In the Camunda Java API Docs it is stated as :
variableValueNotEquals(String name, Object value)
Only select process instances which have a global variable with the given name, but with a different value than the passed value.
Documentation page for your reference:
https://docs.camunda.org/javadoc/camunda-bpm-platform/7.12/?org/camunda/bpm/engine/RuntimeService.html
So i believe you can simply do :
runtimeService.createProcessInstanceQuery()
.variableValueNotEquals("someVar", null)
.list();
Let me know if that helps you .
First, get list of ids of all process instances which have "someVar"
Second, get list of all process ids in camunda
Get ids, from second list, which are not contained in first list.
Here is Kotlin sample as it's shorter than Java code, but concept is the same:
val idsOfProcessesWithVar = runtimeService.createVariableInstanceQuery().variableName("someVar").list().map {
it.processInstanceId
}
val allProcessesIds = runtimeService.createProcessInstanceQuery().list().map { it.id }
allProcessesIds.minus(idsOfProcessesWithVar)
I am trying to write a xquery to get the Value for a specific name .Below is the request payload: i.e. if the Name ="ID" then get the
"Value" for that tag (i.e.1000000000.)If the Name="User" get the "Value" for that tag( ie."US").
<not:Items xmlns:v5="http://www.example.com"
xmlns:com="http://commom.com
xmlns:not="http://services.not.com"
xmlns:com1="http://common1.com">
<not:Array>
<com1:Item>
<v5:List>
<com:extensionsItem>
<com:Name>ID</com:Name>
<com:Value>1000000000</com:Value>
</com:extensionsItem>
<com:extensionsItem>
<com:Name>User</com:Name>
<com:Value>US</com:Value>
</com:extensionsItem>
</v5:List>
</com1:Item>
</not:Array>
</not:Items>
I tried the options below:
<ns2:ID>{fn:data($Items/not:Array/com1:Item/v5:List/com:extensionsItem[1]/com:Value)}<ID>
This statement works . But I cannot assure that ID will always come in first element in the array of List.So i want a statement that will work even if ID comes in any other
place in the array and I can retrieve the value.
Thanks in advance
I think you simply want to apply a predicate $Items/not:Array/com1:Item/v5:List/com:extensionsItem[com:Name = 'ID']/com:Value
I have following block of text retrieved from a log file
SELECT statement with ID: AE12400 SELECT /*+ ALL_ROWS */
T1.CONFLICT_ID, T1.LAST_UPD, T1.CREATED,
T1.LAST_UPD_BY, T1.CREATED_BY, T1.MODIFICATION_NUM,
T1.ROW_ID, T1.DFLT_LIC_FLG, T1.NAME, T1.VAL,
:1 FROM SIEBEL.S_LST_OF_VAL T1 WHERE
(T1.ACTIVE_FLG = :2 OR T1.ACTIVE_FLG IS NULL) AND (T1.TYPE = :3
AND T1.BU_ID IS NULL) ORDER BY T1.TYPE, T1.ORDER_BY, T1.VAL
Bind variable 1: ,,,SADMIN,00000002579c129c:0,,List Of Values
(Internal), Bind variable 2: Y Bind variable 3: ZERO_DTIME_MODE
***** SQL Statement Execute Time: 0.028 seconds ***** 3 row(s) retrieved by ID: AE0EF18
I need to get following tokens out of this block
Statement Id : AE12400
SQL_Query: SELECT /*+ ALL_ROWS */
T1.CONFLICT_ID, T1.LAST_UPD, T1.CREATED,
T1.LAST_UPD_BY, T1.CREATED_BY, T1.MODIFICATION_NUM,
T1.ROW_ID, T1.DFLT_LIC_FLG, T1.NAME, T1.VAL,
:1 FROM SIEBEL.S_LST_OF_VAL T1 WHERE
(T1.ACTIVE_FLG = :2 OR T1.ACTIVE_FLG IS NULL) AND (T1.TYPE = :3 AND T1.BU_ID IS NULL) ORDER BY T1.TYPE, T1.ORDER_BY, T1.VAL
Bind Variable : [",,,SADMIN,00000002579c129c:0,,List Of Values (Internal)","Y","ZERO_DTIME_MODE"]
SQL Time: 0.028
SQL Rows: 3
I have come up with following regular experssion so far to extract the statement, time & rows
SQL Rows : \s\d{1,4}\s
SQL Time: \d{1,3}\.\d{1,4}
Statement Id: (ID:)(\s\w+)
But I am not sure how to extract the SQL along with Bind Variables from the text.
Your current patterns are not precise as they may match another sub-strings that are not expected ones. Hence, I'll go to provide all needed expressions:
SQL rows:
\d{1,4}(?=\s*row)
Query running time:
(\d+(?:\.\d+)?)(?=\s*second)
Statement ID:
ID:\s*(\w+)
SQL statement (m: dot matches newlines):
(?m)ID:\s\w+\s(.*?)(?=Bind variable)
Bind variables:
(?m)Bind variable\s*\d+:\s*(.*?)(?=Bind variable|$)
For bind variables you should work with a matchAll() or findAll() similar method in your programming language. [Live demo, look at Match groups block]
These could be cleaned up; they're not very efficient as they are. But this should head you in the right direction.
SQL_Query: SELECT(?! statement with ID)[\W\w]*?(?=Bind variable \d)
If you're regexing a whole log with more than one of those text blocks, you'll have to get all the bind variables first, and then each one taken from that. Otherwise, you can skip that step.
Find bind vars: Bind variable \d+:[\W\w]*?(?=\s+\*\*\*\*\*)
Extract vars: Bind variable \d+:\s*([\W\w]*?)(?=Bind variable)
Also there could be problems if, for example, there is the text "Bind variable" within your SQL Query... But it would be difficult to get 100% on that, and it's unlikely there would be such things mixed into the other parts of the log, I'm guessing.
Trying to link DiskDrives found in Win32_DiskDrive with the data in MSStorageDriver_ATAPISmartData.
I've tried the following WQL statement, but it returned nothing each time. (I know that there is relevant data in the MSStorageDrive class)
ASSOCIATORS OF {Win32_DiskDrive.DeviceID=[value]} WHERE RESULTCLASS = MSStorageDriver_ATAPISmartData
Any ideas to match the data up?
The answer was this:
SELECT * FROM MSStorageDriver_ATAPISmartData WHERE InstanceName='[PNPDeviceID]'
Just make sure to double-escape any backslashses. So if the PNPDeviceID as found in Win32_DiskDrive was
IDE\DISKHITACHI_HDT725050VLA360_________________V56OA7EA\5&276E2DE5&0&1.0.0
what would be returned by getting the value will be
IDE\\DISKHITACHI_HDT725050VLA360_________________V56OA7EA\\5&276E2DE5&0&1.0.0
but what you need to send in the WHERE clause is
IDE\\\\DISKHITACHI_HDT725050VLA360_________________V56OA7EA\\\\5&276E2DE5&0&1.0.0
Silly, isn't it?
Oh, and from what I've gathered, you also need _0 on the end of the Device ID, so all together, you would send:
SELECT * FROM MSStorageDriver_ATAPISmartData WHERE InstanceName='IDE\\\\DISKHITACHI_HDT725050VLA360_________________V56OA7EA\\\\5&276E2DE5&0&1.0.0_0'