Im wondering if there is a way of forcing a rollback and error if an SQL statement attempts to insert more than X rows into a table (its not an empty table, but a table used as storage for the results of another query). The value X is a varying value (on a per user basis), so probably cant use a constraint on the table - and the query is run from a Java application using a JDBC connection.
At the moment, we go ahead with the full insert and check after the insert completes how many rows were inserted and if it exceeds a certain limit, roll it back. I was just wondering if there is a better way as if the user has a limit of 1000 rows, but the other query returns millions, I'd rather fail as quickly as possible.
At the moment, we go ahead with the full insert and check after the insert completes how many rows were inserted and if it exceeds a certain limit, roll it back. I was just wondering if there is a better way as if the user has a limit of 1000 rows, but the other query returns millions, I'd rather fail as quickly as possible.