O'Reilly logo

Learning Azure DocumentDB by Riccardo Becker

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Building user-defined functions

A UDF can be used to write custom business logic. UDFs can only be called from inside queries. A good example of a UDF inside our domain is produced by creating a function that calculates the price of a device including VAT.

UDFs can be created on the Azure portal, just like stored procedures and triggers. This UDF can be defined in the following way:

Building user-defined functions

If the VAT exceeds 100 percent, the function just returns the price (the VAT is then probably invalid or a mistake). Otherwise, it returns the original price including VAT. Testing this UDF involves a simple query.

The UDF can also be included inside WHERE clauses of our ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required