Powerbuilder中直接使用SQL语句报错

2025-02-24 04:41:35
推荐回答(3个)
回答1:

1. time应能够不能加[]
2. lesson =:'' 应该去掉冒号:
3. v_count是数字,不能应该是 V_count =0

SELECT COUNT(1)
INTO :V_count
FROM db_schedule
where classroom =:ls_classroom and time =:ls_time and ( lesson ='' or lesson is null );

if V_count =0 then
messagebox('警告','教室已用!')
end if

回答2:

PB里面如果需要直接对数据库查询的话应先预定义SQL连接,指定你要对哪个数据库连接 ,例如定义连接为SQL1
则你的语句应为

SELECT COUNT(1)
INTO :V_count
FROM db_schedule
where classroom =: ls_classroom and [time] =: ls_time and ( lesson ='' or lesson is null ) using sql1;

if V_count ='0' then
messagebox('警告','教室已用!')
end if

回答3:

SELECT COUNT(1)
INTO :V_count
FROM db_schedule
where classroom =:ls_classroom and [time] =:ls_time and ( lesson ='' or lesson is null );

if V_count =0 then
messagebox('警告','教室已用!')
end if

这样写应该就可以