cancel
Showing results for 
Search instead for 
Did you mean: 
Create Post
Level 8

Use of Between in SWQL - supported ?

Hello,

Just wondering if SWQL supports the "BETWEEN" operator as I can't find any information about it.

In more details, I am creating an Alert using SWQL scripts.

In some case we need to use the "Between" comparator to get the results based any data between two numbers.

The script is accepted by the Solarwinds check in the Alert but it is not running properly.

SELECT Nodes.Caption, Nodes.NodeID FROM Nodes

LEFT JOIN Traps t ON nodes.caption = t.hostname LEFT JOIN dbo.TrapVarbinds tv ON t.TrapID = tv.TrapID WHERE t.TrapID IN ( SELECT tv.TrapID FROM dbo.TrapVarbinds tv WHERE tv.OIDValue='raised(1)' ) AND t.Tag BETWEEN '16386' and '16990'

AND t.[DateTime] > DATEADD(MI,-6,GETDATE());

Could you tell me how to do a select on t.Tag that is comprised between 16386 and 16990 in the example above ?

Regards

Christine

0 Kudos
3 Replies
Level 14

I don't believe it is.

You can find a list of the all SWQL functions supported, on the Orion SDK page on Github: SWQL Functions · solarwinds/OrionSDK Wiki · GitHub

0 Kudos

Thanks for the information and you are right - I don' t see the Between function into the list.

Any idea on how to check if a value is comprised between two numbers ?

What should I use instead of :

t.Tag BETWEEN '16386' and '16990'?

ArrayContains([16386;16990],t.Tag) ?? Is this working ?

Any help is welcome

0 Kudos

Have you tried using ( t.TAG > 16386 AND t.Tag < 16990 ) ?

SWQL:

SELECT Nodes.Caption, Nodes.NodeID

FROM Orion.Nodes

LEFT JOIN Orion.Traps t ON nodes.caption = t.hostname

LEFT JOIN Orion.TrapVarbinds tv ON t.TrapID = tv.TrapID

WHERE t.TrapID IN ( SELECT tv.TrapID FROM Orion.TrapVarbinds tv WHERE tv.OIDValue='raised(1)' )

AND ( t.Tag > '16386' AND t.Tag < '16990' )

AND t.[DateTime] > AddMonth(-6,GETDATE());

I don't have any Tags assigned to my Traps table, so struggling to test this.