关于c++使用sql语句调用 mysql数据库中带参函数的方法

来源:互联网 发布:广告公司需要什么软件 编辑:程序博客网 时间:2024/06/11 17:30

在数据库中定义函数:类似下面这样 函数名为  myfun

begin
declare rguid    int default -1;
declare result    int default -1;
start transaction;

insert into mytable(a,b,c)
values (pa,pb,pc);

select row_count() into result;
 if result > 0 then
  update mytble2 set m=1 where m= pa;
 end if;

commit;
end

 

然后定义参数:  pa int,pb int,pc int

 

最后就是关键的sql调用了:

char strSql = "call myfun (123,123,123) ";

下面执行sql,  大功告成!!!   这个东西我找了整整一天,很多论坛和官方都说的很模糊很偏。