- 论坛徽章:
- 19
|
这是视频数据内容表Data上的存储函数,用来插入新行并且返回id- CREATE FUNCTION fun_Data(nValue char(100),dValue blob,sValue int,fValue int)
- RETURNS int
- BEGIN
- DECLARE bValue int;
- select count(*) into @Value from Data where name=nValue;
- if @Value<1 then
- insert into Data(name,data,size) values(nValue,dValue,sValue);
- end if;
- select id into bValue from Data where name=nValue;
- select count(*) into @Value from DataIndex inner join Data on Data.id=DataIndex.block_id where Data.name=nValue and DataIndex.file_id=fValue;
- if @Value<1 then
- insert DataIndex(file_id,block_id) values(fValue,bValue);
- end if;
- return bValue;
- END
复制代码 |
|