Skip to Content
SQL Bible, Second Edition
book

SQL Bible, Second Edition

by Alex Kriegel, Boris M. Trukhnov
April 2008
Intermediate to advanced
888 pages
19h 35m
English
Wiley
Content preview from SQL Bible, Second Edition

Chapter 10. SQL Functions

SQL functions exist to make your life easier, and — to some extent — alleviate the procedural deficiency of set-based SQL. While a query is busy retrieving some data for you, the functions used within that query are validating, converting, calculating, getting the system information, and much more.

Think of the SQL functions as tools designed to accomplish a single well-defined task — calculating a square root or converting lowercase letters into uppercase, for example. You invoke a function within an SQL query by its name (usually a single keyword), and it performs its action and returns a value for every row returned by the query. Some functions accept arguments and some do not, but what differentiates a function from every other executable module in an RDBMS is that it always returns a value.

We have mentioned before that SQL itself is not a procedural language (at least without SQL/PSM). It lacks procedural features such as flow control structures and loops, but using functions allows you to compensate for problems stemming from this deficiency.

While classifications of the SQL functions abound, all functions could be divided into two broad categories: deterministic functions and nondeterministic functions. Deterministic functions always return the same result as long as you pass in the same arguments; nondeterministic functions might return different results, even if they are called with exactly the same arguments. For example, the function ABS, which ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

SQL All-In-One For Dummies, 3rd Edition

SQL All-In-One For Dummies, 3rd Edition

Allen G. Taylor

Publisher Resources

ISBN: 9780470229064Purchase book