代码之家  ›  专栏  ›  技术社区  ›  gheist

具有可变参数的MySQL函数

  •  0
  • gheist  · 技术社区  · 7 年前

    我正在用Jaspersoft的iReport和icinga的数据创建一份监控报告。 在ireport中,我必须输入查询以获取所需的数据。现在,我想从该服务中获取(受监控对象的)名称和相应的可用性。为此,icinga提供了一个 function 它将object_id、开始日期和结束日期作为参数。例如:

    select icinga_availability(203, '2017-09-01 00:00:00','2017-09-30 23:59:59'), name1 from icinga_objects where object_id = '203';
    

    是否可以将变量/通配符或多个object\u id传递到函数中?我还没办法。

    谢谢你的帮助!

    1 回复  |  直到 7 年前
        1
  •  0
  •   Alex K    7 年前

    iReport不再受到官方支持,因此最好切换到Jaspersoft Studio。

    select icinga_availability( $P{obejct_id} , '2017-09-01 00:00:00','2017-09-30 23:59:59'), name1 from icinga_objects where object_id = to_char( $P{obejct_id} );
    

    使用整数参数:

    <parameter name="obejct_id" class="java.lang.Integer"/>
    

    因此,在运行报告时,可以输入要查看的object\u id。