Limiting the number of entries in a table/column
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- Posts: 746
- Joined: Sun Feb 04, 2007 11:01 pm
- Location: McKenna, WA
Limiting the number of entries in a table/column
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.
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.
Tom
MacBook Pro OS Mojave 10.14
MacBook Pro OS Mojave 10.14
Re: Limiting the number of entries in a table/column
The answer is in Your question.
Sqlite supports the LImit clause, so just add
LIMIT 15 to the end of YouTube Sqlite call.
Sqlite supports the LImit clause, so just add
LIMIT 15 to the end of YouTube Sqlite call.
Andy Piddock
https://livecode1001.blogspot.com Built with LiveCode
https://github.com/AndyPiddock/TinyIDE Mini IDE alternative
https://github.com/AndyPiddock/Seth Editor color theming
http://livecodeshare.runrev.com/stack/897/ LiveCode-Multi-Search
https://livecode1001.blogspot.com Built with LiveCode
https://github.com/AndyPiddock/TinyIDE Mini IDE alternative
https://github.com/AndyPiddock/Seth Editor color theming
http://livecodeshare.runrev.com/stack/897/ LiveCode-Multi-Search
Re: Limiting the number of entries in a table/column
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?
Are they using a form for each entry or entering all data in one go?
Andy Piddock
https://livecode1001.blogspot.com Built with LiveCode
https://github.com/AndyPiddock/TinyIDE Mini IDE alternative
https://github.com/AndyPiddock/Seth Editor color theming
http://livecodeshare.runrev.com/stack/897/ LiveCode-Multi-Search
https://livecode1001.blogspot.com Built with LiveCode
https://github.com/AndyPiddock/TinyIDE Mini IDE alternative
https://github.com/AndyPiddock/Seth Editor color theming
http://livecodeshare.runrev.com/stack/897/ LiveCode-Multi-Search
-
- Posts: 746
- Joined: Sun Feb 04, 2007 11:01 pm
- Location: McKenna, WA
Re: Limiting the number of entries in a table/column
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.
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.
Tom
MacBook Pro OS Mojave 10.14
MacBook Pro OS Mojave 10.14
Re: Limiting the number of entries in a table/column
This is the simpler solution.quailcreek wrote: ↑Tue Oct 31, 2017 2:12 amshould 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.
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
Re: Limiting the number of entries in a table/column
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 ?
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 ?
-
- Posts: 746
- Joined: Sun Feb 04, 2007 11:01 pm
- Location: McKenna, WA
Re: Limiting the number of entries in a table/column
Here's what I put together. It could easily be set up to use variables.
This part goes wherever you need it.
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
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
Tom
MacBook Pro OS Mojave 10.14
MacBook Pro OS Mojave 10.14