***自己生成数据管道的语法出错,有那位高人有源程序

promark 2003-08-21 10:43:27
我在做数据管道的时候,自己生成她的语法,结果老是不能使用
那位有成功的经验,能把生成语法的源程序发给我,感激涕零!!!

email:mark200106@sohu.com
...全文
28 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
promark 2003-08-24
  • 打赏
  • 举报
回复
各位老兄,来看看下面的程序吧,本人经过n次尝试,马马虎虎的写了一个函数,是生成pipeline的语法的,不太完善,是两个Sybase数据库之间的转换,参考了别人的东东,在此对他们表示感谢
//函数定义
String fun_pipeline(String as_server,String as_client,String as_table,String as_type,Transaction atrans_server)
//函数体
String ls_syntax,ls_sel,ls_errors
String ls_pipeline1,ls_pipeline2,ls_pipeline3,ls_pipeline4
String ls_colname,ls_foxtype,ls_foxdbtype,ls_key
Int i,li_columncount
String ls_inital='spaces'

datastore lds_1
ls_sel="select * from "+as_table
lds_1=create datastore
lds_1.create(Sqlca.syntaxfromsql(ls_sel,"style(type=grid)",ls_errors))
if Len(ls_errors)>0 then return 'error'

//计算数据存储总的列数
li_columncount=integer(lds_1.object.datawindow.column.count)

//构造数据管道语法
ls_pipeline1="PIPELINE(source_connect="+as_server+",destination_connect="+as_client+",type="+as_type+",commit=100,errors=100,keyname="+'"'+as_table+'")'
ls_pipeline2="SOURCE(name=~""+as_table+"~","
ls_pipeline3="RETRIEVE(statement=~"pbselect(version(400) table(name=~~~""+as_table+"~~~")"
ls_pipeline4="DESTINATION(name=~""+as_table+"~","

//对总的列数做循环
for i=1 to li_columncount
//获取该列对应的数据库列的名称
ls_colname=string(lds_1.describe('#'+string(i)+".dbname"))
ls_colname=Mid(ls_colname,Pos(ls_colname,'.')+1)
//获取该列的数据类型
ls_foxdbtype=string(lds_1.describe('#'+string(i)+".coltype"))

//对不同类型进行不同的处理
choose case upper(left(ls_foxdbtype,3))
case "CHA"
ls_foxtype='char'
case 'NUM','DEC'
//从数据窗口中不能得到精度的数据,我也没有办法
Int li_prec,li_scale
SELECT prec,scale INTO :li_prec,:li_scale FROM syscolumns
WHERE name=:ls_colname AND id IN (SELECT id FROM sysobjects WHERE name=:as_table)
USING atrans_server;
ls_foxtype='decimal'
ls_foxdbtype='decimal('+String(li_prec)+','+String(li_scale)+')'
case 'DAT'
ls_foxtype='datetime'
end choose
//我把主键手工放在表中了,没有主键,管道不能用的
Int li_pk
SELECT Count(*) INTO :li_pk FROM SysPk WHERE TableName=:as_table AND ColumnName=:ls_colname Using atrans_server;
IF li_pk>0 THEN
ls_pipeline2+="COLUMN(type="+ls_foxtype+",name=~""+ls_colname+"~",dbtype=~""+ls_foxdbtype+"~",key=yes,nulls_allowed=no)"+"~r~n"
ls_pipeline3+="COLUMN(name=~~~""+as_table+"."+ls_colname+"~~~")"
ls_pipeline4+="COLUMN(type="+ls_foxtype+",name=~""+ls_colname+"~",dbtype=~""+ls_foxdbtype+"~",key=yes,nulls_allowed=no,initial_value=~""+ls_inital+"~")"+"~r~n"
ELSE
ls_pipeline2+="COLUMN(type="+ls_foxtype+",name=~""+ls_colname+"~",dbtype=~""+ls_foxdbtype+"~",nulls_allowed=no)"+"~r~n"
ls_pipeline3+="COLUMN(name=~~~""+as_table+"."+ls_colname+"~~~")"
ls_pipeline4+="COLUMN(type="+ls_foxtype+",name=~""+ls_colname+"~",dbtype=~""+ls_foxdbtype+"~",nulls_allowed=no,initial_value=~""+ls_inital+"~")"+"~r~n"
END IF
next

ls_pipeline2+=+")"
ls_pipeline3+=")~")"
ls_pipeline4+=+")"
ls_syntax=ls_pipeline1+"~r~n"+ls_pipeline2+"~r~n"+ls_pipeline3+"~r~n"+ls_pipeline4

RETURN ls_syntax
dancer 2003-08-24
  • 打赏
  • 举报
回复
你把pipeline export出去,看一下语法,照着写就行了
promark 2003-08-23
  • 打赏
  • 举报
回复
楼上的同志,哈哈,别着急,等一下一定给
刚刚收到,可惜你用的是pb8做的,我才使用pb6.5呢,比较老土
你的程序能够使用参数吗?就是生成能够产生带参数的语法
119119 2003-08-23
  • 打赏
  • 举报
回复
发了。送分吧。我要分。呵呵。
rogery 2003-08-23
  • 打赏
  • 举报
回复
一定要源程序吗?

为何不把需求写出来
polugen 2003-08-21
  • 打赏
  • 举报
回复
在www.pbdriver.com有
eastpond 2003-08-21
  • 打赏
  • 举报
回复
关注

1,072

社区成员

发帖
与我相关
我的任务
社区描述
PowerBuilder 相关问题讨论
社区管理员
  • 基础类社区
  • WorldMobile
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧