1. A computer-implemented method for extending a database transaction to include at least one user-defined operation that accesses a computer resource by means of a Transaction Protocol describing a two-phase commit application programming interface (API) that operates between a transaction manager and a resource manager coupled to said computer resource for transaction processing distributed over computer systems, said method comprising: registering said user-defined operation and Transaction Protocol Interfaces used by said user-defined operation with a database, and wherein said computer resource accessed by said user-defined operation is external to said database; executing said database transaction, wherein said database transaction includes both said user-defined operation and one or more database operations, wherein said database transaction is initiated with a begin transaction operation and ends with a commit or rollback operation; enabling said database to operate as said Transaction Manager by means of said Transaction Protocol, wherein said Transaction Manager manages distributed transactions by coordinating decisions about commit or rollback of pending transactions and coordinating failure recovery; accessing said resource manager by said database operating as said Transaction Manager; invoking said user-defined operation as part of said database transaction, wherein said user-defined operation is invoked by user-defined query code external to said database; recording with said database that said user-defined operation has been invoked to enable triggering said database to invoke said Transaction Protocol Interfaces during commit and rollback; executing said invoked and recorded user-defined operation while executing said database transaction; accessing said computer resource in response to executing said invoked and recorded user-defined operation by said resource manager, thereby extending said database transaction; in response to performing a commit of said database transaction, coordinating a commit of said computer resource accessed by said user-defined operation by said database invoking said Transaction Protocol Interfaces; and in response to performing a rollback of said database transaction, including said user-defined operation in said rollback by said database invoking said Transaction Protocol Interfaces to roll back said computer resource, wherein results of said database transaction that includes both said user-defined operation and said one or more database operations are atomic and are either completed with the commit or rolled back, wherein said user-defined operation accesses said computer resource that is external to said database.