Hi Thwack Forum,
I am a SWQL newbie but have some T-SQL experience. I am trying to build a query to sit under NPM under a custom tab. The information I am extracting gets sent as a SNMP trap to NPM and I want to be able to read this information out using a query from the custom tab.
Individually my queries work fine and return the information I need, it is just when I combine these queries in a subquery format that the query then fails.
For example if I run this query: -
select TOP 1 I.trapid
from Orion.Traps I
where
I.Hostname = '10.0.6.140'
and I.TrapType = 'OPTIX-GLOBAL-PER-TRAPS-RTN-MIB:pmRslCur'
ORDER BY DateTime DESC
This returns a value such as '21371069'
If I then run this query off the back of the above query using the resultant value: -
select J.OIDValue as RSLCurrent
from Orion.TrapVarbinds J
where
J.TrapIndex = '3'
and
J.TrapID = '21371069'
I get the ultimate value that I want which is something like '565'
However, what I want to do is run the queries together in a subquery format. I have therefore constructed the following query from the above two queries: -
select J.OIDValue as RSLCurrent
from Orion.TrapVarbinds J
where
J.TrapIndex = '3'
and
J.TrapID =
(
select TOP 1 I.trapid
from Orion.Traps I
where
I.Hostname = '10.0.6.140'
and I.TrapType = 'OPTIX-GLOBAL-PER-TRAPS-RTN-MIB:pmRslCur'
ORDER BY DateTime DESC
)
However I get a Error: A query to the SolarWinds Information Service failed.
The two queries run fine when I run them separately, but when I try and combine them in the subquery format the query fails.
I can run this query direct on the MS SQL database in the following format and it runs the query and returns the value fine: -
select J.OIDValue as RSLCurrent
from TrapVarbinds J
where
J.TrapIndex = '3'
and
J.TrapID =
(
select TOP 1 I.trapid
from Traps I
where
I.Hostname = '10.0.6.140'
and I.TrapType = 'OPTIX-GLOBAL-PER-TRAPS-RTN-MIB:pmRslCur'
ORDER BY DateTime DESC
)
Therefore in the SWQL query format what am I doing wrong in relation to the subquery formatting?
Thanks,
James