Database | Proc | Application | Created | Links |
sybsystemprocs | syb_aux_expandbitmap | 31 Aug 14 | Defects Dependencies |
1 2 /* Sccsid = "%Z% generic/sproc/src/%M% %I% %G%" */ 3 4 5 create procedure syb_aux_expandbitmap 6 @colcount smallint, /* no of columns in the table */ 7 @expandmap varbinary(133) output /* expanded column map with all 1's */ 8 as 9 10 declare @colleft smallint /* tracks number of columns left in the bit map */ 11 12 13 /* 14 ** if the number of columns are less than 8, it is a special case because 15 ** bit 0 is treated differently in the column bit map 16 */ 17 if (@colcount < 8) 18 begin 19 if (@colcount = 1) 20 select @expandmap = 0x02 21 else if (@colcount = 2) 22 select @expandmap = 0x06 23 else if (@colcount = 3) 24 select @expandmap = 0x0e 25 else if (@colcount = 4) 26 select @expandmap = 0x1e 27 else if (@colcount = 5) 28 select @expandmap = 0x3e 29 else if (@colcount = 6) 30 select @expandmap = 0x7e 31 else if (@colcount = 7) 32 select @expandmap = 0xfe 33 return 34 end 35 36 /* 37 ** column count was more than 7, thus set up the bit map for the first byte 38 ** and set the column left variable 39 */ 40 select @expandmap = 0xfe 41 select @colleft = @colcount - 7 42 43 /* 44 ** for chunk of 8 columns, set the bit map to all 1s for that byte 45 */ 46 while (@colleft >= 8) 47 begin 48 select @expandmap = @expandmap + 0xff 49 select @colleft = @colleft - 8 50 end 51 52 /* 53 ** if no column left, return 54 */ 55 if (@colleft = 0) 56 return 57 58 /* 59 ** now the number of left columns has to be between 1 and 7. So setup 60 ** the bit map for the last byte 61 */ 62 if (@colleft = 1) 63 select @expandmap = @expandmap + 0x01 64 else if (@colleft = 2) 65 select @expandmap = @expandmap + 0x03 66 else if (@colleft = 3) 67 select @expandmap = @expandmap + 0x07 68 else if (@colleft = 4) 69 select @expandmap = @expandmap + 0x0f 70 else if (@colleft = 5) 71 select @expandmap = @expandmap + 0x1f 72 else if (@colleft = 6) 73 select @expandmap = @expandmap + 0x3f 74 else if (@colleft = 7) 75 select @expandmap = @expandmap + 0x7f 76 77
exec sp_procxmode 'syb_aux_expandbitmap', 'AnyMode' go Grant Execute on syb_aux_expandbitmap to public go