Search code examples
sqlzabbix

SQL - Heterogeneous queries error with zabbix item


In Zabbix, There is no way to SET ANSI_WARNINGS ON and SET ANSI_NULLS ON in the query section. At least isn't working. Is there any other way to set it?

I tried SET ANSI_WARNINGS ON; SET ANSI_NULLS ON; select * ... before the select statement and it did not work. I also tried GO SET ANSI_WARNINGS ON; ANSI_NULLS ON; select * ... GO but that did not work either - Zabbix reported syntax error.

Error: Heterogeneous queries require the ANSI_NULLS and ANSI_WARNINGS options to be set for the connection.

Here is my Query:

select sum(item_count) from (select  
coalesce(c.cnt, 0) as [item_count] 


from LINKED_DB_USER.[UserDB].[dbo].[User] as us LEFT JOIN LINKED_DB_USER.[USerDB].[dbo].[Account] as cs ON us.[user_id] = cs.[user_id]  

FULL OUTER JOIN 
(
 select [Account_ID], count(*) as cnt
from [OnlineUsers2].[dbo].[USER_NAME] where USER_ID in (select USER_ID from [OnlineUsers].[dbo].[Last_Login])
group by [Account_ID]
)  c on c.[Account_ID] = us.[Unique_ID] where cs.name = 'SOME_NAME') src;

Here is a screenshot of the item in zabbix.

Zabbix_ITEM


Solution

  • Unfortunately not, because SET ... is not supported by the underlying ODBC driver.

    You cannot use that in isql too. Example:

    SQL> SET ANSI_WARNINGS ON
    [S1000][Oracle][ODBC][Ora]ORA-00922: missing or invalid option
    
    [ISQL]ERROR: Could not SQLExecute
    

    Howerver, did you try using a stored procedure?