- #include <time.h>
- #include <signal.h>
- #include "seetime.h"
- #include "writeoff_inc.h"
- /*
- DB_USER_FEE_DETAIL db_user_fee_detail;
- Connection* amsConn;
- char sql[1024];
- IND_USER_FEE_DETAIL_BY_INSPRODID ind_user_fee_detail_by_insprodid;
- long InitUserInfo()
- {
- long j = 0;
- strcpy(g_struGlobalParam.szRegion, "a");
- sprintf(sql,
- " SELECT PRODUCT_INSTANCE_ID, 0 HIS_AMOUNT, 0 LAST_AMOUNT, 0 HIS_BALANCE, 0 CUR_AMOUNT, "
- " 0 CUR_BALANCE, 0 INVALID_BALANCE, 0 CALL_FEE, 0 RENT_FEE, 0 FAVOR_FEE, "
- " 0 FAVOR_PFEE, 0 PAYMENT_FEE, 0 LATE_FEE, 0 APPORTION_FEE, 0 PRESENT_FEE,"
- " 0 DELMON_FEE, TO_CHAR(SYSDATE, 'YYYYMMDDHH24MISS') OPT_DATE "
- " FROM INS_PROD_%s "
- " WHERE STATE NOT IN('C', 'D', 'E') ", g_struGlobalParam.szRegion);
- // sprintf(sql, "SELECT PRODUCT_INSTANCE_ID FROM INS_PROD_A WHERE 1 = 1");
- g_cLogFile.Info(0, "加载用户资料,SQL=[%s]", sql);
- j = db_user_fee_detail.LoadByRecord(*amsConn, sql);
- if (j <= 0)
- {
- g_cLogFile.Error(0, "加载用户资料到内存失败");
- cout << amsConn->GetMsg() << endl;
- return -1;
- }
- g_cLogFile.Info(0, "装载用户资料成功,共计[%d]条", db_user_fee_detail.GetNodeNumber());
- // CRecords c_record(*amsConn, 1);
- // c_record.Query(sql);
- // for (int i = 0; i < 10; i++)
- // {
- // cout << c_record.Field(0).Float() << endl;
- // c_record.Next();
- // }
- return j;
- }
- long OutputFeeDetail()
- {
- long j = 0;
- int nTotalCounts = 0;
- T_USER_FEE_DETAIL tUserFeeDetail;
- T_LIST<STRU_USER_FEE_DETAIL> *plistUserFeeDetail = NULL;
- tUserFeeDetail.SetConn(*amsConn);
- tUserFeeDetail.SetBatSize(MAX_BATCH_SIZE);
- tUserFeeDetail.SetTableName("aa");
- plistUserFeeDetail = db_user_fee_detail.GetList();
- plistUserFeeDetail->GoHead();
- while (j >= 0 && plistUserFeeDetail->Position())
- {
- nTotalCounts ++;
- db_user_fee_detail.ConvToTable(tUserFeeDetail, plistUserFeeDetail->Current());
- j = tUserFeeDetail.Insert();
- if (j <= 0)
- {
- g_cLogFile.Error(0, "帐单变化表[%s]插入失败,失败原因:[%s]",
- tUserFeeDetail.Name(), amsConn->GetMsg());
- j = -1;
- break;
- }
- plistUserFeeDetail->Next();
- if (!plistUserFeeDetail->Position())
- {
- g_cLogFile.Info(0, "已生成[%d]条帐单变化记录", nTotalCounts);
- }
- if (!plistUserFeeDetail->Position())
- {
- j = tUserFeeDetail.Flush();
- if (j <= 0)
- {
- j = -1;
- g_cLogFile.Error(0, "帐单变化表[%s]FLUSH失败,失败原因:[%s]",
- tUserFeeDetail.Name(), amsConn->GetMsg());
- }
- if (j >= 0)
- {
- amsConn->Commit();
- }
- else
- {
- amsConn->Rollback();
- }
- }
- }
- return j;
- }
- int main()
- {
- Settime();
- long j = Login("ORACLE");
- if (j <= 0)
- {
- cout << "数据库连接失败" << endl;
- return -1;
- }
- DbFactory.Initial();
- DbFactory.GetConnection("ams", "1", amsConn);
- db_user_fee_detail.SetBatchSize(MAX_BATCH_SIZE);
- db_user_fee_detail.AddIndex(&ind_user_fee_detail_by_insprodid);
- InitUserInfo();
- // OutputFeeDetail();
- STRU_USER_FEE_DETAIL* stru;
- ind_user_fee_detail_by_insprodid.Query(3804338, stru);
- cout << stru->PRODUCT_INSTANCE_ID << endl;
- cout << stru->OPT_DATE << endl;
- CRecords record(*amsConn, 1);
- char str[256];
- strcpy(str, "select * from student");
- j = record.Query(str);
- while (j > 0)
- {
- cout << record.Field("SNO").Char() << " ";
- cout << record.Field("SNAME").Char() << endl;
- j = record.Next();
- }
- DbFactory.FreeConnection(amsConn);
- Logout();
- cout << Gettime() << endl;
- return 0;
- }*/
- /*
- //表类的应用
- int main()
- {
- long j = Login("ORACLE");
- if (j <= 0)
- {
- cout << "Login failed" << endl;
- return 1;
- }
- Connection* amsConn = NULL;
- DbFactory.Initial();
- DbFactory.GetConnection("ams", "1", amsConn);
- // CRecords crecord(*amsConn, 1);
- //
- // char sql[256];
- // sprintf(sql, "insert into cc values('1','123','20081010121222')");
- // j = crecord.Query(sql);
- // if (j <= 0)
- // {
- // cout << "Query lost" << endl;
- // cout << amsConn->GetMsg() << endl;
- // return 1;
- // }
- //
- // amsConn->Commit();
- T_SMS_CUR_BALANCE table_a(*amsConn, 1);
- table_a.SetTableName("cc");
- table_a.ACCT_ID = 1;
- table_a.BALANCE = 23;
- table_a.OPT_DATE = "2008091012";
- j = table_a.Insert();
- if (j <= 0)
- {
- cout << amsConn->GetMsg() << endl;
- return 1;
- }
- amsConn->Commit();
- Logout();
- return 0;
- }*/
- int main()
- {
- Settime();
- long j = Login("ORACLE");
- if (j <= 0 )
- {
- cout << "Connect lost" << endl;
- return 1;
- }
- Connection* amsConn = NULL;
- DbFactory.Initial();
- j = DbFactory.GetConnection("ams", "1", amsConn);
- if (j <= 0)
- {
- cout << "Db lost" << endl;
- return 1;
- }
- T_ACCT_BALANCE table_a(*amsConn, 1);
- table_a.SetTableName("cc");
- CFileReader cread("F://test.txt", ",", " " );
- j = cread.Open();
- int i = 0;
- while (j > 0)
- {
- table_a.ACCT_BALANCE_ID = (long int)_atoi64(cread.GetField(4));
- table_a.ACCT_ID = (long int)_atoi64(cread.GetField(5));
- table_a.PAYMENT_ID = 1;
- table_a.EFF_DATE = cread.GetField(6);
- table_a.EXP_DATE = cread.GetField(7);
- table_a.OPT_DATE = cread.GetField(8);
- table_a.Insert();
- j = cread.Next();
- i++;
- }
- j = amsConn->Commit();
- if (j <= 0)
- {
- cout << amsConn->GetMsg() << endl;
- return 1;
- }
- cout << "OK" << endl;
- cout << i << endl;
- cread.Close();
- DbFactory.FreeConnection(amsConn);
- cout << Gettime() << endl;
- return 0;
- }
=========
使用sqlldr 是个不错的方法