Skip to end of metadata
Go to start of metadata

get or secure the next Lot Number from MESNumber Table

Step-by-step guide

use the following script (courtesy of Jason Coope)

def secureNextLotName():

	query = "SELECT Number FROM mesnumber where `key` = 'Lot'"
	mesDB = system.tag.getTagValue("[System]Client/System/DefaultDatabase")
	lotNum = int(system.db.runScalarPrepQuery(query,[],mesDB)) + 1
	query = "UPDATE mesnumber SET Number = ? where `key` = 'Lot'"
	system.db.runPrepUpdate(query, [lotNum], mesDB)
	lotName = str(lotNum)

	return lotName.zfill(10)
lotName = secureNextLotName()

print lotName