setsqlselect()的问题
有2个表
teacher
{
T# //教师号
tname //教师姓名
}
course
{
cname char(10) //课程名
T# char(10)(teacher的外码)
}
根据教师号查询教师姓名和课程。要求要有动态SQL语句
我的代码不知道哪里错了
string code
string old_select
string condition
string tmp1, tmp2, tmp3
tmp1 = trim(sle_1.text)
select tname
into :tmp2
from teacher
where trim(t#) =:tmp1;
select cname
into :tmp3
from course
where trim(t#) =:tmp1;
old_select = dw_1.getsqlselect()
condition = "where teacher.tname = '"+tmp2+"'"
condition += "and teacher.cname = '"+tmp3+"'"
condition = old_select + condition
dw_1.setsqlselect(condition)
dw_1.retrieve()
teacher
{
T# //教师号
tname //教师姓名
}
course
{
cname char(10) //课程名
T# char(10)(teacher的外码)
}
根据教师号查询教师姓名和课程。要求要有动态SQL语句
我的代码不知道哪里错了
string code
string old_select
string condition
string tmp1, tmp2, tmp3
tmp1 = trim(sle_1.text)
select tname
into :tmp2
from teacher
where trim(t#) =:tmp1;
select cname
into :tmp3
from course
where trim(t#) =:tmp1;
old_select = dw_1.getsqlselect()
condition = "where teacher.tname = '"+tmp2+"'"
condition += "and teacher.cname = '"+tmp3+"'"
condition = old_select + condition
dw_1.setsqlselect(condition)
dw_1.retrieve()
...全文
相关推荐
如何给字符型字段以自定义初始值
这对于调试和问题解决非常重要,特别是在数据库操作或者数据验证过程中。### 2.
PowerBuilder中动态SQL查询的实战技巧:从SetSQLSelect到Retrieve的完整流程
本文详细介绍了PowerBuilder中动态SQL查询的实战技巧,重点解析了SetSQLSelect方法的使用及其与Retrieve方法的完整流程。通过实际案例展示了如何动态构建SQL语句、优化查询性能以及防范SQL注入,帮助开发者高效处理数据窗口的动态查询需求。
PB中的六种查询技术new
**GetSqlSelect() 和 SetSqlSelect()**: 这些函数允许开发者获取或设置DataWindow的SQL选择语句。
关于pb的小例子
```powerbuilder dw_1.setsqlselect(ls_sql_new) ```至此,数据窗口将按照新的SQL语句重新加载数据,实现了动态过滤的功能。
PB数据窗口
- **GetSQLSelect/SetSQLSelect**:获取或设置数据窗口的SQL查询语句。 - **GroupCalc**:重新计算数据窗口的分组结果。


