Using the result of a query?

How can i get the result of a query and use it another?
I have a db table which represents a recipe. when the user adds a row to the table I would like to automatically increment the “step No”. when adding the new row.

I am using the following Query to get the number of steps:
GetStep = “Select Count(StepNo) From %s” % (RecipeName)
NextStep = system.db.runQuery(GetStep, ‘Recipes’)

The query itself works but NextStep does not contain the value, at least not in a useable form to perform the “insert Into” query like:
Query = “Insert Into template (StepNo) Values (%s)” % (NextStep)
#system.db.runUpdateQuery(Query, ‘Recipes’)

Thanks for any help.

I’m not sure which Database you are using, but the NextStep variable you are getting as a result from the system.db.runQuery() command is a dataset rather than a single value.

try system.db.runScalarQuery(). It returns a single value.

Thanks, I had a few other “stoppers” as well but that was the biggie.
i had tried that earlier, but the other problems kept me from pursuing it.