The WHILE
loop in SQL Server is a control-flow statement that allows us to repeatedly execute a block of code as long as a specified condition is true. It’s useful for iterative tasks and processing data in batches.
Author: Ian
A Quick Overview of the ERFC() Function in PostgreSQL
In PostgreSQL, erfc()
is a mathematical function that provides the mathematical complementary error function, without loss of precision for large inputs. It returns 1 - erf(x)
.
The erfc()
function was introduced in PostgreSQL 16, which was released on September 14th 2023.
How to Specify Sequence Options for IDENTITY Columns in PostgreSQL
When we create an IDENTITY
column in PostgreSQL, we have the option of specifying our own values for the sequence object that’s created.
This article provides an example of creating an IDENTITY
column with our own sequence options.
A Quick Intro to PostgreSQL’s ERF() Function
In PostgreSQL, erf()
is a mathematical function that provides the standard mathematical error function.
The erf()
function was introduced in PostgreSQL 16, which was released on September 14th 2023.
So PostgreSQL ARRAY_APPEND() Works but ARRAY_PREPEND() Doesn’t? Try this.
If you’re updating arrays in PostgreSQL and you’ve suddenly realised that some of the arrays aren’t being updated, it could be due to the following.
If you’ve been using the array_append()
function and the array_prepend()
function, you may have found that one function works but the other doesn’t. For example array_append()
works but array_prepend()
doesn’t, or vice-versa.
How REGEXP_REPLACE() Works in PostgreSQL
In PostgreSQL, we can use the regexp_replace()
function to replace a substring within a given string, based on a given POSIX regular expression. We can specify that all matches are replaced or just the first match.
We pass the string as the first argument, the pattern as the second, and the replacement text as the third argument. We also have the option of specifying the start position as the fourth argument, and we can specify a flag to determine how the function behaves.
Continue readingQuick Intro to the event_scheduler System Variable in MySQL
In MySQL, the event_scheduler
system variable is used to start and stop the Event Scheduler, as well as enable or disable it.
At runtime we can set the value to ON
or OFF
, and we can check the current value of the variable. We can also disable the Event Scheduler at server startup, but we can’t do this at runtime. However, we can still check the event_scheduler
variable to see whether it’s enabled or disabled.
Fix “date/time field value out of range” in PostgreSQL
If you’re getting an error that reads ‘date/time field value out of range‘ in PostgreSQL while using a function such as date_add()
, date_subtract()
, or date_trunc()
, it’s probably because the date value you’re passing to the function is an invalid date.
It’s possible that you’ve got the month and day in the wrong order.
To fix this issue, be sure that you pass a valid date. It may be that all you need to do is switch the day and the month around. Or it could be that you need to change your datestyle
setting.
Boost Your Data Analysis with These SQL Rank Functions
Most SQL databases have a handful of “ranking” functions that allow us to rank data. By “handful”, I mean there’s a common set of around six SQL rank functions that most of the major RDBMSs appear to support.
SQL rank functions allow us to assign ranks or row numbers to result sets.
Continue readingHow the CHR() Function Works in PostgreSQL
In PostgreSQL, we can use the chr()
function to return a character based on its code.
The code is provided as an integer argument, and the function returns the character that the code represents. When using UTF8 encoding the argument is treated as a Unicode code point, otherwise it must designate an ASCII character.
Continue reading