/* * Licensed Materials - Property of HCL * * IBM Informix DataBlade Module * (C) Copyright International Business Machines Corporation 2002. * (c) Copyright HCL Technologies Ltd. 2017. All Rights Reserved. * * COPYRIGHT LICENSE: * This information contains sample application programs in source language, * which illustrate programming techniques on various operating platforms. * You may copy, modify, and distribute these sample programs in any form * without payment to IBM, for the purposes of developing, using, marketing * or distributing application programs conforming to the application * programming interface for the operating platform for which the sample * programs are written. These examples have not been thoroughly tested under * all conditions. IBM, therefore, cannot guarantee or imply reliability, * serviceability, or function of these programs. You may copy, modify, and * distribute these sample programs in any form without payment to IBM for * the purposes of developing, using, marketing, or distributing application * programs conforming to IBM's application programming interfaces. * Each copy or any portion of these sample programs or any derivative work, * must include a copyright notice as follows: * © (your company name) (year). Portions of this code are derived from * IBM Corp. Sample Programs. © Copyright IBM Corp. (enter the year or * years). All rights reserved. * */ #include "tseries.h" /* * Example of counting non null elements */ mi_integer nelems(ts_timeseries *ts, MI_FPARAM *fParam) { ts_tsdesc *tsdesc; ts_tscan *tsscan; ts_tselem elem; mi_integer cnt; mi_integer ret; MI_CONNECTION *conn; conn = mi_open(NULL, NULL, NULL); /* open the source timeseries */ cnt = 0; tsdesc = ts_open(conn, ts, mi_fp_argtype(fParam, 0), 0); /* scan the entire timeseries */ tsscan = ts_begin_scan(tsdesc, 0, NULL, NULL); while ((ret = ts_next(tsscan, &elem)) != TS_SCAN_EOS) if (ret != TS_SCAN_NULL) /* don't count nulls */ cnt++; /* clean up */ ts_end_scan(tsscan); ts_close(tsdesc); return(cnt); }