Patent ID: 11941001
Assignee: MICROSOFT TECHNOLOGY LICENSING, LLC
Field: Computer technology (Electrical engineering)
Classification: CPC G | IPC G

Claim 9:
10. A system for converting a cursor loop to a declarative structure query language (SQL) query that invokes a custom aggregate function, the system comprising:
a processor; and
a memory device that stores program code to be executed by the processor, the program code comprising:
a precondition verifier instantiated in a client device that:
receives the cursor loop for execution from an application executing in the client device, wherein the received cursor loop comprises a select query and a loop body including a program fragment that can be evaluated iteratively over a result set one row at a time, and wherein the result set is a result of execution of the select query of the received cursor loop; and
verifies that the loop body of the received cursor loop does not include operations that modify a persistent state of a database;

a custom aggregate function constructor instantiated in the client device that automatically constructs the custom aggregate function based on semantics of the loop body of the received cursor loop according to a contract, wherein the automatically constructed custom aggregate function expresses the loop body of the received cursor loop; and
a query rewrite engine instantiated in the client device that:
automatically rewrites the select query to the declarative SQL query that invokes the automatically constructed custom aggregate function; and
transmits the declarative SQL query to an SQL database server for processing the declarative SQL query.