如何实现100%的动态数据管道(三)[2]

[入库:2005年8月18日] [更新:2007年3月24日]

本文简介:选择自 daixf_csdn 的 blog

  ls_sourcesyntax+="column(type="+ls_pbdttype+",name=~""+ls_name+"~",dbtype=~""+ls_dbtype+"~","+ls_prikey+"nulls_allowed="+ls_nulls+")~r~n"
  if ls_default='' then
   if li_identity = 1 then
    ls_destsyntax+="column(type="+ls_pbdttype+",name=~""+ls_name+"~",dbtype=~""+ls_dbtype+"~","+ls_prikey+"nulls_allowed="+ls_nulls+",initial_value=~"exclude~")~r~n"
   else
    ls_destsyntax+="column(type="+ls_pbdttype+",name=~""+ls_name+"~",dbtype=~""+ls_dbtype+"~","+ls_prikey+"nulls_allowed="+ls_nulls+")~r~n"
   end if
  else
   if li_identity = 1 then
    ls_destsyntax+="column(type="+ls_pbdttype+",name=~""+ls_name+"~",dbtype=~""+ls_dbtype+"~","+ls_prikey+"nulls_allowed="+ls_nulls+",default_value=~""+ls_default+"~",initial_value=~"exclude~")~r~n"
   else
    ls_destsyntax+="column(type="+ls_pbdttype+",name=~""+ls_name+"~",dbtype=~""+ls_dbtype+"~","+ls_prikey+"nulls_allowed="+ls_nulls+",default_value=~""+ls_default+"~")~r~n"    
   end if
  end if
 next
else
 return ''
end if
ls_sourcesyntax+=')'
ls_destsyntax+=')'

//generate pipeline
//example:
//pipeline(source_connect=csfdata,destination_connect=csfdata,type=replace,commit=100,errors=100,keyname="bar_x")
if lb_key then
 ls_syntax+='pipeline(source_connect='+inv_attrib[li].is_sconnect+',destination_connect='+inv_attrib[li].is_dconnect+',type='+inv_attrib[li].is_ptype+',commit='+inv_attrib[li].is_pcommit+',errors='+inv_attrib[li].is_errors+',keyname="'+as_tablename+'_x")~r~n'
else
 ls_syntax+='pipeline(source_connect='+inv_attrib[li].is_sconnect+',destination_connect='+inv_attrib[li].is_dconnect+',type='+inv_attrib[li].is_ptype+',commit='+inv_attrib[li].is_pcommit+',errors='+inv_attrib[li].is_errors+')~r~n' 
end if

//generate source
//example:
//source(name="bar",column(type=char,name="customcode",dbtype="char(8)",key=yes,nulls_allowed=no)
ls_syntax+='source(name="'+inv_attrib[li].is_sname+'",'


ls_syntax+=ls_sourcesyntax


//generate retrieve
//example:
//retrieve(statement="select bar.customcode,bar.barcode,bar.itemcode,bar.metering,bar.packsize,bar.length,bar.width,bar.high,bar.vol,bar.weight,bar.newpackflagfrom bar")
ls_syntax+='retrieve(statement="'+inv_attrib[li].is_sqlsyntax+'")'


//generate destination
//example:
//destination(name="bar_copy",
//column(type=char,name="customcode",dbtype="char(8)",key=yes,nulls_allowed=no,initial_value="spaces")
ls_syntax+='destination(name="'+inv_attrib[li].is_dname+'",'
ls_syntax+=ls_destsyntax

return ls_syntax

这个函数的返回值就是构建完成的管道语法了.


其中:初始化的函数:of_input(inv_attrib[li])

是初始化,inv_attrib的函数,初始化的数据主要是用户需要输入的条件,比如管道的type,commit,errors,select语句.

需要说明一下,其中处理了几个特殊的情况的函数.

of_filterimg(lds_vdtcolumns):

过滤掉表中的image列,因为管道不支持image数据传输.

of_getpipedbtype(is_s_dbtype,ls_types):

根据表中列的类型得到管道中数据列的类型,因为他们不是总是一一对应的.

这个可以通过一个extend datawindowobject,并包含有初始数据来实现.

of_getpbdttype(is_s_dbtype,ls_types):
根据表中列的类型得到管道中列的类型,因为他们也不是总是一一对应的.
这个可以通过一个extend datawindowobject,并包含有初始数据来实现.

管道语法构建完成了,就可以执行管道传输了:


this.syntax=得到的语法

li_rc = this.start(srcsqlca,destsqlca,idw_errors)
 
if li_rc <> 1 then
 if not ib_silence then msg(ls_title,"对象传输失败: " + string(li_rc))
 of_addtransmsg(' 对象<'+is_currentobj+'>传输失败:' + string(li_rc) )
 return li_rc
 rollback ;
else
 commit;
end if

本文关键:如何实现100%的动态数据管道(三)
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top