Re: Conversion problem with cast function
I finally found a solution...(but it's not elegant...) i created another function to convert an integer value to binary(4) value.
CREATE DEFINER=`root`@`localhost` FUNCTION `ITOB`(pNum Integer) RETURNS varbinary(4)
BEGIN
Declare cResult char(32);
Declare bit1 Integer Default 0;
Declare bit2 Integer Default 0;
Declare bit3 Integer Default 0;
Declare bit4 Integer Default 0;
Set cResult = LPAD(BIN(pNum), 32, 0);
Set bit1 = Conv(Substring(cResult, 1, 8), 2, 10);
Set bit2 = Conv(Substring(cResult, 9, 8), 2, 10);
Set bit3 = Conv(Substring(cResult, 17, 8), 2, 10);
Set bit4 = Conv(Substring(cResult, 25, 8), 2, 10);
RETURN Cast(Concat(Char(bit1), Char(bit2), Char(bit3), Char(bit4)) As binary(4));
END
Thanks for all :)