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

Claim 18:
19. A system for converting a cursor loop to a declarative structure query language (SQL) query that invokes a custom aggregate function, the system comprising:
one or more processors; and
one or more memory devices that store program code to be executed by the one or more processors, the program code comprising:
a precondition verifier instantiated in an SQL database server that:
receives the cursor loop for execution from an application executing in a 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 SQL database server 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;
a query rewrite engine instantiated in the SQL database server that automatically rewrites the select query to the declarative SQL query that invokes the automatically constructed custom aggregate function.