Search code examples
databasestored-proceduresmigrationcockroachdbcockroachcloud

Alternative For Stored Procedures In cockroachDB


I was trying to migrate from Another RDBMS to cockroachDB but I think there is no such functionality like stored procedures in Cockroach. So what is the best alternative to make a stored procedure in cockroachDB ?


Solution

  • CockroachDB does not support stored procedures and the best alternative would depend on the problem you are trying to solve. A few examples:

    • If the stored procedure contains business logic, we'd recommend moving that logic to the application.
    • Simple stored procedures that contain a single DML statement should be moved into the application's DataAccess logic.
    • More complex stored procedures that contain explicit transactions or error code should be moved to the application-level transactions.

    EDIT: Stored Procedures as a Litmus Test, an article by Joe Emison, compares Stored Procedures to other solutions. It may be helpful in understanding alternatives.