首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

将sql语句用paraset中的值给填充一上

2012-08-31 
将sql语句用paraset中的值给填充一下!int CSQLMake::DoSqlFit(std::string &strSql, CParaSet &oInPara){i

将sql语句用paraset中的值给填充一下!

int CSQLMake::DoSqlFit(std::string &strSql, CParaSet &oInPara){    int iRet = 0;    // 拆分sql    std::vector<std::string> vctSql;    SplitSql(strSql, vctSql);    // 循环处理sql    std::vector<std::string> vctSqlFit;    std::vector<std::string>::iterator itr;    for (itr=vctSql.begin(); itr!=vctSql.end(); itr++)    {        //std::cout << "=====>" << *itr << std::endl;        MakeSqlFit(*itr, oInPara);        //std::cout << "--------->" << *itr << std::endl;        vctSqlFit.push_back(*itr);    }    // 合并sql    MergeSql(strSql, vctSqlFit);    // 最后处理一下排序字段 order by    //需要排序,需要把原来的过滤条件给去掉。    std::string::size_type iOrderpos = strSql.find(" order ");    if (std::string::npos == iOrderpos)    {        ;//没有order排序,直接过。    }    else    {        strSql = strSql.substr(0,iOrderpos);    }    if ( oInPara["sort.strFild"].isNull() || oInPara["sort.iOrder"].isNull() )    {        return iRet;    }    int iOrder = oInPara["sort.iOrder"].asInt();    std::string strSortField = oInPara["sort.strFild"].asString();    strSql = strSql + " order by " + strSortField;    if (2 == iOrder)    {        strSql = strSql + " ASC";    }    else    {        strSql = strSql + " DESC";    }    return iRet;}

热点排行