首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > PB >

pb中sql语言的select语句中的表名不能用变量解决方案

2012-02-12 
pb中sql语言的select语句中的表名不能用变量这个问题我在以前的帖子中 找到了,可是答案有些模糊string cur

pb中sql语言的select语句中的表名不能用变量
这个问题我在以前的帖子中 找到了,可是答案有些模糊
string cursor_class[13]
/////cursor_class[13],已经赋值,是13个表名
datetime ls_time2
string ls_sql
for i = 1 to 13
ls_sql="select max(datime) :into ls_time2 from " + cursor_class[i] + " USING sourcetrans" ;
execute immediate :ls_sql ;// USING sourcetrans;  
update b
set d_to=:ls_time2 using destinationtrans where d_table=:cursor_class[i];//这个变量放的是表名
commit;
next 


这个红色代码部分有问题,其中有一个变量ls_time2。不知道 怎么处理了

[解决办法]
看来楼主是一定要做了,那就帮写个

int i
string cursor_class[13]

datetime ls_time2
string ls_sql
for i = 1 to 13
DECLARE my_cursor DYNAMIC CURSOR FOR SQLSA ;
ls_sql="select max(datime) from " + cursor_class[i] 
PREPARE SQLSA FROM :ls_sql;
OPEN DYNAMIC my_cursor ;
FETCH my_cursor INTO :ls_time2 ;
CLOSE my_cursor ;

update b set d_to=:ls_time2 where d_table=:cursor_class[i] using destinationtrans;
commit;
next

热点排行