Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Restrict number of records

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Hi guys,

I have a program that inputs records into sybase.
I have a table here called orders.

now ,i require that there may be a maximum number of 10 entries in this table,not more.
Attempts to enter more entries are discarded.

how should i attempt this

Bye
 
I would probably do this by defining an insert trigger on the table which counted the records in the table. If there were 10, then don't allow the insert.

Greg.
 
Hi,

I also had faced this problem before...
but can anyone tell me how can i abort the insertion into the table through the trigger..means what code i have to write

Thanks
 
You would normally have some sort of 'if' condition in the trigger. If you don't want to do the insertion you would do

rollback tran
return

You may also (optionally) want to do a raiserror to generate a user error for the log file before the rollback.

Greg.
 
Hi Grega,

but i get the follwoing error
COMMIT/ROLLBACK NOT ALLOWED WITHIN ATOMIC TRANSACTIONS

how do i fix this

Bye
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top