gsSQL = [
SELECT
Max(material.id_material) AS ultimo
FROM
material
]
EDT_Id_material=1
IF HExecuteSQLQuery(gdsQry,hQueryDefault,gsSQL) THEN
HReadFirst(gdsQry)
EDT_Id_material=gdsQry.ultimo+1
END
gsSQL = [
SELECT
Max(material.id_empresa_material) AS ultimo
FROM
material
where id_Empresa=%1
]
gsSQL = StringBuild(gsSQL,gnEmpresaCodigo)
EDT_Id_empresa_material=1
IF HExecuteSQLQuery(gdsQry,hQueryDefault,gsSQL) THEN
HReadFirst(gdsQry)
EDT_Id_empresa_material=gdsQry.ultimo+1
END