Even a boolean is 4 bytes (native navision). The corresponding SQL data type of a boolean is TINYINT, which is 1 byte. I guess this is the smallest you can go ... .
(At least if nobody has another suggestion? - I'm not sure, you see ...)
If using SQL option, you can Design a table in Enterprise Manager (for each company) and change the Data Type To bit.
By changing Navision boolean (SQL tinyint) to SQL bit you would probably loose nothing, since only 0 and 1 can be entered in Navision.
By changing Navision integer (SQL int) to SQL bit you will convert all nonzero values to 1.
In my opinion you should not change data type in SQL, since you can produce unpredictable situations. And changes to your system get messy. The size of storage place isn't probably a problem. If you want user to limit to 0 and 1, you can do it another way. (Using code OnValidate, using property ValuesAllowed...)
You probably want to view an integer value in binary representation. I don't know any command to do it. You have to create your function (e.g. BitSet, BitTest) and manipulate with integer value by dividing by 2.
You probably want to view an integer value in binary representation. I don't know any command to do it. You have to create your function (e.g. BitSet, BitTest) and manipulate with integer value by dividing by 2.
Yep that's it. So there's no way to to this that build it yourself...
ToBinary(liNumber : Integer) ltBinary : Text[50]
WHILE liNumber > 0 DO BEGIN
ltBinary := FORMAT(liNumber MOD 2) + ltBinary;
liNumber := liNumber DIV 2;
END;
This is the thing I build to check the bit values. Thanx to RobertMo for his beginning...
If somebody has question/comments let me know...
You can use it like this:
HasBit(18,2)
This will result in True
HasBit(5,2)
This will result in False
PROCEDURE HasBit(Source : Integer;Bit : Integer) : Boolean;
VAR
BitSource: Text[32];
BitBit: Text[32];
I: Integer;
BEGIN
IF Source < Bit THEN EXIT(FALSE);
// Create Bit list Source in Reversed order
WHILE Source > 0 DO BEGIN
BitSource := BitSource + FORMAT(Source MOD 2);
Source := Source DIV 2;
END;
// MESSAGE(BitSource);
// Create Bitlist for the bit value in Reversed order
WHILE Bit > 0 DO BEGIN
BitBit := BitBit + FORMAT(Bit MOD 2);// + BitBit;
Bit := Bit DIV 2;
END;
// MESSAGE(BitBit);
FOR I := 1 TO STRLEN(BitBit) DO
BEGIN
IF BitBit = '1' THEN EXIT(BitSource = '1');
END;
END;
Comments
(At least if nobody has another suggestion? - I'm not sure, you see ...)
You can convert to a boolean with:
Eric Wauters
MVP - Microsoft Dynamics NAV
My blog
By changing Navision boolean (SQL tinyint) to SQL bit you would probably loose nothing, since only 0 and 1 can be entered in Navision.
By changing Navision integer (SQL int) to SQL bit you will convert all nonzero values to 1.
In my opinion you should not change data type in SQL, since you can produce unpredictable situations. And changes to your system get messy. The size of storage place isn't probably a problem. If you want user to limit to 0 and 1, you can do it another way. (Using code OnValidate, using property ValuesAllowed...)
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
Yep that's it. So there's no way to to this that build it yourself...
Guido
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
If somebody has question/comments let me know...
You can use it like this:
HasBit(18,2)
This will result in True
HasBit(5,2)
This will result in False
PROCEDURE HasBit(Source : Integer;Bit : Integer) : Boolean;
VAR
BitSource: Text[32];
BitBit: Text[32];
I: Integer;
BEGIN
IF Source < Bit THEN EXIT(FALSE);
// Create Bit list Source in Reversed order
WHILE Source > 0 DO BEGIN
BitSource := BitSource + FORMAT(Source MOD 2);
Source := Source DIV 2;
END;
// MESSAGE(BitSource);
// Create Bitlist for the bit value in Reversed order
WHILE Bit > 0 DO BEGIN
BitBit := BitBit + FORMAT(Bit MOD 2);// + BitBit;
Bit := Bit DIV 2;
END;
// MESSAGE(BitBit);
FOR I := 1 TO STRLEN(BitBit) DO
BEGIN
IF BitBit = '1' THEN EXIT(BitSource = '1');
END;
END;