文章分類

C# (27) ASP.NET (13) SQL (7) ORACLE (5) JAVA (2) SQLSERVER2008 (2) 大家都在問的事 (2) ACCESS (1) ANDRIOD (1) JQUERY (1) python (1) 雜談 (1)

關於我自己

我的相片
程式初心者 JAVA, ASP.NET, C# ,SQL

2010年11月3日 星期三

StringBuilder.APPEND用法

static string GetSqlString_1()
{
StringBuilder sqlCmd;
sqlCmd = new StringBuilder("");
sqlCmd.Append(
"select customer.customername || ' ' as cstname,vendor.vbename || ' ' as vbename,");
sqlCmd.Append(" tradepara.cparavalue || ' ' as Bank,");
sqlCmd.Append(" vendor.brkcap ||' '|| vendor.brkcapvalue as CCASS,");
sqlCmd.Append(" contract.tradername ||'      '|| contract.traderphone as Person,");
sqlCmd.Append(" contract.bankno || ' ' as BIC,contract.traderemail || ' ' as email");
sqlCmd.Append(" from sbtrade");
sqlCmd.Append(" left join customer on sbtrade.corpid = customer.corpid");
sqlCmd.Append(" and sbtrade.customerid = customer.customerid");
sqlCmd.Append(" left join vendor on sbtrade.corpid = vendor.corpid");
sqlCmd.Append(" and sbtrade.secbrkid = vendor.secbrkid");
sqlCmd.Append(" left join tradepara on sbtrade.corpid = tradepara.corpid");
sqlCmd.Append(" and tradepara.tradeid=:tradeid");
sqlCmd.Append(" and sbtrade.customerid = tradepara.customerid");
sqlCmd.Append(" and tradepara.cparaid='CUSTBANKNAME'");
sqlCmd.Append(" left join contract on sbtrade.corpid = contract.corpid");
sqlCmd.Append(" and sbtrade.mktcodeid = contract.mktcodeid");
sqlCmd.Append(" and sbtrade.secbrkid = contract.secbrkid");
sqlCmd.Append(" and contract.sbktype='CSI'");
sqlCmd.Append(" and sbtrade.secaccount = contract.secaccount");
sqlCmd.Append(" where sbtrade.corpid=:gCorpId and sbtrade.tradetype='BS'");
sqlCmd.Append(" and to_char(sbtrade.tradedate,'yyyy/MM/dd') = :tradedate");
sqlCmd.Append(" and sbtrade.mktcodeid=:mktcodeid");
sqlCmd.Append(" and sbtrade.secbrkid = :secbrkid");
sqlCmd.Append(" and sbtrade.secaccount = :secaccount");
sqlCmd.Append(" and sbtrade.customerid = :customerid");
return sqlCmd.ToString();
}
static string GetSqlString_2()
{
string sql =
"select customer.customername || ' ' as cstname,vendor.vbename || ' ' as vbename," +
" tradepara.cparavalue || ' ' as Bank," +
" vendor.brkcap ||' '|| vendor.brkcapvalue as CCASS," +
" contract.tradername ||'      '|| contract.traderphone as Person," +
" contract.bankno || ' ' as BIC,contract.traderemail || ' ' as email" +
" from sbtrade" +
" left join customer on sbtrade.corpid = customer.corpid" +
" and sbtrade.customerid = customer.customerid" +
" left join vendor on sbtrade.corpid = vendor.corpid" +
" and sbtrade.secbrkid = vendor.secbrkid" +
" left join tradepara on sbtrade.corpid = tradepara.corpid" +
" and tradepara.tradeid=:tradeid" +
" and sbtrade.customerid = tradepara.customerid" +
" and tradepara.cparaid='CUSTBANKNAME'" +
" left join contract on sbtrade.corpid = contract.corpid" +
" and sbtrade.mktcodeid = contract.mktcodeid" +
" and sbtrade.secbrkid = contract.secbrkid" +
" and contract.sbktype='CSI'" +
" and sbtrade.secaccount = contract.secaccount" +
" where sbtrade.corpid=:gCorpId and sbtrade.tradetype='BS'" +
" and to_char(sbtrade.tradedate,'yyyy/MM/dd') = :tradedate" +
" and sbtrade.mktcodeid=:mktcodeid" +
" and sbtrade.secbrkid = :secbrkid" +
" and sbtrade.secaccount = :secaccount" +
" and sbtrade.customerid = :customerid";
return sql;
}
以上兩個一樣!

沒有留言:

張貼留言