当前位置: 代码迷 >> Sql Server >> C++中怎么写基于OTL存储过程的sql语句
  详细解决方案

C++中怎么写基于OTL存储过程的sql语句

热度:76   发布时间:2016-04-24 09:21:57.0
C++中如何写基于OTL存储过程的sql语句
已经把存储过程的代码写好了。
--带参数的存储过程
create proc insert_time @content varbinary(MAX),@depotid int--参数形式
as
begin
declare @idtemp int
select @idtemp=id from dbo.TIMERMONITORINFO where depotid=@depotid

if( @idtemp!=null)
begin
update dbo.TIMERMONITORINFO set content=@content where id=@idtemp
end
else
begin
insert into dbo.TIMERMONITORINFO(depotid,content) values(@depotid,@content)
print 1
end

end
功能是:查询TIMERMONITORINFO表有没有这个depotid的相关内容,如果有就更新,没有就插入。所以要传入depotid和
content 这两个变量(其中depotid是int  content 是varbinary)

就是不知道怎么写这个sql语句。
我写的是这个,运行报错。
sqlcmd=FMT_STR(boost::format("begin insert_time(:depotid<int,in>,:content<raw_long,in>) end;" ));
------解决思路----------------------
建议用ADO组件adodb.connection连接数据库,用adodb.command执行存储过程.
  相关解决方案