关于在PB中往SQL SERVER2000中插入图片问题
一个关于在PB中往SQL SERVER2000中插入图片怎么操作:
表:t_image(no int ,b image),其中no为自增型。要求是往数据库中插入10万张相同图片(主要用于数据库性能分析)。
我是这样做的:
string filename,filelen,filenum
long looops,i,bytes
blob total,b
filename="e:\IMG_0182.JPG"//指定文件
filelen=filelength(filename)//计算文件长度
filenum=fileopen(filename,StreamMode!Read!)//读方式打开图片
if filelen>32765 then
if mod(filelen,32765)=0 then //一次只能读32765个字节
loops=filelen/32765 //读取次数
else
loops=filelen/32765 +1
else
loops=1
for i=1 to loops
bytes=fileread(filenum,b)
total=total+b
next
close(filename)
//插入记录
for i=1 to 100000
insert into t_image(b)
values(null);
next
//插入图片列
for i=1 to 100000
updateblob t_image set b=:total where no=:i;
next
commit;
这样做就是特别慢!运行17个小时才插入24000条!
有什么好的办法?我现在不想把图片放到数据库外的文件系统中。