EXPORT SET Function SQL

The EXPORT_SET() function is not exactly straight-forward and for many programmers it is difficult to see its necessity, though it does have application in security and binary code extraction. It can also be used in porting data between applications. Suffice it to say it is all about finding the particular bits in a number and listing them in an array, albeit in reverse order. Here is the syntax:

EXPORT_SET(number, on, off ,separator ,number_of_bits)

The number parameter is the character to be tested. The "on" and "off" parameters are the characters that will be returned for every bit that is on or off (usually "y" and "n", or "1" and "0"). The separator is optional and is a comma by default. The number of bits is a maximum of 64 and will be 64 as a default.

Here is an example:

SELECT EXPORT_SET(35, 1, 0 , ',' , 10)

will result in: "1,1,0,0,0,1,0,0,0,0". Note again that these are listed backward from their actual order as a binary number. The last "1" in the array will be the first digit of a binary number and progress to the first digit of the array. Testing on a mySQL application reveals that letters will not be converted. To convert characters try:

SELECT EXPORT_SET(ASCII('F'), 1, 0, ',', 10)

which yields: "0,1,1,0,0,0,1,0,0,0".

< DATEDIFF function SQL | FOUND ROWS Function >


Send notes in disappearing ink!

Interesting Pages