xTuple.com xTupleU Blog & News Customer Support

xtConnect send Metasql only if not empty

Is there a way to configure an xtConnect job to send the MetaSQL only if it returns data and not if the query returns no rows?

Thanks

I would be interested in this as well.

There isn’t a direct way to do this in the software, but you should be able to accomplish this by scheduling a function in the database instead of scheduling the metasql directly. pseudocode would be something like:

execute the query in the function
check number of rows returned is > 0
manually insert row in to xtbatch.batch to schedule the actual batch job to run (can get values from existing row in table, adjusting timestamp as necessary)

This works if the query in question doesn’t need the MetaSQL parser to run. You can still store it in the metasql table, and EXECUTE it in the function in order to check the count of the rows. More complex and dynamic queries would need some more on the fly query building and might get messy though…

I guess if you needed metasql. you could always have a simple check query in the function. and insert the actual metasql query into the xtbatch.batch table. It would probably work for everything that We would need.