Chinaunix

标题: AIX下DB2预编译嵌入sql的问题 [打印本页]

作者: steel1991    时间: 2004-06-24 11:32
标题: AIX下DB2预编译嵌入sql的问题
//Sales.sqC
#include <iostream.h>;
#include <string.h>;
#include "usr/opt/db2_08_01/include/sqlenv.h"
#include "usr/opt/db2_08_01/include/sql.h"
#include "usr/opt/db2_08_01/include/sqlca.h"
#include "usr/opt/db2_08_01/include/sqlda.h"
#include "usr/opt/db2_08_01/include/sqlutil.h"
#include "usr/opt/db2_08_01/include/sqladef.h"

void PrintStr()
{
        int i;
        for (i=0;i<10;i++)          
           cout<<"Hello World!\n";
}


void getDB2data()
{       
        EXEC SQL BEGIN DECLARE SECTION;
                 char userid[9]="db2inst1";
                 char psw[2]="1";
                 char DBName[7]="sample";
                 sqlint16  iSales;
                 char sRegion[16];
               
        EXEC SQL END DECLARE SECTION;                                
        EXEC SQL INCLUDE SQLCA;  
                        
        cout<<"rint DB Info..."<<endl;
        EXEC SQL CONNECT TO BName USER :userid USING :psw;
        cout<<"Connected DB\n";
        EXEC SQL SELECT REGION,SALES INTO :sRegion,:iSales FROM SALES WHERE SALES=18;
        //EXEC SQL COMMIT;
               
        cout<<"Region="<<sRegion<<"     Sales="<<iSales<<endl;
        char cRegion[16];
        strcpy(cRegion,sRegion);
        cout<<"cRegion="<<cRegion<<endl;
        cout<<"rint DB Info complete\n";

        EXEC SQL CONNECT RESET;
        //free( inout_sqlda );

}


int main()
{
        char ch[1];
        PrintStr();
        getDB2data();
        cout<<"\nPress any key to exit.\n";
        cin>;>;ch;
        return 0;
       
}

--------------------------------------------------------------------------
上面代码在prep时:
db2 =>;prep /home/qlw/Sales/Sales.sqC bindfile
报错说不能生成bnd文件,怎么办?
作者: steel1991    时间: 2004-06-24 17:27
标题: AIX下DB2预编译嵌入sql的问题
LINE MESSAGES FOR Sales.sqC
------ --------------------------------------------------------------------
SQL0060W The "C++" precompiler is in progress.
SQL0031C File "/home/qlw/Sales/Sales.bnd" could not be
opened.
SQL0095N No bind file was created because of previous
errors.
SQL0091W Precompilation or binding was ended with "2"
errors and "0" warnings.




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2