如题,两个Blob变量如何,如何经行二进制与操作。
我写了一个Function , 但是速度太慢。有没有其他办法?
以下是function:
CREATE FUNCTION `compare`(param1 varchar(50), param2 varchar(50) ) RETURNS varchar(20)
BEGIN
declare i int default 1;
declare length1 int;
declare length2 int;
declare temp1 int default 0;
declare temp2 int default 0;
declare temp int default 0;
declare result varchar(20) default '';
declare flag int default 0; #decide whether AND has something
set result = '';
set length1 = length(param1);
set length2 = length(param2);
if length1 < length2 then
set length1 = length2;
end if;
while i <= length1 do
set temp1 = ascii(substring(param1,i,1));
set temp2 = ascii(substring(param2,i,1));
set temp = temp1& temp2;
if temp>0 then
set flag =1 ;
end if;
set result = concat(result , char(temp));
set i = i+1;
end while;
if flag = 0 then
return null;
end if ;
return hex(result);
END
我写了一个Function , 但是速度太慢。有没有其他办法?
以下是function:
CREATE FUNCTION `compare`(param1 varchar(50), param2 varchar(50) ) RETURNS varchar(20)
BEGIN
declare i int default 1;
declare length1 int;
declare length2 int;
declare temp1 int default 0;
declare temp2 int default 0;
declare temp int default 0;
declare result varchar(20) default '';
declare flag int default 0; #decide whether AND has something
set result = '';
set length1 = length(param1);
set length2 = length(param2);
if length1 < length2 then
set length1 = length2;
end if;
while i <= length1 do
set temp1 = ascii(substring(param1,i,1));
set temp2 = ascii(substring(param2,i,1));
set temp = temp1& temp2;
if temp>0 then
set flag =1 ;
end if;
set result = concat(result , char(temp));
set i = i+1;
end while;
if flag = 0 then
return null;
end if ;
return hex(result);
END
