- 论坛徽章:
- 0
|
一个proc程序与编译的问题.....
- #include <stdio.h>;
- #include <stdlib.h>;
- int main(int argc,char *argv[])
- {
- EXEC SQL BEGIN DECLARE SECTION;
- char auditSeq[10+1]={""};
- char beforefilename[100]={""};
- char afterfilename[100]={""};
- char sqlstr[2000]={""};
- char partitions[2+1]={""};
- char monthflag[1+1]={""};
- char auditmonth[2+1]={""};
-
- char auditTable[50]={""};
- char auditErrTable[50]={""};
- char auditTable_bak[50]={""};
- char auditErrTable_bak[50]={""};
-
- char roamOutTable[50]={""};
- char mergeTable[50]={""};
- char repeatTable[50]={""};
- char billTable[50]={""};
- char areacode[3+1]={"434"};
- char auditdate[8+1]={"20030223"};
- EXEC SQL END DECLARE SECTION;
- EXEC SQL INCLUDE sqlca;
- auditmonth[0]=auditdate[4];
- auditmonth[1]=auditdate[5];
- auditmonth[2]=0;
-
- switch(atoi(auditmonth))
- {
- case 1:
- case 7:
- monthflag[0]='1';break;
- case 2:
- case 8:
- monthflag[0]='2';break;
- case 3:
- case 9:
- monthflag[0]='3';break;
- case 4:
- case 10:
- monthflag[0]='4';break;
- case 5:
- case 11:
- monthflag[0]='5';break;
- case 6:
- case 12:
- monthflag[0]='6';break;
- }
- monthflag[1]=0;
-
- //表分区
- partitions[0]=auditdate[6];
- partitions[1]=auditdate[7];
- partitions[2]=0;
- //表后缀
- sprintf(roamOutTable,"Log_Audit_Roam_Out_GSM_%s_%s",areacode,monthflag);
- sprintf(auditTable,"Log_Fee_Audit_%s",areacode);
- sprintf(auditErrTable,"Log_Fee_Audit_Err_%s",areacode);
- sprintf(auditTable_bak,"Log_Fee_Audit_Hist_%s",areacode);
- sprintf(auditErrTable_bak,"Log_Fee_Audit_Err_Hist_%s",areacode);
-
- EXEC SQL SELECT auditing.SEQ_FEE_AUDIT.nextval INTO :auditSeq FROM dual;
- sprintf(sqlstr,"insert into %s (Fee_Audit_Seq,Service_Type,Tele_Order_Deal_Moment,Tele_Order_Status,Call_Date,Fee_Audit_Begin_Date) values ('%s','GSM','RoamOut-Repeat','0',%s,sysdate)",auditTable,auditSeq,auditdate);
- EXEC SQL EXECUTE IMMEDIATE :sqlstr;
- sprintf(sqlstr,"SELECT distinct before_filename,after_filename FROM %s PARTITION(DAY%s)",roamOutTable,partitions);
- EXEC SQL PREPARE RoamOutToRepeat FROM :sqlstr;
- EXEC SQL DECLARE a CURSOR FOR RoamOutToRepeat;
- EXEC SQL OPEN a;
- for(;;){//--a
- EXEC SQL WHENEVER NOT FOUND DO break;
- EXEC SQL FETCH a INTO :beforefilename,:afterfilename;
- printf("%s-----%s\n",beforefilename,afterfilename);
-
- }//--a
- EXEC SQL CLOSE a;
- sprintf(sqlstr,"update %s set Fee_Audit_End_Date=sysdate where Fee_Audit_Seq='%s'",auditTable,auditSeq);
- EXEC SQL EXECUTE IMMEDIATE :sqlstr;
- sprintf(sqlstr,"insert into %s select * from %s where Service_Type='GSM' and Tele_Order_Deal_Moment='RoamOut-Repeat' and Call_Date=%s",auditTable_bak,auditTable,auditdate);
- EXEC SQL EXECUTE IMMEDIATE :sqlstr;
- sprintf(sqlstr,"insert into %s select * from %s where Service_Type='GSM' and Tele_Order_Deal_Moment='RoamOut-Repeat' and Call_Date=%s",auditErrTable_bak,auditErrTable,auditdate);
- EXEC SQL EXECUTE IMMEDIATE :sqlstr;
- }
复制代码 |
|