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'
//对总的列数做循环
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