![]() | ![]() Products ![]() ![]() ![]() ![]() |
Home » Technical Support » ElevateDB Technical Support » Support Forums » ElevateDB SQL » View Thread |
Messages 1 to 5 of 5 total |
![]() |
Fri, Feb 22 2013 2:29 PM | Permanent Link |
Vitor Martins Pregitzer & Ca., Lda | How can I prevent insert more than one record in a table. At DataBase level.
Best regads Vitor Martins |
Sat, Feb 23 2013 4:32 AM | Permanent Link |
Roy Lambert NLH Associates ![]() | Vitor
>How can I prevent insert more than one record in a table. At DataBase level. Do you mean one record at a time, one record ever or.... Roy Lambert [Team Elevate] |
Sat, Feb 23 2013 1:41 PM | Permanent Link |
Barry | <How can I prevent insert more than one record in a table. At DataBase level.>
Victor, If you want a table to contain only 1 row at most, you will need to create a Before Insert trigger and see if the table is empty. If not, then raise an exception to disallow a new row from from being inserted. This allows the row to be deleted, or edited, but won't allow the table to have more than 1 row in it. Barry |
Sat, Feb 23 2013 2:37 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. ![]() | Vitor,
<< How can I prevent insert more than one record in a table. At DataBase level. >> Here's what it would look like as a trigger: CREATE TRIGGER "PreventInsert" BEFORE INSERT ON "SingleRow" BEGIN DECLARE TestCursor CURSOR FOR TestStatement; PREPARE TestStatement FROM 'TABLE SingleRow'; OPEN TestCursor; IF (ROWCOUNT(TestCursor) >= 1) THEN ABORT; END IF; END If you have any other questions, please let me know. Tim Young Elevate Software www.elevatesoft.com |
Mon, Feb 25 2013 3:08 PM | Permanent Link |
Vitor Martins Pregitzer & Ca., Lda | Works fine, thanks Best regards Vitor Martins "Tim Young [Elevate Software]" wrote: Vitor, << How can I prevent insert more than one record in a table. At DataBase level. >> Here's what it would look like as a trigger: CREATE TRIGGER "PreventInsert" BEFORE INSERT ON "SingleRow" BEGIN DECLARE TestCursor CURSOR FOR TestStatement; PREPARE TestStatement FROM 'TABLE SingleRow'; OPEN TestCursor; IF (ROWCOUNT(TestCursor) >= 1) THEN ABORT; END IF; END If you have any other questions, please let me know. Tim Young Elevate Software www.elevatesoft.com |
This web page was last updated on Thursday, July 10, 2025 at 01:54 PM | Privacy Policy![]() © 2025 Elevate Software, Inc. All Rights Reserved Questions or comments ? ![]() |