How to return the record count with RecipeQuery

How to return the record count with RecipeQuery
none 0.0 0
  • HMI Model: cmt-fhdx-820
  • EasyBuilder Pro Version: 6.10.01.510

Can i use the following sql statement within a macro?

“Select * FROM Code_Stage order by Code_Stage.No Desc Limit 1”

Hi @outbound6 ,

That SQL statement should work. Are you running into any errors within your project?

Thank you!

Sorry, yes i got it to work out…

Thanks!

Can i run a count statement something like this:

“Select Count(Code_Que1.Loaded) where Code_Que1.Loaded = o”

I’ve tried is and it’s not getting any results, is my syntax bad?

Hi @outbound6 ,

Within your SQL query could you add a FROM clause just like in your first query. It should look something like the following.

SELECT COUNT(*)
FROM Code_Que1
WHERE Loaded = 0;

Please let us know if the query runs into any errors.

This is inside a Macro, does that matter?

This is the code, not successful

Suggestions?

char sql_a[100] = "SELECT Count(*) FROM Code_Que1 WHERE Loaded = "
char lad[1] = “o”
StringCat(lad[0], sql_a[0])
result = RecipeQuery(sql_a[0], ldctn)

@outbound6,

Within macros, the record “count” is returned when you invoke the RecipeQuery function, there is no need to select the count in your statement.