使用ORACLE数据库时的PB内嵌SQL问题,请各位大侠出手

felixx 2002-06-26 03:42:43
在使用ORACLE8i做后台数据库时,我写了一下简单script

string ls_name
string ls_password

ls_name = "tan"
select password into :ls_pwd from opr where oprname=:ls_name;

opr表中有相应的记录为
tan 123456

可是SQL执行的结果总是空。后经分析,是由于oracle不支持字符串用双引号的原因,即
select password into :ls_pwd from opr where oprname="tan";
不能成功,但是
select password into :ls_pwd from opr where oprname='tan';
可以得出正确结果。

问题时,如果我使用变量形式:ls_name,则始终无法成功,因为,PB执行以上sql时,还是将SQL变成了
select password into :ls_pwd from opr where oprname="tan";
执行。
我想PB内部一定有什么可以配置的地方,毕竟内嵌SQL是PB的特色,如果因为双引号的原因就无法在使用ORACLE时支持内嵌SQL,那实在是不应该,也不可能的,

请大侠执教。


...全文
24 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
liulee 2002-06-26
  • 打赏
  • 举报
回复
很奇怪,我这里是好的。

string ls_user_id = "000002",ls_user_name
select user_name into :ls_user_name from sys_user where row_id = :ls_user_id;
messagebox('asdf',ls_user_name + '~r'+sqlca.sqlerrtext)

返回结果了。

你的
select password into :ls_pwd from opr where oprname="tan";

本身就无法执行的,因此不存在错误问题。
所以,还是检查如下内容先:
1.有无权限?
2.返回的错误信息是什么?(如果有错误)
3.用户存在吗?
4.有无其他问题?

tiger7403 2002-06-26
  • 打赏
  • 举报
回复
用Dynamic SQL Format试试
wizardinred 2002-06-26
  • 打赏
  • 举报
回复
select password into :ls_pwd from opr where oprname="'"+:ls_name+"'";
试试吧.

752

社区成员

发帖
与我相关
我的任务
社区描述
PowerBuilder 数据库相关
社区管理员
  • 数据库相关社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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