pb执行sql文件

$PBExportHeader$uf_exesqlfile.srf
global type uf_exesqlfile from function_object
end type
forward prototypes
global function integer uf_exesqlfile (string astr_file, transaction atrs_sql)
end prototypes
global function integer uf_exesqlfile (string astr_file, transaction atrs_sql);int f
string ls_file
ls_file = astr_file
f = fileopen(ls_file,linemode!,read!,shared!)
if f < 0 then 
//messagebox('错误','打开文件'+ls_file+'错误!')
return 0
end if
string ls_line
string ls_sql
int li_rtn,li_exec,li_succ
li_rtn = fileread(f,ls_line)
li_exec = 0
li_succ = 0
do while li_rtn >=0 
ls_line = trim(ls_line)
if left(ls_line,2) = '--' or left(ls_line,2)='//' then
li_rtn = fileread(f,ls_line)
continue
end if
if right(ls_line,1) = ";" then
ls_line = left(ls_line,len(ls_line) - 1)
ls_sql = ls_sql + " " + ls_line
li_exec ++
execute immediate :ls_sql using atrs_sql;
if atrs_sql.sqlcode =0 then
li_succ ++
end if
ls_sql = ""
else
ls_sql = ls_sql + " " + ls_line
end if
li_rtn = fileread(f,ls_line)
loop
commit using atrs_sql;
fileclose(f)
if li_exec = li_succ  then
messagebox('信息','执行'+astr_file+'~r~n执行'+ string(li_exec)+",成功"+string(li_succ)+"。")
return li_succ
else
return - 1
end if
end function

转载于:https://www.cnblogs.com/kuailewangzi1212/archive/2011/08/04/2127629.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值