You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Return a string such that for every bitsetin the value bits, you get an on string and for every unset bit, you get an off string.
440
+
The `EXPORT_SET()` function returns a string that consists of a specified number (`number_of_bits`) of `on`/`off`values, optionally separated by `separator`. These values are based on whether the corresponding bitin the `bits` argument is `1`, where the first value corresponds to the rightmost (lowest) bit of `bits`.
441
+
442
+
Syntax:
443
+
444
+
```sql
445
+
EXPORT_SET(bits, on, off, [separator[, number_of_bits]])
446
+
```
447
+
448
+
-`bits`: an integer representing the bit value.
449
+
-`on`: the string to be returned if the corresponding bit is `1`.
450
+
-`off`: the string to be returned if the corresponding bit is `0`.
451
+
-`separator` (optional): the separator character in the result string.
452
+
-`number_of_bits` (optional): the number of bits to be processed. If it is not set, `64` (the max size of bits) is used by default, which means that `bits` is treated as an unsigned 64-bitinteger.
453
+
454
+
Examples:
455
+
456
+
In the following example, `number_of_bits` is set to `5`, resulting in5values, separated by `|`. Because only 3 bits are given, the other bits are considered unset. Therefore, setting `number_of_bits` to either `101`or`00101` results in the same output.
457
+
458
+
```sql
459
+
SELECT EXPORT_SET(b'101',"ON",'off','|',5);
460
+
```
461
+
462
+
```sql
463
+
+-------------------------------------+
464
+
| EXPORT_SET(b'101',"ON",'off','|',5) |
465
+
+-------------------------------------+
466
+
| ON|off|ON|off|off |
467
+
+-------------------------------------+
468
+
1 row in set (0.00 sec)
469
+
```
470
+
471
+
In the following example, `bits` is set to `00001111`, `on` is set to `x`, and`off` is set to `_`. This causes the function to return `____` for the `0` bits and`xxxx` for the `1` bits. Therefore, when processing with the bits in`00001111`from right to left, the function returns `xxxx____`.
472
+
473
+
```sql
474
+
SELECT EXPORT_SET(b'00001111', 'x', '_', '', 8);
475
+
```
476
+
477
+
```sql
478
+
+------------------------------------------+
479
+
| EXPORT_SET(b'00001111', 'x', '_', '', 8) |
480
+
+------------------------------------------+
481
+
| xxxx____ |
482
+
+------------------------------------------+
483
+
1 row in set (0.00 sec)
484
+
```
485
+
486
+
In the following example, `bits` is set to `00001111`, `on` is set to `x`, and`off` is set to `_`. This causes the function to return `x` for each `1`bitand`_` for each `0`bit. Therefore, when processing with the bits in`01010101`from right to left, the function returns `x_x_x_x_`.
0 commit comments