在Oracle Connection Sql Query中使用变量

时间:2013-07-30 06:50:31

标签: oracle asp.net-mvc-4 razor

我试图在SQL查询中使用变量但是失败了。怎么做到这一点?

 var SicilNumvber = SessionCurrentUser.EMPNO;
                    string query = "select * from crm_visible_v where ownerid in (select sicilno from personel.pkim_kutlama@netdb_1.europe.nortel.com where cikis_tarihi is null start with sicilno = :SicilNumvber   connect by prior sicilno = amir)";

此致

2 个答案:

答案 0 :(得分:0)

请将固定字符串与变量部分连接起来,如下所示

     string query := 'select * from crm_visible_v where ownerid in (select sicilno 
     from personel.pkim_kutlama@netdb_1.europe.nortel.com where cikis_tarihi is null    
     start with sicilno ='||SicilNumvber||' connect by prior sicilno = ''''amir'';

答案 1 :(得分:0)

成功查询如下: 谢谢你的帮助;

string query = "select * from crm_visible_v where ownerid in (select sicilno from personel.pkim_kutlama@netdb_1.europe.nortel.com where cikis_tarihi is null start with sicilno ='"+SicilNumvber+"' connect by prior sicilno = amir)";