Cierto numero de filas en una .db
Publicado: 06 Nov 2013 01:01
Como crear un codigo que limite en el numero de filas de una .db ? 

Foro Especializado en Autoplay Media Studio y más...
https://amsspecialist.com/
if (tbConsulta.Rows > nMaxFiles) then
--Entonces haces el limitante.
--Podria ser un booleano negativo
end
nMaxFiles = 100;
q = "SELECT * FROM mitabla";
tbConsulta = SQLite.QueryToTable(db, q);
if (tbConsulta.Rows > nMax) then
bPermitido = false;
else
bPermitido = true;
end
if (bPermitido) then
--Ingresas datos
else
Dialog.Message("", "No hay mas registros");
end
Código: Seleccionar todo
"SELECT * FROM table_name LIMIT 100"
cupolimit = Input.GetText("CUPO")
sDatabaseFile = _SourceFolder .. "\\AutoPlay\\Docs\\".. cupolimit ..".db";
db = SQLite.Open(sDatabaseFile);
nLastError = Application.GetLastError();
if nLastError ~= SQLite.OK then
Dialog.Message("Error al abrir archivo", SQLite.GetLastErrorString());
end
SQLite.Query(db,"CREATE TABLE recargas(RecordID integer primary key, NOMBRE text, FECHA text)");
Page.Jump("CUPOS")
Input.SetText("CUPO", strpath1);
tabla = Label.GetText("CUPO")
nMaxFiles = 10;
q = "SELECT * FROM" .. tabla ..";
tbConsulta = SQLite.QueryToTable(db, q);
if (tbConsulta.Rows > nMax) then
bPermitido = false;
else
bPermitido = true;
end
function Escape (sSourceString)
sSourceString = String.Replace(sSourceString, "'", "''", false);
return sSourceString;
end
sNUMERO = Input.GetText("InputNUMERO");
sFOLIO = Input.GetText("InputFOLIO");
sSALDO = ComboBox.GetText("ComboBox_SALDO");
sVENDEDOR = Input.GetText("ASISTENTE");
if bNewRecord then
SQLite.Query(db, "insert into recargas values(NULL, '"..sNOMBRE.."', '"..sFECHA.."')");
nLastError = Application.GetLastError();
if nLastError ~= SQLite.OK then
Dialog.Message("Error: " .. nLastError, SQLite.GetLastErrorString());
end
else
SQLite.Query(db,"insert or replace into recargas values('".. nRecordID .."', '".. sNOMBRE.."', '"..sFECHA.."')");
nLastError = Application.GetLastError();
if nLastError ~= SQLite.OK then
Dialog.Message("Error: " .. nLastError, SQLite.GetLastErrorString());
end
end
if (bPermitido) then
--Ingresas datos
else
Dialog.Message("", "No hay mas registros");
end
SQLite.Close(db);
FECHA = Input.GetText("FECHA")
sDatabaseFile = _SourceFolder .. "\\AutoPlay\\Docs\\".. FECHA ..".db";
db = SQLite.Open(sDatabaseFile);
nLastError = Application.GetLastError();
if nLastError ~= SQLite.OK then
Dialog.Message("Error al abrir la base de datos", SQLite.GetLastErrorString());
end
SQLite.Query(db,"CREATE TABLE recargas(RecordID integer primary key, NUMERO numeric, VENDEDOR tex)");
tDatas=SQLite.QueryToTable(db,"SELECT COUNT(VENDEDOR) AS count FROM recargas");
nLastError = Application.GetLastError();
if nLastError ~= SQLite.OK then
Dialog.Message("Error :", SQLite.GetLastErrorString());
end
nRegistros = tonumber(tData.Data[1]["count"]);
if (nRegistros >= 10) then
Dialog.Message("Error", "No se pueden ingresar mas de 10 registros", MB_OK, MB_ICONSTOP);
Application.ExitScript();
end