有一表 T_language,有Id|China|English等列,分别为number、varchar(128)、varchar(128)
Id China English
1 中国 china
2 朋友 friend
3 人民 people
4 书 book
.................
现在一个参数化的sql语句,使用asp.net来获得结果,
select * from T_luanguage where instr(:column,:content)>0通过给参数column,赋不同的列,来实现查找相应的结果,如给程序column参数赋“China”,content为“中国”
:column赋值为"China"
:content赋值为"中国"
亦即
select * from T_luanguage where instr(China,'中国')>0 ,在pl/sql可以查出结果,程序执行却返回空记录,估计Oracle使用参数化,将上述语句为变
select * from T_luanguage where instr('China','中国')>0 导致查不出结果。期待高手解决!!!
Id China English
1 中国 china
2 朋友 friend
3 人民 people
4 书 book
.................
现在一个参数化的sql语句,使用asp.net来获得结果,
select * from T_luanguage where instr(:column,:content)>0通过给参数column,赋不同的列,来实现查找相应的结果,如给程序column参数赋“China”,content为“中国”
:column赋值为"China"
:content赋值为"中国"
亦即
select * from T_luanguage where instr(China,'中国')>0 ,在pl/sql可以查出结果,程序执行却返回空记录,估计Oracle使用参数化,将上述语句为变
select * from T_luanguage where instr('China','中国')>0 导致查不出结果。期待高手解决!!!
否则,达不到你所想要的结果!!
你可以在前台检测使用不同的列而写成不同的两个SQL语句。
也可以在一个存储过程中使用动态SQL来处理create or replace procedure(i_col varchar2,col_value varchar2,o out sys_refcursor) is
--i_col:要查询的列
--i_value:要查询的列值
--o:返回一个游标数据集
v_sql varchar2(2000);
begin
v_sql := 'select * from t_language where instr('||i_col||','''||col_value||''')>0';
open o for v_sql;
end;
create or replace procedure get_rset(i_col varchar2,col_value varchar2,o out sys_refcursor) is
--i_col:要查询的列
--i_value:要查询的列值
--o:返回一个游标数据集
v_sql varchar2(2000);
begin
v_sql := 'select * from t_language where instr('||i_col||','''||col_value||''')>0';
open o for v_sql;
end;
SQL> with t as(
2 select 1 id,'中国' entity,'china' en_nm from dual union all
3 select 2 id,'朋友','friend' from dual union all
4 select 3 id,'人民','people' from dual union all
5 select 4 id,'书','book' from dual)
6 select * from t
7 where instr(entity,'中国')>0
8 /
ID ENTITY EN_NM
-------------------- ------ ------
1 中国 china
汗 这个永远不成立 怎么会有结果呢