Page 1 of 1
Limiting the number of entries in a table/column
Posted: Tue Oct 31, 2017 2:12 am
by quailcreek
Hi,
I need to be able to limit the number of entries a user could insert into a table. This would be based upon a parameter. If the parameter is true the user can generate an unlimited number of entries, if the parameter is false, I need to be able to limit the number of entries to <= 15.
Can this be done from within the SQLite database or should I just count the number of entries in the table and if it exceeds 15 just present the user with an answer box stating that they have exceeded the number of allowed entries? Thanks in advance.
Re: Limiting the number of entries in a table/column
Posted: Tue Oct 31, 2017 8:37 am
by AndyP
The answer is in Your question.
Sqlite supports the LImit clause, so just add
LIMIT 15 to the end of YouTube Sqlite call.
Re: Limiting the number of entries in a table/column
Posted: Tue Oct 31, 2017 9:03 am
by AndyP
Whoops.. just reread the question for inserting it would depend on how your users are inputing the data.
Are they using a form for each entry or entering all data in one go?
Re: Limiting the number of entries in a table/column
Posted: Tue Oct 31, 2017 7:14 pm
by quailcreek
Hi Andy,
they are entering all of the data at one time. It all goes into 1 table which of course has multiple columns. One column for each piece of input data. No cross reference, no foreign keys, etc.
Re: Limiting the number of entries in a table/column
Posted: Fri Dec 15, 2017 12:30 pm
by MaxV
quailcreek wrote: ↑Tue Oct 31, 2017 2:12 am
should I just count the number of entries in the table and if it exceeds 15 just present the user with an answer box stating that they have exceeded the number of allowed entries? Thanks in advance.
This is the simpler solution.
Re: Limiting the number of entries in a table/column
Posted: Fri Jan 12, 2018 3:12 pm
by teriibi
I m also looking for to use such limits for a project...Havent yet get to that part - though.
I figure out that such User account - input limit number- sould be set as an editable variable
(maybe in some extra table)
The reason not to hard code it in the App. is that you may want later on to upgrade/downgrade it for each user´s - by synchronizing the Variable with one stored online.... for whatever reason.
If its only hard-coded... U´re stuck.
unless you´re absolutely certain it ll never change...ever..ever...ever.. !
Make sense ?
Re: Limiting the number of entries in a table/column
Posted: Fri Jan 12, 2018 9:06 pm
by quailcreek
Here's what I put together. It could easily be set up to use variables.
Code: Select all
function getLastItemID
put "SELECT COUNT(ItemID) FROM MyItems" into tSQLRowCount
put revDataFromQuery(,,the uDatabaseID of this stack,tSQLRowCount) into theRowCount
return theRowCount
end getLastItemID
This part goes wherever you need it.
Code: Select all
put getLastItemID() into theRowCount
put the uProVersionPurchased of this stack into theVersion
if (theVersion = "false") AND (theRowCount >= 2) then
answer "Only 2 items can be created using the Free Version of this app" with "Yes" OR "Not Now" titled "Purchase the Pro Version"
if it is "Not Now" then
exit to top
else
go cd "Settings"
exit to top
end if
end if