Beispiel #1
0
/*
---------------------------------------------------------
   TestSQLDataSources
	No negative tests since this functionality is done at
	driver manager level.
---------------------------------------------------------
*/
PassFail TestSQLDataSources(TestInfo *pTestInfo)
{                  
	TEST_DECLARE;
	RETCODE		returncode;
 	SQLHANDLE 	henv;
	char		szDSN[DSRC_LEN], szDESC[DSRC_LEN];
	SWORD		cbDSN, pcbDESC;

 	LogMsg(LINEBEFORE+SHORTTIMESTAMP,"Begin testing API => SQLDataSources | SQLDataSources | datasrc.c\n");

  TEST_INIT;

	//==========================================================================================
	   
  TESTCASE_BEGIN("Test the positive functionality of SQLDataSources\n");
 	returncode = SQLAllocEnv(&henv);                 /* Environment handle */
	if (returncode == SQL_SUCCESS)
	{
		returncode = SQLDataSources(henv, SQL_FETCH_FIRST, (SQLCHAR*)szDSN, DSRC_LEN, &cbDSN, (SQLCHAR*)szDESC, DSRC_LEN, &pcbDESC); 
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLDataSources"))
		{
			TEST_FAILED;
			LogMsg(ERRMSG,"Test SQLDataSources => SQL_FETCH_FIRST #1 failed.\n");
		}
		while (returncode == SQL_SUCCESS)
		{
			returncode = SQLDataSources(henv, SQL_FETCH_NEXT, (SQLCHAR*)szDSN, DSRC_LEN, &cbDSN, (SQLCHAR*)szDESC, DSRC_LEN, &pcbDESC); 
			if((returncode != SQL_SUCCESS) && (returncode != SQL_NO_DATA_FOUND))
			{
				TEST_FAILED;
				LogMsg(ERRMSG,"Test SQLDataSources => SQL_FETCH_NEXT failed.\n");
			}
		}
		returncode = SQLDataSources(henv, SQL_FETCH_FIRST, (SQLCHAR*)szDSN, DSRC_LEN, &cbDSN, (SQLCHAR*)szDESC, DSRC_LEN, &pcbDESC); 
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLDataSources"))
		{
			TEST_FAILED;
			LogMsg(ERRMSG,"Test SQLDataSources => SQL_FETCH_FIRST #2 failed.\n");
		}
	}
	SQLFreeEnv(henv);
   TESTCASE_END;

	//==========================================================================================
      
	LogMsg(SHORTTIMESTAMP+LINEAFTER,"End testing API => SQLDataSources.\n");
   TEST_RETURN;
}
Beispiel #2
0
/*
---------------------------------------------------------
   TestSQLMoreResults
---------------------------------------------------------
*/
PassFail TestSQLMoreResults(TestInfo *pTestInfo)
{                  
	TEST_DECLARE;
 	char			Heading[MAX_STRING_SIZE];
	RETCODE			returncode;
 	SQLHANDLE 		henv;
 	SQLHANDLE 		hdbc;
 	SQLHANDLE		hstmt;
	CHAR			*SetupStr[] =  { "--", "--", "--", "--", "--", "--", "--", "endloop" };
	CHAR			*TestStr[] = { "--", "--", "--", "--", "--","endloop" };
	int				cnt, fail = 0;
//===========================================================================================================
	var_list_t *var_list;
	var_list = load_api_vars("SQLMoreResults", charset_file);
	if (var_list == NULL) return FAILED;

	SetupStr[0] = var_mapping("SQLMoreResults_SetupStr_0", var_list);
	SetupStr[1] = var_mapping("SQLMoreResults_SetupStr_1", var_list);
	SetupStr[2] = var_mapping("SQLMoreResults_SetupStr_2", var_list);
	SetupStr[3] = var_mapping("SQLMoreResults_SetupStr_3", var_list);
	SetupStr[4] = var_mapping("SQLMoreResults_SetupStr_4", var_list);
	SetupStr[5] = var_mapping("SQLMoreResults_SetupStr_5", var_list);
	SetupStr[6] = var_mapping("SQLMoreResults_SetupStr_6", var_list);

	TestStr[0] = var_mapping("SQLMoreResults_TestStr_0", var_list);
	TestStr[1] = var_mapping("SQLMoreResults_TestStr_1", var_list);
	TestStr[2] = var_mapping("SQLMoreResults_TestStr_2", var_list);
	TestStr[3] = var_mapping("SQLMoreResults_TestStr_3", var_list);
	TestStr[4] = var_mapping("SQLMoreResults_TestStr_4", var_list);

//===========================================================================================================

	LogMsg(LINEBEFORE+SHORTTIMESTAMP,"Begin testing API =>SQLMoreResults | SQLMoreResults | moreres.c\n");

  TEST_INIT;
	returncode=FullConnect(pTestInfo);
   if (pTestInfo->hdbc == (SQLHANDLE)NULL)
	{
		TEST_FAILED;
		TEST_RETURN;
	}

	henv = pTestInfo->henv;
 	hdbc = pTestInfo->hdbc;
 	hstmt = (SQLHANDLE)pTestInfo->hstmt;
   	
	returncode = SQLAllocStmt((SQLHANDLE)hdbc, &hstmt);	
  if (returncode == SQL_SUCCESS)
	{
		cnt = 0;
		while (_stricmp(SetupStr[cnt],"endloop") != 0)
		{
			returncode = SQLExecDirect(hstmt,(SQLCHAR*) SetupStr[cnt],SQL_NTS);
			if (returncode == SQL_ERROR)
				fail++;
			cnt++;
		}
		if (fail != cnt)
		{
			cnt = 0;
			while (_stricmp(TestStr[cnt],"endloop") != 0)
			{
				sprintf(Heading,"Positive Test SQLMoreResults for ");
				strcat(Heading,TestStr[cnt]);
				strcat(Heading,"\n");
				TESTCASE_BEGIN(Heading);
				returncode = SQLExecDirect(hstmt,(SQLCHAR*)TestStr[cnt],SQL_NTS);
				if (returncode == SQL_SUCCESS)
				{
					SQLFetch(hstmt);
					returncode=SQLMoreResults(hstmt);
					if(!CHECKRC(SQL_NO_DATA_FOUND,returncode,"SQLMoreResults"))
					{
						TEST_FAILED;
						LogAllErrors(henv,hdbc,hstmt);
					}
				}
				TESTCASE_END;
				cnt++;
			}
			SQLExecDirect(hstmt,(SQLCHAR*)SetupStr[0],SQL_NTS); // CLEANUP 
			SQLExecDirect(hstmt,(SQLCHAR*)SetupStr[1],SQL_NTS); // CLEANUP 
		}
	}

//==============================================================================*/

	FullDisconnect(pTestInfo);
	LogMsg(SHORTTIMESTAMP+LINEAFTER,"End testing API => SQLMoreResults.\n");
	free_list(var_list);
	TEST_RETURN;
}
Beispiel #3
0
/*
---------------------------------------------------------
  TestSQLDrivers
	No negative tests since this functionality is done at
	driver manager level.
---------------------------------------------------------
*/
PassFail TestInfoStats(TestInfo *pTestInfo)
{                  
	TEST_DECLARE;

    SQLHANDLE	secHandle;
    SQLSMALLINT outLen = SQL_NTS;
    char		tempStr[MAX_STR_LEN*2];
	int			i,j;
	char		cursorName[MAX_STR_LEN] = "";
    RETCODE		returncode;

	char* strs[5];

    struct _test_data {
        char        front[2];
        char        back[MAX_SIZE];
        RETCODE     retcode;
        BOOL        cursor;
        char        *stmt;
    } testData[] = {{"", "",          SQL_SUCCESS,    TRUE,  ""},
                    {"", "",          SQL_SUCCESS,    TRUE,  ""},
                    {"", "",          SQL_SUCCESS,    TRUE,  ""},
                    {"", "SQL_CUR_2", SQL_ERROR,      FALSE, ""},
                    {"", "",          SQL_ERROR,      FALSE, ""},    // empty statement
                    {"'", "'",        SQL_SUCCESS,    TRUE,  ""},
                    {"\"", "\"",      SQL_SUCCESS,    TRUE,  ""},
                    {"", "SQL_CUR_9 ",SQL_ERROR,      FALSE, ""},
                    {"\"", "",        SQL_ERROR,      TRUE,  ""},
                    {"\"", "\"",      SQL_SUCCESS,    FALSE, ""},     // strs[3].txt
                    {"'", "'",        SQL_SUCCESS,    FALSE, ""},     // strs[3].txt
                    {"'", "",         SQL_ERROR,      FALSE, ""},     // strs[3].txt
                    {"\"", "",        SQL_ERROR,      FALSE, ""},     // strs[3].txt
                    {"", "\"",        SQL_ERROR,      FALSE, ""},     // strs[3].txt
                    {"", "'",         SQL_ERROR,      FALSE, ""},     // strs[3].txt
                    {"'", "'",        SQL_ERROR,      FALSE, ""},     // strs[4].txt
                    {"\"", "\"",      SQL_ERROR,      FALSE, ""},     // strs[4].txt
                    {"", "end"}
     };

//===========================================================================================================
	var_list_t *var_list;
	var_list = load_api_vars("InfoStats", charset_file);
	if (var_list == NULL) return FAILED;

    strs[0] = var_mapping("InfoStats_strs_0", var_list);
    strs[1] = var_mapping("InfoStats_strs_1", var_list);
    strs[2] = var_mapping("InfoStats_strs_2", var_list);
    strs[3] = var_mapping("InfoStats_strs_3", var_list);
    strs[4] = var_mapping("InfoStats_strs_4", var_list);
    strs[5] = var_mapping("InfoStats_strs_5", var_list);

	testData[9].stmt  = strs[3];
    testData[10].stmt = strs[3];
    testData[11].stmt = strs[3];
    testData[12].stmt = strs[3];
    testData[13].stmt = strs[3];
    testData[14].stmt = strs[3];

    testData[15].stmt = strs[4];
    testData[16].stmt = strs[4];

//===========================================================================================================

	LogMsg(LINEBEFORE+SHORTTIMESTAMP,"Begin testing => InfoStats | InfoStats | infostats.cpp\n");
    TEST_INIT;

	if(!FullConnectWithOptions(pTestInfo, CONNECT_ODBC_VERSION_3))
	{
		LogMsg(NONE,"Unable to connect\n");
		TEST_FAILED;
		TEST_RETURN;
	}

    returncode = SQLAllocStmt((SQLHANDLE)pTestInfo->hdbc, &(pTestInfo->hstmt));	
    if (returncode != SQL_SUCCESS) {
        TEST_FAILED;
        TEST_RETURN;
    }

    returncode = SQLAllocStmt((SQLHANDLE)pTestInfo->hdbc, &secHandle);
    if(returncode != SQL_SUCCESS) {
        TEST_FAILED;
        TEST_RETURN;
    }

    for(j = 0; j < 2; j++) {
        i = 0;
        while (strcmp(testData[i].back,"end")!=0) {

            if((j == 0) || (i==0)) {    // setup table and data
                LogMsg(NONE,"Setting up table and data\n");
                returncode = SQLExecDirect(pTestInfo->hstmt, (SQLCHAR*)strs[0], SQL_NTS);
	            returncode = SQLExecDirect(pTestInfo->hstmt, (SQLCHAR*)strs[1], SQL_NTS);
	            returncode = SQLExecDirect(pTestInfo->hstmt, (SQLCHAR*)strs[2], SQL_NTS);
	            returncode = SQLEndTran(SQL_HANDLE_DBC, pTestInfo->hdbc, SQL_COMMIT);
	            returncode = SQLFreeStmt(pTestInfo->hstmt, SQL_CLOSE);
            }
     
	        returncode = SQLPrepare(pTestInfo->hstmt, (SQLCHAR*)strs[3], SQL_NTS);

            strcpy(cursorName, "");

	        returncode = SQLGetCursorName(pTestInfo->hstmt, (SQLCHAR*)cursorName, sizeof(cursorName), &outLen);
            if(returncode != SQL_SUCCESS)
                LogAllErrors(pTestInfo->henv, pTestInfo->hdbc, pTestInfo->hstmt);

	        returncode = SQLExecute(pTestInfo->hstmt);

            sprintf(tempStr, "Starting test number %d\n", i);
            TESTCASE_BEGIN(tempStr);

            if(testData[i].cursor == TRUE)
                sprintf(tempStr, "INFOSTATS %s%s%s", testData[i].front, cursorName, testData[i].back);
            else
                sprintf(tempStr, "INFOSTATS %s%s%s", testData[i].front, testData[i].stmt, testData[i].back);

            returncode = execute(pTestInfo, secHandle, tempStr, testData[i].retcode);
            if(returncode == FALSE)
                TEST_FAILED;
			returncode = SQLFreeStmt(secHandle, SQL_CLOSE);
	        returncode = SQLFreeStmt(pTestInfo->hstmt,SQL_CLOSE);

            TESTCASE_END;
            i++;
        }

        returncode = SQLExecDirect(pTestInfo->hstmt, (SQLCHAR*)strs[0], SQL_NTS);
    }

	//==========================================================================================
      
	FullDisconnect3(pTestInfo);
	free_list(var_list);
	LogMsg(SHORTTIMESTAMP+LINEAFTER,"End testing => InfoStats.\n");
    TEST_RETURN;
}
Beispiel #4
0
/*
---------------------------------------------------------
   TestSQLTablePrivileges
---------------------------------------------------------
*/
PassFail TestMXSQLTablePrivileges( TestInfo *pTestInfo)
{
	TEST_DECLARE;
 	char			Heading[MAX_HEADING_SIZE];
	/*  */char	ColumnWC4_TabOwner[NAME_LEN];
 	RETCODE			returncode;
 	SQLHANDLE 		henv = (SQLHANDLE)NULL;
 	SQLHANDLE 		hdbc = (SQLHANDLE)NULL;
 	SQLHANDLE		hstmt = (SQLHANDLE)NULL, hstmt1 = (SQLHANDLE)NULL;
	CHAR			TableQualifier[NAME_LEN],TableOwner[NAME_LEN],*TableStr;

	CHAR			*TableName;
	
	// CHAR			*Grantor; //Assume that we log on as role.user
	CHAR            Grantor[SQL_MAX_ROLENAME_LEN+2];

	CHAR			oTableQualifier[NAME_LEN];  
	CHAR			oTableOwner[NAME_LEN];
	CHAR			oTableName[NAME_LEN];
	CHAR			oGrantor[NAME_LEN];
	CHAR			oGrantee[NAME_LEN];
	CHAR			oPrivilege[NAME_LEN];
	CHAR			oIs_Grantable[3];

	SQLLEN		oTableQualifierlen;
	SQLLEN		oTableOwnerlen;
	SQLLEN		oTableNamelen;
	SQLLEN		oGrantorlen = SQL_NTS;
	SQLLEN		oGranteelen;
	SQLLEN		oPrivilegelen;
	SQLLEN		oIs_Grantablelen;

/*  */
	struct
	{
		CHAR		*Col;
		CHAR		*Grantee;
		CHAR		*Is_Grantable;
		CHAR		*Privilege;
	} TableCol[] = {
		{"--",SQ_GRANTEE,"YES","DELETE"},
		{"--",SQ_GRANTEE,"NO","DELETE,SELECT"},
		{"--",SQ_GRANTEE,"YES","SELECT"},
		{"--",SQ_GRANTEE,"NO","DELETE"},
		{"--",SQ_GRANTEE,"YES","INSERT"},
		{"--",SQ_GRANTEE,"NO","UPDATE"},
		{"--",SQ_GRANTEE,"YES","REFERENCES"},
		{"--",SQ_GRANTEE,"NO","SELECT"},
		{"--",SQ_GRANTEE,"YES","INSERT"},
		{"--",SQ_GRANTEE,"NO","REFERENCES"},
		{"--",SQ_GRANTEE,"YES","UPDATE"},
		{"--",SQ_GRANTEE,"NO","REFERENCES"},
		{"--",SQ_GRANTEE,"YES","UPDATE"},
		{"--",SQ_GRANTEE,"NO","INSERT",},
		{"--",SQ_GRANTEE,"YES","SELECT"},
		{"--",SQ_GRANTEE,"NO","REFERENCES,SELECT"},
		{"--",SQ_GRANTEE,"YES","DELETE,INSERT,SELECT"},
		{"--",SQ_GRANTEE,"NO","INSERT,REFERENCES,UPDATE"},
		{"--",SQ_GRANTEE,"YES","SELECT,DELETE,INSERT,UPDATE"},
		{"--",SQ_GRANTEE,"NO","DELETE,INSERT,REFERENCES,UPDATE",},
		{"--",SQ_GRANTEE,"YES","DELETE,INSERT,REFERENCES,SELECT,UPDATE"},
		{"--",SQ_GRANTEE,"NO","DELETE"},						//Bignum
		{"--",SQ_GRANTEE,"YES","SELECT"},					//Bignum
		{"--",SQ_GRANTEE,"NO","INSERT"},						//Bignum
		{"--",SQ_GRANTEE,"YES","UPDATE"},					//Bignum
		{"--",SQ_GRANTEE,"NO","REFERENCES"},					//Bignum
		{"--",SQ_GRANTEE,"YES","SELECT,DELETE,INSERT,UPDATE"},//Bignum
		{"--",SQ_GRANTEE,"NO","INSERT,REFERENCES,UPDATE"},	//Bignum
		{"endloop",}
	};

	struct
	{
		CHAR		*TabQua;
		CHAR		*TabOwner;
		CHAR		*TabName;
		RETCODE		CheckCode;
		int			isEscape;
	} ColumnWC[] = {								// wild cards from here 
							{"--","--","--", SQL_SUCCESS,0},// Have a row with all valid values here so that 
							{"--","--","--", SQL_SUCCESS,0},
							{"--","--","--", SQL_SUCCESS,0},
							{"--","--","--", SQL_SUCCESS,0},
							{"--","--","--", SQL_SUCCESS,0},
							{"--","--","--", SQL_SUCCESS,0},
							{"--","--","--", SQL_SUCCESS,0},
							{"--","--","--", SQL_ERROR,0},
							{"--","--","--", SQL_ERROR,0},
							{"--","--","--", SQL_ERROR,0},
							{"--","--","--", SQL_ERROR,0},
							{"--","--","--", SQL_ERROR,0}, 
							{"--","--","--", SQL_ERROR,0}, 
							{"--","--","--", SQL_ERROR,0}, 
							{"--","--","--", SQL_ERROR,0},
							{"--","--","--", SQL_SUCCESS,0},
							{"--","--","--", SQL_SUCCESS,0},
							{"--","--","--", SQL_SUCCESS,0},
							{"--","--","--", SQL_SUCCESS,0},
							{"--","--","--", SQL_SUCCESS,0},
							{"--","--","--", SQL_SUCCESS,0},
							{"--","--","--", SQL_SUCCESS,0},
							{"--","--","--", SQL_SUCCESS,0},
							{"--","--","--", SQL_SUCCESS,0},
							{"--","--","--", SQL_SUCCESS,0},
							{"--","--","--", SQL_SUCCESS,0},
							{"--","--","--", SQL_SUCCESS,0},
							{"--","--","--", SQL_SUCCESS,0},
							{"--","--","--", SQL_SUCCESS,0},
							{"--","--","--", SQL_SUCCESS,0},
							{"--","--","--", SQL_SUCCESS,0},
							//	Testing escape sequences
							{"--","--","--", SQL_SUCCESS,1},
							{"--","--","--", SQL_SUCCESS,1},
							{"--","--","--", SQL_SUCCESS,1},
							{"--","--","--", SQL_SUCCESS,1},
							{"endloop",}
						};

	struct
	{
		CHAR		*TabQua;
		SWORD		TabQuaLen;
		CHAR		*TabOwner;
		SWORD		TabOwnerLen;
		CHAR		*TabName;
		SWORD		TabNameLen;
		CHAR		*ColName;
		SWORD		ColNameLen;
	} ColumnWC2[] = {								//	wild cards from here
							{"--", (SWORD)-1, "--",(SWORD)-1, "--",(SWORD)-1, "", (SWORD)-1},
							{"--", (SWORD)4,  "--",(SWORD)2,  "--",(SWORD)2,  "", (SWORD)2},
//							{"TEST_CATALOG", (SWORD)0, "TEST_SCHEMA",(SWORD)0, "TEST_TABLE",(SWORD)0, "", (SWORD)0},
							{"endloop",}
						};

	int cols;
	int	iatt;
	SWORD numOfCols = 0;
	SWORD pcbDesc;
	SQLLEN pfDesc;
	CHAR cn[COLNAME_LEN];
	SWORD cl;
	SWORD st;
	SQLULEN cp;
	SWORD cs, cnull;
	CHAR rgbDesc[RGB_MAX_LEN];
	CHAR *CharOutput[12];
	SQLLEN stringlength;	//	Attributes for columns added for negative testing
	UWORD DescrType[] = 
				{
					SQL_COLUMN_AUTO_INCREMENT,SQL_COLUMN_CASE_SENSITIVE,SQL_COLUMN_COUNT,
					SQL_COLUMN_DISPLAY_SIZE,SQL_COLUMN_LENGTH,SQL_COLUMN_MONEY,
					SQL_COLUMN_NULLABLE,SQL_COLUMN_PRECISION,SQL_COLUMN_SCALE,
					SQL_COLUMN_SEARCHABLE,SQL_COLUMN_TYPE,SQL_COLUMN_UNSIGNED,
					SQL_COLUMN_UPDATABLE,SQL_COLUMN_NAME,SQL_COLUMN_TYPE_NAME,
					SQL_COLUMN_OWNER_NAME,SQL_COLUMN_QUALIFIER_NAME,SQL_COLUMN_TABLE_NAME,
					SQL_COLUMN_LABEL
				};

	CHAR	*TestColumn;
	int		i = 0, k = 0;

    struct {
        char cat[STR_LEN];
        char sch[STR_LEN];
        char tab[STR_LEN];
    } displayBuf;

//	DWORD	nSize;


//===========================================================================================================
	var_list_t *var_list;
	var_list = load_api_vars("SQLTablePrivileges", charset_file);
	if (var_list == NULL) return FAILED;

	TableName = var_mapping("SQLTablePrivileges_TableName", var_list);

	TestColumn = var_mapping("SQLTablePrivileges_TestColumn", var_list);

	TableCol[0].Col = var_mapping("SQLTablePrivileges_TableCol_Col_0", var_list);
	TableCol[1].Col = var_mapping("SQLTablePrivileges_TableCol_Col_1", var_list);
	TableCol[2].Col = var_mapping("SQLTablePrivileges_TableCol_Col_2", var_list);
	TableCol[3].Col = var_mapping("SQLTablePrivileges_TableCol_Col_3", var_list);
	TableCol[4].Col = var_mapping("SQLTablePrivileges_TableCol_Col_4", var_list);
	TableCol[5].Col = var_mapping("SQLTablePrivileges_TableCol_Col_5", var_list);
	TableCol[6].Col = var_mapping("SQLTablePrivileges_TableCol_Col_6", var_list);
	TableCol[7].Col = var_mapping("SQLTablePrivileges_TableCol_Col_7", var_list);
	TableCol[8].Col = var_mapping("SQLTablePrivileges_TableCol_Col_8", var_list);
	TableCol[9].Col = var_mapping("SQLTablePrivileges_TableCol_Col_9", var_list);
	TableCol[10].Col = var_mapping("SQLTablePrivileges_TableCol_Col_10", var_list);
	TableCol[11].Col = var_mapping("SQLTablePrivileges_TableCol_Col_11", var_list);
	TableCol[12].Col = var_mapping("SQLTablePrivileges_TableCol_Col_12", var_list);
	TableCol[13].Col = var_mapping("SQLTablePrivileges_TableCol_Col_13", var_list);
	TableCol[14].Col = var_mapping("SQLTablePrivileges_TableCol_Col_14", var_list);
	TableCol[15].Col = var_mapping("SQLTablePrivileges_TableCol_Col_15", var_list);
	TableCol[16].Col = var_mapping("SQLTablePrivileges_TableCol_Col_16", var_list);
	TableCol[17].Col = var_mapping("SQLTablePrivileges_TableCol_Col_17", var_list);
	TableCol[18].Col = var_mapping("SQLTablePrivileges_TableCol_Col_18", var_list);
	TableCol[19].Col = var_mapping("SQLTablePrivileges_TableCol_Col_19", var_list);
	TableCol[20].Col = var_mapping("SQLTablePrivileges_TableCol_Col_20", var_list);
	TableCol[21].Col = var_mapping("SQLTablePrivileges_TableCol_Col_21", var_list);
	TableCol[22].Col = var_mapping("SQLTablePrivileges_TableCol_Col_22", var_list);
	TableCol[23].Col = var_mapping("SQLTablePrivileges_TableCol_Col_23", var_list);
	TableCol[24].Col = var_mapping("SQLTablePrivileges_TableCol_Col_24", var_list);
	TableCol[25].Col = var_mapping("SQLTablePrivileges_TableCol_Col_25", var_list);
	TableCol[26].Col = var_mapping("SQLTablePrivileges_TableCol_Col_26", var_list);
	TableCol[27].Col = var_mapping("SQLTablePrivileges_TableCol_Col_27", var_list);

	ColumnWC[0].TabQua = var_mapping("SQLTablePrivileges_ColumnWC_TabQua_0", var_list);
	ColumnWC[0].TabOwner = var_mapping("SQLTablePrivileges_ColumnWC_TabOwner_0", var_list);
	ColumnWC[0].TabName = var_mapping("SQLTablePrivileges_ColumnWC_TabName_0", var_list);

	ColumnWC[1].TabQua = var_mapping("SQLTablePrivileges_ColumnWC_TabQua_1", var_list);
	ColumnWC[1].TabOwner = var_mapping("SQLTablePrivileges_ColumnWC_TabOwner_1", var_list);
	ColumnWC[1].TabName = var_mapping("SQLTablePrivileges_ColumnWC_TabName_1", var_list);

	ColumnWC[2].TabQua = var_mapping("SQLTablePrivileges_ColumnWC_TabQua_2", var_list);
	ColumnWC[2].TabOwner = var_mapping("SQLTablePrivileges_ColumnWC_TabOwner_2", var_list);
	ColumnWC[2].TabName = var_mapping("SQLTablePrivileges_ColumnWC_TabName_2", var_list);

	ColumnWC[3].TabQua = var_mapping("SQLTablePrivileges_ColumnWC_TabQua_3", var_list);
	ColumnWC[3].TabOwner = var_mapping("SQLTablePrivileges_ColumnWC_TabOwner_3", var_list);
	ColumnWC[3].TabName = var_mapping("SQLTablePrivileges_ColumnWC_TabName_3", var_list);

	ColumnWC[4].TabQua = var_mapping("SQLTablePrivileges_ColumnWC_TabQua_4", var_list);
        ColumnWC[4].TabOwner = var_mapping("SQLTablePrivileges_ColumnWC_TabOwner_4", var_list); 
	ColumnWC[4].TabName = var_mapping("SQLTablePrivileges_ColumnWC_TabName_4", var_list);

	ColumnWC[5].TabQua = var_mapping("SQLTablePrivileges_ColumnWC_TabQua_5", var_list);
	ColumnWC[5].TabOwner = var_mapping("SQLTablePrivileges_ColumnWC_TabOwner_5", var_list);
	ColumnWC[5].TabName = var_mapping("SQLTablePrivileges_ColumnWC_TabName_5", var_list);

	ColumnWC[6].TabQua = var_mapping("SQLTablePrivileges_ColumnWC_TabQua_6", var_list);
	ColumnWC[6].TabOwner = var_mapping("SQLTablePrivileges_ColumnWC_TabOwner_6", var_list);
	ColumnWC[6].TabName = var_mapping("SQLTablePrivileges_ColumnWC_TabName_6", var_list);

	ColumnWC[7].TabQua = var_mapping("SQLTablePrivileges_ColumnWC_TabQua_7", var_list);
	ColumnWC[7].TabOwner = var_mapping("SQLTablePrivileges_ColumnWC_TabOwner_7", var_list);
	ColumnWC[7].TabName = var_mapping("SQLTablePrivileges_ColumnWC_TabName_7", var_list);

	ColumnWC[8].TabQua = var_mapping("SQLTablePrivileges_ColumnWC_TabQua_8", var_list);
	ColumnWC[8].TabOwner = var_mapping("SQLTablePrivileges_ColumnWC_TabOwner_8", var_list);
	ColumnWC[8].TabName = var_mapping("SQLTablePrivileges_ColumnWC_TabName_8", var_list);

	ColumnWC[9].TabQua = var_mapping("SQLTablePrivileges_ColumnWC_TabQua_9", var_list);
	ColumnWC[9].TabOwner = var_mapping("SQLTablePrivileges_ColumnWC_TabOwner_9", var_list);
	ColumnWC[9].TabName = var_mapping("SQLTablePrivileges_ColumnWC_TabName_9", var_list);

	ColumnWC[10].TabQua = var_mapping("SQLTablePrivileges_ColumnWC_TabQua_10", var_list);
	ColumnWC[10].TabOwner = var_mapping("SQLTablePrivileges_ColumnWC_TabOwner_10", var_list);
	ColumnWC[10].TabName = var_mapping("SQLTablePrivileges_ColumnWC_TabName_10", var_list);

	ColumnWC[11].TabQua = var_mapping("SQLTablePrivileges_ColumnWC_TabQua_11", var_list);
	ColumnWC[11].TabOwner = var_mapping("SQLTablePrivileges_ColumnWC_TabOwner_11", var_list);
	ColumnWC[11].TabName = var_mapping("SQLTablePrivileges_ColumnWC_TabName_11", var_list);

	ColumnWC[12].TabQua = var_mapping("SQLTablePrivileges_ColumnWC_TabQua_12", var_list);
	ColumnWC[12].TabOwner = var_mapping("SQLTablePrivileges_ColumnWC_TabOwner_12", var_list);
	ColumnWC[12].TabName = var_mapping("SQLTablePrivileges_ColumnWC_TabName_12", var_list);

	ColumnWC[13].TabQua = var_mapping("SQLTablePrivileges_ColumnWC_TabQua_13", var_list);
	ColumnWC[13].TabOwner = var_mapping("SQLTablePrivileges_ColumnWC_TabOwner_13", var_list);
	ColumnWC[13].TabName = var_mapping("SQLTablePrivileges_ColumnWC_TabName_13", var_list);

	ColumnWC[14].TabQua = var_mapping("SQLTablePrivileges_ColumnWC_TabQua_14", var_list);
	ColumnWC[14].TabOwner = var_mapping("SQLTablePrivileges_ColumnWC_TabOwner_14", var_list);
	ColumnWC[14].TabName = var_mapping("SQLTablePrivileges_ColumnWC_TabName_14", var_list);

	ColumnWC[15].TabQua = var_mapping("SQLTablePrivileges_ColumnWC_TabQua_15", var_list);
	ColumnWC[15].TabOwner = var_mapping("SQLTablePrivileges_ColumnWC_TabOwner_15", var_list);
	ColumnWC[15].TabName = var_mapping("SQLTablePrivileges_ColumnWC_TabName_15", var_list);

	ColumnWC[16].TabQua = var_mapping("SQLTablePrivileges_ColumnWC_TabQua_16", var_list);
	ColumnWC[16].TabOwner = var_mapping("SQLTablePrivileges_ColumnWC_TabOwner_16", var_list);
	ColumnWC[16].TabName = var_mapping("SQLTablePrivileges_ColumnWC_TabName_16", var_list);

	ColumnWC[17].TabQua = var_mapping("SQLTablePrivileges_ColumnWC_TabQua_17", var_list);
	ColumnWC[17].TabOwner = var_mapping("SQLTablePrivileges_ColumnWC_TabOwner_17", var_list);
	ColumnWC[17].TabName = var_mapping("SQLTablePrivileges_ColumnWC_TabName_17", var_list);

	ColumnWC[18].TabQua = var_mapping("SQLTablePrivileges_ColumnWC_TabQua_18", var_list);
	ColumnWC[18].TabOwner = var_mapping("SQLTablePrivileges_ColumnWC_TabOwner_18", var_list);
	ColumnWC[18].TabName = var_mapping("SQLTablePrivileges_ColumnWC_TabName_18", var_list);

	ColumnWC[19].TabQua = var_mapping("SQLTablePrivileges_ColumnWC_TabQua_19", var_list);
	ColumnWC[19].TabOwner = var_mapping("SQLTablePrivileges_ColumnWC_TabOwner_19", var_list);
	ColumnWC[19].TabName = var_mapping("SQLTablePrivileges_ColumnWC_TabName_19", var_list);

	ColumnWC[20].TabQua = var_mapping("SQLTablePrivileges_ColumnWC_TabQua_20", var_list);
	ColumnWC[20].TabOwner = var_mapping("SQLTablePrivileges_ColumnWC_TabOwner_20", var_list);
	ColumnWC[20].TabName = var_mapping("SQLTablePrivileges_ColumnWC_TabName_20", var_list);

	ColumnWC[21].TabQua = var_mapping("SQLTablePrivileges_ColumnWC_TabQua_21", var_list);
	ColumnWC[21].TabOwner = var_mapping("SQLTablePrivileges_ColumnWC_TabOwner_21", var_list);
	ColumnWC[21].TabName = var_mapping("SQLTablePrivileges_ColumnWC_TabName_21", var_list);

	ColumnWC[22].TabQua = var_mapping("SQLTablePrivileges_ColumnWC_TabQua_22", var_list);
	ColumnWC[22].TabOwner = var_mapping("SQLTablePrivileges_ColumnWC_TabOwner_22", var_list);
	ColumnWC[22].TabName = var_mapping("SQLTablePrivileges_ColumnWC_TabName_22", var_list);

	ColumnWC[23].TabQua = var_mapping("SQLTablePrivileges_ColumnWC_TabQua_23", var_list);
	ColumnWC[23].TabOwner = var_mapping("SQLTablePrivileges_ColumnWC_TabOwner_23", var_list);
	ColumnWC[23].TabName = var_mapping("SQLTablePrivileges_ColumnWC_TabName_23", var_list);

	ColumnWC[24].TabQua = var_mapping("SQLTablePrivileges_ColumnWC_TabQua_24", var_list);
	ColumnWC[24].TabOwner = var_mapping("SQLTablePrivileges_ColumnWC_TabOwner_24", var_list);
	ColumnWC[24].TabName = var_mapping("SQLTablePrivileges_ColumnWC_TabName_24", var_list);

	ColumnWC[25].TabQua = var_mapping("SQLTablePrivileges_ColumnWC_TabQua_25", var_list);
	ColumnWC[25].TabOwner = var_mapping("SQLTablePrivileges_ColumnWC_TabOwner_25", var_list);
	ColumnWC[25].TabName = var_mapping("SQLTablePrivileges_ColumnWC_TabName_25", var_list);

	ColumnWC[26].TabQua = var_mapping("SQLTablePrivileges_ColumnWC_TabQua_26", var_list);
	ColumnWC[26].TabOwner = var_mapping("SQLTablePrivileges_ColumnWC_TabOwner_26", var_list);
	ColumnWC[26].TabName = var_mapping("SQLTablePrivileges_ColumnWC_TabName_26", var_list);

	ColumnWC[27].TabQua = var_mapping("SQLTablePrivileges_ColumnWC_TabQua_27", var_list);
	ColumnWC[27].TabOwner = var_mapping("SQLTablePrivileges_ColumnWC_TabOwner_27", var_list);
	ColumnWC[27].TabName = var_mapping("SQLTablePrivileges_ColumnWC_TabName_27", var_list);

	ColumnWC[28].TabQua = var_mapping("SQLTablePrivileges_ColumnWC_TabQua_28", var_list);
	ColumnWC[28].TabOwner = var_mapping("SQLTablePrivileges_ColumnWC_TabOwner_28", var_list);
	ColumnWC[28].TabName = var_mapping("SQLTablePrivileges_ColumnWC_TabName_28", var_list);

	ColumnWC[29].TabQua = var_mapping("SQLTablePrivileges_ColumnWC_TabQua_29", var_list);
	ColumnWC[29].TabOwner = var_mapping("SQLTablePrivileges_ColumnWC_TabOwner_29", var_list);
	ColumnWC[29].TabName = var_mapping("SQLTablePrivileges_ColumnWC_TabName_29", var_list);

	ColumnWC[30].TabQua = var_mapping("SQLTablePrivileges_ColumnWC_TabQua_30", var_list);
	ColumnWC[30].TabOwner = var_mapping("SQLTablePrivileges_ColumnWC_TabOwner_30", var_list);
	ColumnWC[30].TabName = var_mapping("SQLTablePrivileges_ColumnWC_TabName_30", var_list);

	ColumnWC[31].TabQua = var_mapping("SQLTablePrivileges_ColumnWC_TabQua_31", var_list);
	ColumnWC[31].TabOwner = var_mapping("SQLTablePrivileges_ColumnWC_TabOwner_31", var_list);
	ColumnWC[31].TabName = var_mapping("SQLTablePrivileges_ColumnWC_TabName_31", var_list);

	ColumnWC[32].TabQua = var_mapping("SQLTablePrivileges_ColumnWC_TabQua_32", var_list);
	ColumnWC[32].TabOwner = var_mapping("SQLTablePrivileges_ColumnWC_TabOwner_32", var_list);
	ColumnWC[32].TabName = var_mapping("SQLTablePrivileges_ColumnWC_TabName_32", var_list);

	ColumnWC[33].TabQua = var_mapping("SQLTablePrivileges_ColumnWC_TabQua_33", var_list);
	ColumnWC[33].TabOwner = var_mapping("SQLTablePrivileges_ColumnWC_TabOwner_33", var_list);
	ColumnWC[33].TabName = var_mapping("SQLTablePrivileges_ColumnWC_TabName_33", var_list);

	ColumnWC[34].TabQua = var_mapping("SQLTablePrivileges_ColumnWC_TabQua_34", var_list);
	ColumnWC[34].TabOwner = var_mapping("SQLTablePrivileges_ColumnWC_TabOwner_34", var_list);
	ColumnWC[34].TabName = var_mapping("SQLTablePrivileges_ColumnWC_TabName_34", var_list);

	ColumnWC2[0].TabQua = var_mapping("SQLTablePrivileges_ColumnWC2_TabQua_0", var_list);
	ColumnWC2[0].TabOwner = var_mapping("SQLTablePrivileges_ColumnWC2_TabOwner_0", var_list);
	ColumnWC2[0].TabName = var_mapping("SQLTablePrivileges_ColumnWC2_TabName_0", var_list);

	ColumnWC2[1].TabQua = var_mapping("SQLTablePrivileges_ColumnWC2_TabQua_1", var_list);
	ColumnWC2[1].TabOwner = var_mapping("SQLTablePrivileges_ColumnWC2_TabOwner_1", var_list);
	ColumnWC2[1].TabName = var_mapping("SQLTablePrivileges_ColumnWC2_TabName_1", var_list);

//=================================================================================================

	LogMsg(LINEBEFORE+SHORTTIMESTAMP,"Begin testing API => SQLTablePrivileges | SQLTablePriv | tabpriv.c\n");

	TEST_INIT;

	TESTCASE_BEGIN("Setup for SQLTablePrivileges tests\n");

	if(!FullConnectWithOptions(pTestInfo, CONNECT_ODBC_VERSION_3))
	{
		LogMsg(NONE,"Unable to connect\n");
		TEST_FAILED;
		TEST_RETURN;
	}

	henv = pTestInfo->henv;
 	hdbc = pTestInfo->hdbc;
 	hstmt = (SQLHANDLE)pTestInfo->hstmt;
   	
	returncode = SQLAllocStmt((SQLHANDLE)hdbc, &hstmt);	
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLAllocStmt"))
	{
		LogAllErrors(henv,hdbc,hstmt);
		TEST_FAILED;
		TEST_RETURN;
	}

#ifdef LDAP
	// Grantor = var_mapping("SQLTablePrivileges_Grantor", var_list);
/*
	returncode = SQLGetConnectAttr(hdbc, (SQLINTEGER)SQL_ATTR_ROLENAME, (SQLCHAR*)Grantor, SQL_MAX_ROLENAME_LEN+2, (SQLINTEGER *) &oGrantorlen);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLGetConnectAttr"))
	{
		LogAllErrors(henv,hdbc,hstmt);
		TEST_FAILED;
		TEST_RETURN;
	}
*/
/* hardcode it for now */ strcpy (Grantor, "DB__ROOT");
#else
        sprintf(Grantor, "%s", var_mapping("SQLTablePrivileges_Grantor", var_list)); 
#endif

	LogMsg(NONE,"Grantor is: %s\n", Grantor);

	TESTCASE_END;  // end of setup
 
	strcpy(TableQualifier,pTestInfo->Catalog);
	strcpy(TableOwner,pTestInfo->Schema);

	TableStr = (char *)malloc(MAX_NOS_SIZE);
	i = 0;
	while (_stricmp(TableCol[i].Col,"endloop") != 0)
	{
		sprintf(Heading,"Test #%d\n",i);
		TESTCASE_BEGIN(Heading);

		if (_stricmp(TableCol[i].Privilege,"ALL PRIVILEGES") == 0)
			strcpy(TableCol[i].Privilege,"DELETE");

		// clean up left over table, if any.  We don't care about returncode from SQLExecDirect
		sprintf(TableStr,"drop table %s",TableName);
		SQLExecDirect(hstmt,(SQLCHAR*) TableStr,SQL_NTS);
		
		// create table to test against
		sprintf(TableStr,"create table %s (%s) no partition;",TableName,TableCol[i].Col);
		returncode = SQLExecDirect(hstmt,(SQLCHAR*)TableStr,SQL_NTS);
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect"))
		{
			LogAllErrors(henv,hdbc,hstmt);
			TEST_FAILED;
		}
		else
		{
			// execute GRANT statement to set up some table privileges
			sprintf(TableStr,"GRANT %s ON %s TO \"%s\"",TableCol[i].Privilege,TableName,TableCol[i].Grantee);
			if (_stricmp(TableCol[i].Is_Grantable,"YES") == 0)
				strcat(TableStr, " WITH GRANT OPTION");
			LogMsg(NONE,"%s\n",TableStr);
			returncode = SQLExecDirect(hstmt,(SQLCHAR*)TableStr,SQL_NTS);
			if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect"))
			{
				LogAllErrors(henv,hdbc,hstmt);
				TEST_FAILED;
			}
			else
			{
				// Execute SQLTablePrivileges for test table
				if (strlen(TableQualifier) == 0)
					returncode = SQLTablePrivileges(hstmt,NULL,0,(SQLCHAR*)TableOwner,(SWORD)strlen(TableOwner),(SQLCHAR*)TableName,(SWORD)strlen(TableName));
				else
					returncode = SQLTablePrivileges(hstmt,(SQLCHAR*)TableQualifier,(SWORD)strlen(TableQualifier),(SQLCHAR*)TableOwner,(SWORD)strlen(TableOwner),(SQLCHAR*)TableName,(SWORD)strlen(TableName));
				if(!CHECKRC(SQL_SUCCESS,returncode,"SQLTablePrivileges"))
				{
					LogAllErrors(henv,hdbc,hstmt);
					TEST_FAILED;
				}
				else
				{
					LogMsg(NONE,"SQLTablePrivileges function call executed correctly.\n");

					// clear all buffers
					strcpy(oTableQualifier,"");
					strcpy(oTableOwner,"");
					strcpy(oTableName,"");
					strcpy(oGrantor,"");
					strcpy(oGrantee,"");
					strcpy(oPrivilege,"");
					strcpy(oIs_Grantable,"");

					// Bind all columns to recieve data returned from SQLTablePrivileges
					returncode = SQLBindCol(hstmt,1,SQL_C_CHAR,oTableQualifier,NAME_LEN,&oTableQualifierlen);
					if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol"))
					{
						LogAllErrors(henv,hdbc,hstmt);
						TEST_FAILED;
					} 
					returncode = SQLBindCol(hstmt,2,SQL_C_CHAR,oTableOwner,NAME_LEN,&oTableOwnerlen);
					if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol"))
					{
						LogAllErrors(henv,hdbc,hstmt);
						TEST_FAILED;
					}
					returncode = SQLBindCol(hstmt,3,SQL_C_CHAR,oTableName,NAME_LEN,&oTableNamelen);
					if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol"))
					{
						LogAllErrors(henv,hdbc,hstmt);
						TEST_FAILED;
					}
					returncode = SQLBindCol(hstmt,4,SQL_C_CHAR,oGrantor,NAME_LEN,&oGrantorlen);
					if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol"))
					{
						LogAllErrors(henv,hdbc,hstmt);
						TEST_FAILED;
					}
					returncode = SQLBindCol(hstmt,5,SQL_C_CHAR,oGrantee,NAME_LEN,&oGranteelen);
					if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol"))
					{
						LogAllErrors(henv,hdbc,hstmt);
						TEST_FAILED;
					}
					returncode = SQLBindCol(hstmt,6,SQL_C_CHAR,oPrivilege,NAME_LEN,&oPrivilegelen);
					if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol"))
					{
						LogAllErrors(henv,hdbc,hstmt);
						TEST_FAILED;
					}
					returncode = SQLBindCol(hstmt,7,SQL_C_CHAR,oIs_Grantable,NAME_LEN,&oIs_Grantablelen);
					if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol"))
					{
						LogAllErrors(henv,hdbc,hstmt);
						TEST_FAILED;
					}
					
					
					// Loop, reading and checking all data retuned from SQLTablePrivileges call
					k = 0;
					while (returncode == SQL_SUCCESS)
					{
						returncode = SQLFetch(hstmt);
						if((returncode!=SQL_NO_DATA_FOUND) && (!CHECKRC(SQL_SUCCESS,returncode,"SQLFetch")))
						{
							LogAllErrors(henv,hdbc,hstmt);
							TEST_FAILED;
						}
						else 
						{
							// check for SQL_SUCCESS in case SQL_NO_DATA_FOUND was what was returned
							// compare results for rows where oGrantor is not the same as Grantor (super.super)
							if ((returncode == SQL_SUCCESS) && (_stricmp(Grantor,oGrantor) == 0) && (_stricmp(TableCol[i].Grantee,oGrantee) == 0))
							{
								k++;	// found a match, increment counter
								if ((_stricmp(TableQualifier,oTableQualifier) == 0) 
									&& (cstrcmp(TableOwner,oTableOwner,TRUE,isCharSet) == 0) 
									&& (cstrcmp(TableName,oTableName,TRUE,isCharSet) == 0) 
									//&& (_stricmp(oGrantor,Grantor) == 0) 
									//&& (_stricmp(TableCol[i].Grantee,oGrantee) == 0) // NOT NEEDED
									&& (strstr(TableCol[i].Privilege,oPrivilege) != NULL) 
									&& (_stricmp(TableCol[i].Is_Grantable,oIs_Grantable) == 0) )
								{
									LogMsg(NONE,"SQLTablePrivileges: compare results of rows fetched for following column.\n");
									LogMsg(NONE,"TableQualifier expect: %s and actual: %s are matched\n",TableQualifier,oTableQualifier);
									LogMsg(NONE,"TableOwner expect: %s and actual: %s are matched\n",TableOwner,oTableOwner);
									LogMsg(NONE,"TableName expect: %s and actual: %s are matched\n",TableName,oTableName);
									LogMsg(NONE,"Grantor expect: %s and actual: %s are matched\n",Grantor,oGrantor);
									LogMsg(NONE,"Grantee expect: %s and actual: %s are matched\n",TableCol[i].Grantee,oGrantee);
									LogMsg(NONE,"Privilege expect: %s and actual: %s are matched\n",TableCol[i].Privilege,oPrivilege);
									LogMsg(NONE,"Is_Grantable expect: %s and actual: %s are matched\n",TableCol[i].Is_Grantable,oIs_Grantable);
								}
								else
								{
									TEST_FAILED;	
									LogMsg(NONE,"SQLTablePrivileges: compare results of rows fetched for following column failed line %d.\n", __LINE__);
									if (_stricmp(TableQualifier,oTableQualifier) != 0)
										LogMsg(ERRMSG,"TableQualifier expect: %s and actual: %s are not matched\n",TableQualifier,oTableQualifier);
									if (cstrcmp(TableOwner,oTableOwner,TRUE,isCharSet) != 0) 
										LogMsg(ERRMSG,"TableOwner expect: %s and actual: %s are not matched\n",TableOwner,oTableOwner);
									if (cstrcmp(TableName,oTableName,TRUE,isCharSet) != 0) 
										LogMsg(ERRMSG,"TableName expect: %s and actual: %s are not matched\n",TableName,oTableName);
									//if (_stricmp(oGrantor,Grantor) != 0)
									//	LogMsg(ERRMSG,"Grantor expect: %s and actual: %s are not matched\n",Grantor,oGrantor);
									//if (_stricmp(TableCol[i].Grantee,oGrantee) != 0)
									//	LogMsg(ERRMSG,"Grantee expect: %s and actual: %s are not matched\n",TableCol[i].Grantee,oGrantee);
									if (strstr(TableCol[i].Privilege,oPrivilege) == NULL)
										LogMsg(ERRMSG,"Privilege expect: %s and actual: %s are not matched\n",TableCol[i].Privilege,oPrivilege);
									if (_stricmp(TableCol[i].Is_Grantable,oIs_Grantable) != 0)
										LogMsg(ERRMSG,"Is_Grantable expect: %s and actual: %s are not matched\n",TableCol[i].Is_Grantable,oIs_Grantable);
								}
							}
						}
					}
					if(k == 0){
						TEST_FAILED;
						LogMsg(ERRMSG,"No matching grantee record for '%s' found\n"
										  "   At least one row fetched should have matched\n",
										  TableCol[i].Grantee);
						}
					SQLFreeStmt(hstmt,SQL_UNBIND);
					SQLFreeStmt(hstmt,SQL_CLOSE);
				}
			}
		}
		TESTCASE_END;
		
		// clean up SQL table
		sprintf(TableStr,"drop table %s",TableName);
		SQLExecDirect(hstmt,(SQLCHAR*) TableStr,SQL_NTS);
		i++;
	} 

//=======================================================================================

	i = 0;
	sprintf(TableStr,"drop table %s.%s.%s",ColumnWC[i].TabQua, ColumnWC[i].TabOwner, ColumnWC[i].TabName);
	SQLExecDirect(hstmt,(SQLCHAR*) TableStr,SQL_NTS);
	LogMsg(NONE,"%s\n",TableStr);
	sprintf(TableStr,"drop schema %s.%s cascade",ColumnWC[i].TabQua, ColumnWC[i].TabOwner);
	SQLExecDirect(hstmt,(SQLCHAR*) TableStr,SQL_NTS);
	LogMsg(NONE,"%s\n",TableStr);

	sprintf(TableStr,"create schema %s.%s",ColumnWC[i].TabQua, ColumnWC[i].TabOwner);
	LogMsg(NONE,"%s\n",TableStr);
	returncode = SQLExecDirect(hstmt,(SQLCHAR*) TableStr,SQL_NTS);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect"))
	{
		LogAllErrors(henv,hdbc,hstmt);
		TEST_FAILED;
	}
	else
	{
		sprintf(TableStr,"create table %s.%s.%s(%s char(10)) no partition;",ColumnWC[i].TabQua, ColumnWC[i].TabOwner, ColumnWC[i].TabName, TestColumn);
		returncode = SQLExecDirect(hstmt,(SQLCHAR*) TableStr,SQL_NTS);
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect"))
		{
			LogAllErrors(henv,hdbc,hstmt);
			TEST_FAILED;
		}
	}
	LogMsg(NONE,"%s\n",TableStr);
	returncode = SQLSetStmtAttr(hstmt,SQL_ATTR_METADATA_ID,(SQLPOINTER)SQL_FALSE,0);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLSetStmtAttr"))
	{
		TEST_FAILED;
		LogAllErrors(henv,hdbc,hstmt);
	}// end of setup
	if (returncode == SQL_SUCCESS) 
	{
		while ((_stricmp(ColumnWC[i].TabQua,"endloop") != 0) && (ColumnWC[i].isEscape == 0))
		{
			sprintf(Heading,"SQLTablePrivileges: wildcard options => \n"
				"Table Qualifier: %s \nTable Owner: %s \nTable Name: %s\n", 
				printSymbol(ColumnWC[i].TabQua,displayBuf.cat), 
				printSymbol(ColumnWC[i].TabOwner,displayBuf.sch), 
				printSymbol(ColumnWC[i].TabName,displayBuf.tab));
			TESTCASE_BEGIN(Heading);
			if (_stricmp(ColumnWC[i].TabQua,"NULL") == 0)
				ColumnWC[i].TabQua = NULL;
			if (_stricmp(ColumnWC[i].TabOwner,"NULL") == 0)
				ColumnWC[i].TabOwner = NULL;
			if (_stricmp(ColumnWC[i].TabName,"NULL") == 0)
				ColumnWC[i].TabName = NULL;

			if (ColumnWC[i].TabQua == NULL || ColumnWC[i].TabOwner == NULL || ColumnWC[i].TabName == NULL)
				returncode = SQLTablePrivileges(hstmt,(SQLCHAR*)ColumnWC[i].TabQua,SQL_NTS,
                                                      (SQLCHAR*)ColumnWC[i].TabOwner,SQL_NTS,
                                                      (SQLCHAR*)removeQuotes(ColumnWC[i].TabName,displayBuf.tab),SQL_NTS);
			else
				returncode = SQLTablePrivileges(hstmt,(SQLCHAR*)ColumnWC[i].TabQua,(SWORD)strlen(ColumnWC[i].TabQua),
                                                      (SQLCHAR*)ColumnWC[i].TabOwner,(SWORD)strlen(ColumnWC[i].TabOwner),
                                                      (SQLCHAR*)removeQuotes(ColumnWC[i].TabName,displayBuf.tab),(SWORD)strlen(displayBuf.tab));
			if(!CHECKRC(SQL_SUCCESS,returncode,"SQLTablePrivileges"))
			{
				TEST_FAILED;
				LogAllErrors(henv,hdbc,hstmt);
			}
			else
			{
				LogMsg(NONE,"SQLTablePrivileges: SQLTablePrivileges function call executed correctly.\n");
				strcpy(oTableQualifier,"");
				strcpy(oTableOwner,"");
				strcpy(oTableName,"");
				strcpy(oGrantor,"");
				strcpy(oGrantee,"");
				strcpy(oPrivilege,"");
				strcpy(oIs_Grantable,"");
				returncode = SQLBindCol(hstmt,1,SQL_C_CHAR,oTableQualifier,NAME_LEN,&oTableQualifierlen);
				if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol"))
				{
						LogAllErrors(henv,hdbc,hstmt);
						TEST_FAILED;
				} 
				returncode = SQLBindCol(hstmt,2,SQL_C_CHAR,oTableOwner,NAME_LEN,&oTableOwnerlen);
				if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol"))
				{
						LogAllErrors(henv,hdbc,hstmt);
						TEST_FAILED;
				}
				returncode = SQLBindCol(hstmt,3,SQL_C_CHAR,oTableName,NAME_LEN,&oTableNamelen);
				if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol"))
				{
						LogAllErrors(henv,hdbc,hstmt);
						TEST_FAILED;
				}

				returncode = SQLBindCol(hstmt,4,SQL_C_CHAR,oGrantor,NAME_LEN,&oGrantorlen);
				if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol"))
				{
						LogAllErrors(henv,hdbc,hstmt);
						TEST_FAILED;
				}
				returncode = SQLBindCol(hstmt,5,SQL_C_CHAR,oGrantee,NAME_LEN,&oGranteelen);
				if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol"))
				{
						LogAllErrors(henv,hdbc,hstmt);
						TEST_FAILED;
				}
				
				returncode = SQLBindCol(hstmt,6,SQL_C_CHAR,oPrivilege,NAME_LEN,&oPrivilegelen);
				if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol"))
				{
						LogAllErrors(henv,hdbc,hstmt);
						TEST_FAILED;
				}
				returncode = SQLBindCol(hstmt,7,SQL_C_CHAR,oIs_Grantable,NAME_LEN,&oIs_Grantablelen);
				if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol"))
				{
						LogAllErrors(henv,hdbc,hstmt);
						TEST_FAILED;
				}
				k = 0;
				while (returncode == SQL_SUCCESS) 
				{
					returncode = SQLFetch(hstmt);
					if((returncode!=SQL_NO_DATA_FOUND) && (!CHECKRC(SQL_SUCCESS,returncode,"SQLFetch")))
					{
						TEST_FAILED;
						LogAllErrors(henv,hdbc,hstmt);
					}
					if (returncode == SQL_SUCCESS)
						k++;
				}
				if(k == 0 && ColumnWC[i].CheckCode == SQL_SUCCESS)
				{
					if(ColumnWC[i].isEscape == 1)
						LogMsg(ERRMSG, "Search string pattern in Catalog's Name is not supported\n");
					else {
						TEST_FAILED;
						LogMsg(ERRMSG,"No Data Found => Atleast one row should be fetched\n");
					}
				}
			}
			SQLFreeStmt(hstmt,SQL_CLOSE);
			TESTCASE_END;
			i++;
		}
	}

//======================================================================================================

	TESTCASE_BEGIN("SQLTablePrivileges: Negative test with invalid handle.\n");

	i = 0;
	returncode = SQLTablePrivileges(hstmt1,(SQLCHAR*)ColumnWC[i].TabQua,(SWORD)strlen(ColumnWC[i].TabQua),(SQLCHAR*)ColumnWC[i].TabOwner,(SWORD)strlen(ColumnWC[i].TabOwner),(SQLCHAR*)ColumnWC[i].TabName,(SWORD)strlen(ColumnWC[i].TabName));
	if(!CHECKRC(SQL_INVALID_HANDLE,returncode,"SQLTables"))
	{
		TEST_FAILED;
		LogAllErrors(henv,hdbc,hstmt);
	}
	TESTCASE_END;

//=========================================================================================

	TESTCASE_BEGIN("SQLTables: Negative test with NULL handle.\n");

	hstmt1 = (SQLHANDLE)NULL;
	i = 0;
	returncode = SQLTablePrivileges(hstmt1,(SQLCHAR*)ColumnWC[i].TabQua,(SWORD)strlen(ColumnWC[i].TabQua),(SQLCHAR*)ColumnWC[i].TabOwner,(SWORD)strlen(ColumnWC[i].TabOwner),(SQLCHAR*)ColumnWC[i].TabName,(SWORD)strlen(ColumnWC[i].TabName));
	if(!CHECKRC(SQL_INVALID_HANDLE,returncode,"SQLTables"))
	{
		TEST_FAILED;
		LogAllErrors(henv,hdbc,hstmt);
	}
	TESTCASE_END;

//=========================================================================================

	TESTCASE_BEGIN("SQLTablePrivileges: Negative test with invalid arg lengths.\n");

	returncode = SQLTablePrivileges(hstmt,(SQLCHAR*)ColumnWC2[0].TabQua,ColumnWC2[0].TabQuaLen,(SQLCHAR*)ColumnWC2[0].TabOwner,ColumnWC2[0].TabOwnerLen,(SQLCHAR*)ColumnWC2[0].TabName,ColumnWC2[0].TabNameLen);
	LogMsg(NONE, "Input parameters: CatalogLen %d SchemaLen %d TableLen %d\n", ColumnWC2[0].TabQuaLen, ColumnWC2[0].TabOwnerLen, ColumnWC2[0].TabNameLen);
	if(!CHECKRC(SQL_ERROR,returncode,"SQLTablePrivileges"))
	{
		TEST_FAILED;
		LogAllErrors(henv,hdbc,hstmt);
	}

	TESTCASE_END;

//=========================================================================================

	TESTCASE_BEGIN("SQLTablePrivileges: Positive test with invalid arg lengths.\n");

	returncode = SQLTablePrivileges(hstmt,(SQLCHAR*)ColumnWC2[1].TabQua,ColumnWC2[1].TabQuaLen,(SQLCHAR*)ColumnWC2[1].TabOwner,ColumnWC2[1].TabOwnerLen,(SQLCHAR*)ColumnWC2[1].TabName,ColumnWC2[1].TabNameLen);
	LogMsg(NONE, "Input parameters: CatalogLen %d SchemaLen %d TableLen %d\n", ColumnWC2[1].TabQuaLen, ColumnWC2[1].TabOwnerLen, ColumnWC2[1].TabNameLen);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLTablePrivileges"))
	{
		TEST_FAILED;
		LogAllErrors(henv,hdbc,hstmt);
	}
	else {
		LogMsg(NONE,"SQLTablePrivileges: SQLTablePrivileges function call executed correctly.\n");
		strcpy(oTableQualifier,"");
		strcpy(oTableOwner,"");
		strcpy(oTableName,"");
		strcpy(oGrantor,"");
		strcpy(oGrantee,"");
		strcpy(oPrivilege,"");
		strcpy(oIs_Grantable,"");
		returncode = SQLBindCol(hstmt,1,SQL_C_CHAR,oTableQualifier,NAME_LEN,&oTableQualifierlen);
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol"))
		{
				LogAllErrors(henv,hdbc,hstmt);
				TEST_FAILED;
		} 
		returncode = SQLBindCol(hstmt,2,SQL_C_CHAR,oTableOwner,NAME_LEN,&oTableOwnerlen);
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol"))
		{
				LogAllErrors(henv,hdbc,hstmt);
				TEST_FAILED;
		}
		returncode = SQLBindCol(hstmt,3,SQL_C_CHAR,oTableName,NAME_LEN,&oTableNamelen);
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol"))
		{
				LogAllErrors(henv,hdbc,hstmt);
				TEST_FAILED;
		}
		returncode = SQLBindCol(hstmt,4,SQL_C_CHAR,oGrantor,NAME_LEN,&oGrantorlen);
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol"))
		{
				LogAllErrors(henv,hdbc,hstmt);
				TEST_FAILED;
		}
		returncode = SQLBindCol(hstmt,5,SQL_C_CHAR,oGrantee,NAME_LEN,&oGranteelen);
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol"))
		{
				LogAllErrors(henv,hdbc,hstmt);
				TEST_FAILED;
		}
		
		returncode = SQLBindCol(hstmt,6,SQL_C_CHAR,oPrivilege,NAME_LEN,&oPrivilegelen);
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol"))
		{
				LogAllErrors(henv,hdbc,hstmt);
				TEST_FAILED;
		}
		returncode = SQLBindCol(hstmt,7,SQL_C_CHAR,oIs_Grantable,NAME_LEN,&oIs_Grantablelen);
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol"))
		{
				LogAllErrors(henv,hdbc,hstmt);
				TEST_FAILED;
		}
		k = 0;
		while (returncode == SQL_SUCCESS) 
		{
			returncode = SQLFetch(hstmt);
			if (returncode == SQL_SUCCESS) k++;
		}
		if(k > 0)
		{
			TEST_FAILED;
			LogMsg(ERRMSG,"Should be no data found - check for similar objects unintentionally appear\n");
		}
	}

	TESTCASE_END;

//=========================================================================================

	TESTCASE_BEGIN("Testing SQLColAttribute, SQLDescribeCol, SQLBindCol and SQLFetch functions for catalog names.\n");

	returncode = SQLSetStmtAttr(hstmt,SQL_ATTR_METADATA_ID,(SQLPOINTER)SQL_FALSE,0);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLSetStmtAttr"))
	{
		TEST_FAILED;
		LogAllErrors(henv,hdbc,hstmt);
	}// end of setup

	for(i = 0; i < 5; i++)
	{
		sprintf(Heading,"======================================\n"
						"SQLTablePrivileges: wildcard options => \n"
						"Table Qualifier: %s \nTable Owner: %s \nTable Name: %s\n", 
						printSymbol(ColumnWC[i].TabQua,displayBuf.cat), 
						printSymbol(ColumnWC[i].TabOwner,displayBuf.sch), 
						printSymbol(ColumnWC[i].TabName,displayBuf.tab));
		LogMsg(NONE,Heading);

		returncode = SQLTablePrivileges(hstmt,(SQLCHAR*)ColumnWC[i].TabQua,(SWORD)strlen(ColumnWC[i].TabQua),
											  (SQLCHAR*)removeQuotes(ColumnWC[i].TabOwner, displayBuf.sch),(SWORD)strlen(displayBuf.sch),
											  (SQLCHAR*)removeQuotes(ColumnWC[i].TabName, displayBuf.tab),(SWORD)strlen(displayBuf.tab));
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLColumns"))
		{
			TEST_FAILED;
			LogAllErrors(henv,hdbc,hstmt);
		}
		LogMsg(NONE,"after the call\n");

		returncode = SQLNumResultCols(hstmt, &numOfCols);
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLNumResultsCol"))
		{
			TEST_FAILED;
			LogMsg(ERRMSG,"Test failed while executing call for SQLNUMRESULTSCOL");
			LogAllErrors(henv,hdbc,hstmt);
		}
		for(cols = 0; cols < numOfCols; cols++)
		{
			returncode = SQLDescribeCol(hstmt,(SWORD)(cols+1),(SQLCHAR*)cn,COLNAME_LEN,&cl,&st,&cp,&cs,&cnull);
			if(!CHECKRC(SQL_SUCCESS,returncode,"SQLDescribeCol"))
			{
				TEST_FAILED;
				LogMsg(ERRMSG,"Test failed while executing call for SQLDESCRIBECOL of column");
				LogAllErrors(henv,hdbc,hstmt);
			}
			CharOutput[cols] = (char *)malloc(STR_LEN);
			for (iatt = 0; iatt <= TOTALATTRIBS; iatt++)
			{
				strcpy(rgbDesc,"");
				pcbDesc = 0;
				pfDesc = 0;
				returncode = SQLColAttributes(hstmt,(SWORD)(cols+1),DescrType[iatt],rgbDesc,STR_LEN,&pcbDesc,&pfDesc);
				if(!CHECKRC(SQL_SUCCESS,returncode,"SQLColAttribute"))
				{
					TEST_FAILED;
					LogMsg(ERRMSG,"Test failed while executing call for SQLCOLATTRIBUTES of column : %d.\n",i+1);
					LogAllErrors(henv,hdbc,hstmt);
				}
			}
			returncode = SQLBindCol(hstmt,(SWORD)(cols+1),SQL_C_CHAR,CharOutput[cols],STR_LEN,&stringlength);
			if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol"))
			{
				TEST_FAILED;
				LogMsg(ERRMSG,"Test failed while executing call for SQLBindCols of column : %d.\n",cols);
				LogAllErrors(henv,hdbc,hstmt);
			}
		}

		k = 0;
		while (returncode == SQL_SUCCESS)
		{
			returncode = SQLFetch(hstmt);
			if(returncode == SQL_ERROR)
			{
				LogAllErrors(henv,hdbc,hstmt);
				TEST_FAILED;
			} else if (returncode == SQL_NO_DATA_FOUND) {
				break;
			}
			else {
				if (returncode == SQL_SUCCESS_WITH_INFO)
					LogAllErrors(henv,hdbc,hstmt);
				k++;
			}
		}
		if(k == 0)
		{
			TEST_FAILED;
			LogMsg(ERRMSG,"No Data Found => Atleast one row should be fetched\n");
		}
		
		for(cols = 0; cols < numOfCols; cols++)
		{
			free(CharOutput[cols]);
		}
		TESTCASE_END;
	}

//=========================================================================================
	// Cleanup
	i=0;
	sprintf(TableStr,"drop table %s.%s.%s",ColumnWC[i].TabQua, ColumnWC[i].TabOwner, ColumnWC[i].TabName);
	SQLExecDirect(hstmt,(SQLCHAR*) TableStr,SQL_NTS);
	sprintf(TableStr,"drop schema %s.%s cascade",ColumnWC[i].TabQua, ColumnWC[i].TabOwner);
	SQLExecDirect(hstmt,(SQLCHAR*) TableStr,SQL_NTS);

	FullDisconnect3(pTestInfo);
	LogMsg(SHORTTIMESTAMP+LINEAFTER,"End testing API => SQLTablePrivileges.\n");
	free(TableStr); 
	free_list(var_list);
	TEST_RETURN;
}
Beispiel #5
0
PassFail TestSQLPrepare(TestInfo *pTestInfo)
{   
	TEST_DECLARE;

 	char			Heading[MAX_STRING_SIZE];
 	RETCODE			returncode;
 	SQLHANDLE 		henv;
 	SQLHANDLE 		hdbc;
 	SQLHANDLE		hstmt;
	CHAR			*PrepStr[6];

	CHAR			*szInput[] = {"Insert char","Insert varchar"};
	SQLLEN	cbInput = SQL_NTS;
	SQLUSMALLINT	i;
	SQLSMALLINT	Type[] = {SQL_CHAR,SQL_VARCHAR};

//===========================================================================================================
	var_list_t *var_list;
	var_list = load_api_vars("SQLPrepare", charset_file);
	if (var_list == NULL) return FAILED;

	PrepStr[0] = var_mapping("SQLPrepare_PrepStr_0", var_list);
	PrepStr[1] = var_mapping("SQLPrepare_PrepStr_1", var_list);
	PrepStr[2] = var_mapping("SQLPrepare_PrepStr_2", var_list);
	PrepStr[3] = var_mapping("SQLPrepare_PrepStr_3", var_list);
	PrepStr[4] = var_mapping("SQLPrepare_PrepStr_4", var_list);
	PrepStr[5] = var_mapping("SQLPrepare_PrepStr_5", var_list);
//===========================================================================================================

	LogMsg(LINEBEFORE+SHORTTIMESTAMP,"Begin testing API =>SQLPrepare | SQLPrepare | prepare.c\n");

	TEST_INIT;

	TESTCASE_BEGIN("Setup for SQLPrepare tests\n");

	if(!FullConnect(pTestInfo)){
		LogMsg(NONE,"Unable to connect\n");
		TEST_FAILED;
		TEST_RETURN;
	}

	henv = pTestInfo->henv;
 	hdbc = pTestInfo->hdbc;
 	hstmt = (SQLHANDLE)pTestInfo->hstmt;
   	
	returncode = SQLAllocStmt((SQLHANDLE)hdbc, &hstmt);	
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLAllocStmt")){
		LogAllErrors(henv,hdbc,hstmt);
		TEST_FAILED;
		TEST_RETURN;
		}

	TESTCASE_END;  // end of setup

	TESTCASE_BEGIN("Test Positive Functionality of SQLPrepare/SQLExecute\n");
	returncode=SQLExecDirect(hstmt,(SQLCHAR*)PrepStr[0],strlen(PrepStr[0])); /* cleanup */
	returncode = SQLPrepare(hstmt,(SQLCHAR*)PrepStr[1],strlen(PrepStr[1]));
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLPrepare"))
	{
		TEST_FAILED;
		LogAllErrors(henv,hdbc,hstmt);
	}
	else
	{
		returncode = SQLExecute(hstmt); 
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecute"))
		{
			TEST_FAILED;
			LogAllErrors(henv,hdbc,hstmt);
		}
	}	
	TESTCASE_END;

	sprintf(Heading,"Test Positive Functionality of SQLPrepare/SQLExecute with SQL_NTS\n");
	TESTCASE_BEGIN(Heading);
	returncode=SQLExecDirect(hstmt,(SQLCHAR*)PrepStr[0],SQL_NTS);	/* cleanup */
	returncode = SQLPrepare(hstmt,(SQLCHAR*)PrepStr[1],SQL_NTS);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLPrepare"))
	{
		TEST_FAILED;
		LogAllErrors(henv,hdbc,hstmt);
	}
	else
	{
		returncode = SQLExecute(hstmt); 
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecute"))
		{
			TEST_FAILED;
			LogAllErrors(henv,hdbc,hstmt);
		}
	}	
	TESTCASE_END;

	sprintf(Heading,"Test Positive Functionality of SQLPrepare then SQLExecute twice\n");
	TESTCASE_BEGIN(Heading);
	returncode = SQLPrepare(hstmt,(SQLCHAR*)PrepStr[2],strlen(PrepStr[2]));
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLPrepare"))
	{
		TEST_FAILED;
		LogAllErrors(henv,hdbc,hstmt);
	}
	else
	{
		returncode = SQLExecute(hstmt); 
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecute"))
		{
			TEST_FAILED;
			LogAllErrors(henv,hdbc,hstmt);
		}
		returncode = SQLExecute(hstmt); 
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecute"))
		{
			TEST_FAILED;
			LogAllErrors(henv,hdbc,hstmt);
		}
	}	
	SQLExecDirect(hstmt,(SQLCHAR*)PrepStr[0],strlen(PrepStr[0])); /* cleanup */
	TESTCASE_END;
		
	sprintf(Heading,"Test Positive Functionality of SQLPrepare with params\n");
	TESTCASE_BEGIN(Heading);
	SQLExecDirect(hstmt,(SQLCHAR*)PrepStr[3],SQL_NTS); /* cleanup */
	returncode = SQLPrepare(hstmt,(SQLCHAR*)PrepStr[4],SQL_NTS);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLPrepare"))
	{
		TEST_FAILED;
		LogAllErrors(henv,hdbc,hstmt);
	}
	else
	{
		for (i = 0; i <= 1; i++)
		{
			returncode = SQLBindParameter(hstmt,(SWORD)(i+1),SQL_PARAM_INPUT,SQL_C_CHAR,Type[i],PREP_LEN,0,szInput[i],0,&cbInput);
			if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindParameter"))
			{
				TEST_FAILED;
				LogAllErrors(henv,hdbc,hstmt);
			}
		}
		returncode = SQLExecute(hstmt); 
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecute"))
		{
			TEST_FAILED;
			LogAllErrors(henv,hdbc,hstmt);
		}
	}	
	SQLExecDirect(hstmt,(SQLCHAR*)PrepStr[3],SQL_NTS); /* cleanup */
	TESTCASE_END;

	sprintf(Heading,"Test negative Functionality of SQLPrepare with strlen less than sqlstr\n");
	TESTCASE_BEGIN(Heading);
	SQLExecDirect(hstmt,(SQLCHAR*)PrepStr[0],SQL_NTS); /* cleanup */
	returncode = SQLPrepare(hstmt,(SQLCHAR*)PrepStr[1],(strlen(PrepStr[1])-5));
	if(!CHECKRC(SQL_ERROR,returncode,"SQLPrepare"))
	{
		TEST_FAILED;
		LogAllErrors(henv,hdbc,hstmt);
	}
	TESTCASE_END;

	sprintf(Heading,"Test negative Functionality of SQLPrepare with invalid sqlstr\n");
	TESTCASE_BEGIN(Heading);
	returncode = SQLPrepare(hstmt,NULL,strlen(PrepStr[2]));
	if(!CHECKRC(SQL_ERROR,returncode,"SQLPrepare"))
	{
		TEST_FAILED;
		LogAllErrors(henv,hdbc,hstmt);
	}
	TESTCASE_END;

	sprintf(Heading,"Test negative Functionality of SQLPrepare with invalid handle\n");
	TESTCASE_BEGIN(Heading);
	returncode = SQLPrepare((SQLHANDLE)NULL,(SQLCHAR*)PrepStr[2],strlen(PrepStr[2]));
	if(!CHECKRC(SQL_INVALID_HANDLE,returncode,"SQLPrepare"))
	{
		TEST_FAILED;
		LogAllErrors(henv,hdbc,hstmt);
	}
	TESTCASE_END;

	FullDisconnect(pTestInfo);
	LogMsg(SHORTTIMESTAMP+LINEAFTER,"End testing API => SQLPrepare.\n");

	free_list(var_list);

	TEST_RETURN;
}
Beispiel #6
0
/*
---------------------------------------------------------
   TestSQLProcedureColumns
---------------------------------------------------------
*/
PassFail TestMXSQLProcedureColumns(TestInfo *pTestInfo)
{                  
	TEST_DECLARE;
 	TCHAR			Heading[MAX_HEADING_SIZE];
 	RETCODE			returncode;
 	SQLHANDLE 		henv;
 	SQLHANDLE 		hdbc;
 	SQLHANDLE		hstmt;
	TCHAR			*ProcStr;
  	TCHAR			ProcCatalog[NAME_LEN],ProcSchema[NAME_LEN],ProcName[NAME_LEN];
    TCHAR           ColName[NAME_LEN];
/* SEAQUEST */
char                    tmpbuf[1024];
TCHAR                   *myTestSch;
TCHAR                   *createSchStr;
TCHAR                   *setSchStr;
TCHAR                   *dropSchStr;
/* end of SEAQUEST */
	TCHAR			oProcCatalog[NAME_LEN];
	TCHAR			oProcSchema[NAME_LEN];
	TCHAR			oProcName[NAME_LEN];
	TCHAR			oColName[NAME_LEN];
	SWORD			oColType;
	SWORD			oColDataType;
	TCHAR			oColTypeName[NAME_LEN];
	SDWORD			oColSize;
	SDWORD			oBufferLen;
	SWORD			oDecDigits;
	SWORD			oColRadix;
	SWORD			oColNullable;
	TCHAR			oRemark[REM_LEN];
	TCHAR			oColDef[NAME_LEN];
	SWORD			oSQLDataType;
	SWORD			oSQLDateTimeSub;
	SDWORD			oCharOctetLen;
	SDWORD			oOrdinalPos;
	TCHAR			oIsNullable[NAME_LEN];
	SQLLEN		oProcCataloglen; // sushil
	SQLLEN		oProcSchemalen;
	SQLLEN		oProcNamelen;
	SQLLEN		oColNamelen;
	SQLLEN		oColTypelen;
	SQLLEN		oColDataTypelen;
	SQLLEN		oColTypeNamelen;
	SQLLEN		oColSizelen;
	SQLLEN		oBufferLenlen;
	SQLLEN		oDecDigitslen;
	SQLLEN		oColRadixlen;
	SQLLEN		oColNullablelen;
	SQLLEN		oRemarklen;
	SQLLEN		oColDeflen;
	SQLLEN		oSQLDataTypelen;
	SQLLEN		oSQLDateTimeSublen;
	SQLLEN		oCharOctetLenlen;
	SQLLEN		oOrdinalPoslen;
	SQLLEN		oIsNullablelen;

	struct	
	{
		TCHAR		*DropProc;
		TCHAR		*CrtProc;
	} CreateProc[] = {
							{_T("DROP PROCEDURE N4210"),
							 _T("CREATE PROCEDURE N4210 (IN IN1 TIME) EXTERNAL NAME 'Procs.N4210' EXTERNAL PATH '/home/SQFQA/SPJRoot/spjrs/nci/spjrs.jar' LANGUAGE JAVA PARAMETER STYLE JAVA NO SQL NO ISOLATE")},
							{_T("DROP PROCEDURE N4260"),
							 _T("CREATE PROCEDURE N4260 (IN IN1 REAL, INOUT INOUT1 INTEGER) EXTERNAL NAME 'Procs.N4260' EXTERNAL PATH '/home/SQFQA/SPJRoot/spjrs/nci/spjrs.jar' LANGUAGE JAVA PARAMETER STYLE JAVA NO SQL NO ISOLATE")},
							{_T("DROP PROCEDURE N4261"),
 							 _T("CREATE PROCEDURE N4261 (IN IN1 NUMERIC, INOUT INOUT1 REAL) EXTERNAL NAME 'Procs.N4261' EXTERNAL PATH '/home/SQFQA/SPJRoot/spjrs/nci/spjrs.jar' LANGUAGE JAVA PARAMETER STYLE JAVA NO SQL NO ISOLATE")},
							{_T("DROP PROCEDURE N4264"),
 							 _T("CREATE PROCEDURE N4264 (IN IN1 VARCHAR(30) CHARACTER SET ISO88591, OUT OUT1 VARCHAR(45) CHARACTER SET ISO88591) EXTERNAL NAME 'Procs.N4264' EXTERNAL PATH '/home/SQFQA/SPJRoot/spjrs/nci/spjrs.jar' LANGUAGE JAVA PARAMETER STYLE JAVA NO SQL NO ISOLATE")},	
							{_T("DROP PROCEDURE N4264A"),
 							 _T("CREATE PROCEDURE N4264A (IN IN1 CHAR(30) CHARACTER SET ISO88591, OUT OUT1 CHAR(45) CHARACTER SET ISO88591) EXTERNAL NAME 'Procs.N4264' EXTERNAL PATH '/home/SQFQA/SPJRoot/spjrs/nci/spjrs.jar' LANGUAGE JAVA PARAMETER STYLE JAVA NO SQL NO ISOLATE")},	
							{_T("DROP PROCEDURE N4264B"),
 							 _T("CREATE PROCEDURE N4264B (IN IN1 VARCHAR(2000) CHARACTER SET ISO88591, OUT OUT1 VARCHAR(2000) CHARACTER SET ISO88591) EXTERNAL NAME 'Procs.N4264' EXTERNAL PATH '/home/SQFQA/SPJRoot/spjrs/nci/spjrs.jar' LANGUAGE JAVA PARAMETER STYLE JAVA NO SQL NO ISOLATE")},	
							{_T("DROP PROCEDURE N4264C"),
 							 _T("CREATE PROCEDURE N4264C (IN IN1 VARCHAR(30) CHARACTER SET UCS2, OUT OUT1 VARCHAR(45) CHARACTER SET UCS2) EXTERNAL NAME 'Procs.N4264' EXTERNAL PATH '/home/SQFQA/SPJRoot/spjrs/nci/spjrs.jar' LANGUAGE JAVA PARAMETER STYLE JAVA NO SQL NO ISOLATE")},	
							{_T("DROP PROCEDURE N4264D"),
 							 _T("CREATE PROCEDURE N4264D (IN IN1 CHAR(30) CHARACTER SET UCS2, OUT OUT1 CHAR(45) CHARACTER SET UCS2) EXTERNAL NAME 'Procs.N4264' EXTERNAL PATH '/home/SQFQA/SPJRoot/spjrs/nci/spjrs.jar' LANGUAGE JAVA PARAMETER STYLE JAVA NO SQL NO ISOLATE")},	
							{_T("DROP PROCEDURE N4264E"),
 							 _T("CREATE PROCEDURE N4264E (IN IN1 VARCHAR(2000) CHARACTER SET UCS2, OUT OUT1 VARCHAR(2000) CHARACTER SET UCS2) EXTERNAL NAME 'Procs.N4264' EXTERNAL PATH '/home/SQFQA/SPJRoot/spjrs/nci/spjrs.jar' LANGUAGE JAVA PARAMETER STYLE JAVA NO SQL NO ISOLATE")},	
							{_T("DROP PROCEDURE N4267"),
 							 _T("CREATE PROCEDURE N4267 (IN IN1 NUMERIC, INOUT INOUT1 REAL) EXTERNAL NAME 'Procs.N4267' EXTERNAL PATH '/home/SQFQA/SPJRoot/spjrs/nci/spjrs.jar' LANGUAGE JAVA PARAMETER STYLE JAVA NO SQL NO ISOLATE")},
							{_T("endloop"),_T("endloop")}
					};

	struct
	{
		TCHAR       *ProcName;
		TCHAR		*ColName;
		SWORD		ColType;
		SWORD		ColDataType;
		TCHAR		*ColTypeName;
		SDWORD		ColSize;
		SDWORD		BufferLen;
		SWORD		DecDigits;
		SWORD		ColRadix;
		SWORD		ColNullable;
		TCHAR		*Remark;
		TCHAR       *ColDef;
		SWORD       SQLDataType;
		SWORD       SQLDateTimeSub;
		SDWORD		CharOctetLen;
		SDWORD		OrdinalPos;
		TCHAR		*IsNullable;
	} ProcCol[] = {
/*		{"N4210", "IN1",	SQL_PARAM_INPUT,		SQL_TYPE_TIME,	"TIME",			8,	 6, 0, <Null>,	SQL_NULLABLE, <Null>, <Null>, 9,	  2, <Null>, 1, "YES"},
		{"N4260", "IN1",	SQL_PARAM_INPUT,		SQL_REAL,		"REAL",			22,  4, 0, 2,		SQL_NULLABLE, <Null>, <Null>, 7, <Null>, <Null>, 1, "YES"},
		{"N4260", "INOUT1", SQL_PARAM_INPUT_OUTPUT, SQL_INTEGER, "INTEGER SIGNED",	10,  4, 0, 10,		SQL_NULLABLE, <Null>, <Null>, 4, <Null>, <Null>, 2, "YES"},
		{"N4261", "IN1",	SQL_PARAM_INPUT,		SQL_NUMERIC, "NUMERIC",			9,  11, 0, 10,		SQL_NULLABLE, <Null>, <Null>, 2, <Null>, <Null>, 1, "YES"},
		{"N4261", "INOUT1", SQL_PARAM_INPUT_OUTPUT, SQL_REAL,	 "REAL",			22,  4, 0, 2,		SQL_NULLABLE, <Null>, <Null>, 7, <Null>, <Null>, 2, "YES"},
		{"N4264", "IN1",	SQL_PARAM_INPUT,		SQL_WVARCHAR, "VARCHAR",			30, 30, 0, <Null>,	SQL_NULLABLE, <Null>, <Null>, 12,<Null>,     30, 1, "YES"},
		{"N4264", "OUT1",	SQL_PARAM_OUTPUT,		SQL_WVARCHAR, "VARCHAR",			45, 45, 0, <Null>,	SQL_NULLABLE, <Null>, <Null>, 12,<Null>,     45, 2, "YES"},
		{"N4267", "IN1",	SQL_PARAM_INPUT,		SQL_NUMERIC, "NUMERIC",			9,  11, 0, 10,		SQL_NULLABLE, <Null>, <Null>, 2, <Null>, <Null>, 1, "YES"},
		{"N4267", "INOUT1", SQL_PARAM_INPUT_OUTPUT, SQL_REAL,	 "REAL",			22,	 4, 0, 2,		SQL_NULLABLE, <Null>, <Null>, 7, <Null>, <Null>, 2, "YES"},
*/
		{_T("N4210"), _T("IN1"),	SQL_PARAM_INPUT,		SQL_TYPE_TIME,	_T("TIME"),			8,	 6, 0, 0,	SQL_NULLABLE, _T(""), _T(""), 9, 2, 0, 1, _T("YES")},
		{_T("N4260"), _T("IN1"),	SQL_PARAM_INPUT,		SQL_REAL,		_T("REAL"),			22,  4, 0, 2,	SQL_NULLABLE, _T(""), _T(""), 7, 0, 0, 1, _T("YES")},
		{_T("N4260"), _T("INOUT1"), SQL_PARAM_INPUT_OUTPUT, SQL_INTEGER,	_T("INTEGER SIGNED"),10,  4, 0, 10,	SQL_NULLABLE, _T(""), _T(""), 4, 0, 0, 2, _T("YES")},
		{_T("N4261"), _T("IN1"),	SQL_PARAM_INPUT,		SQL_NUMERIC,	_T("NUMERIC SIGNED"),9,  11, 0, 10,	SQL_NULLABLE, _T(""), _T(""), 2, 0, 0, 1, _T("YES")},
		{_T("N4261"), _T("INOUT1"), SQL_PARAM_INPUT_OUTPUT, SQL_REAL,		_T("REAL"),			22,  4, 0, 2,	SQL_NULLABLE, _T(""), _T(""), 7, 0, 0, 2, _T("YES")},
		{_T("N4264"), _T("IN1"),	SQL_PARAM_INPUT,		SQL_VARCHAR,	_T("VARCHAR"),		30, 30, 0, 0,	SQL_NULLABLE, _T(""), _T(""), 12,0, 30,1, _T("YES")},
		{_T("N4264"), _T("OUT1"),	SQL_PARAM_OUTPUT,		SQL_VARCHAR,	_T("VARCHAR"),		45, 45, 0, 0,	SQL_NULLABLE, _T(""), _T(""), 12,0, 45,2, _T("YES")},
		{_T("N4264A"), _T("IN1"),	SQL_PARAM_INPUT,		SQL_CHAR,		_T("CHAR"),			30, 30, 0, 0,	SQL_NULLABLE, _T(""), _T(""),  1,0, 30,1, _T("YES")},
		{_T("N4264A"), _T("OUT1"),	SQL_PARAM_OUTPUT,		SQL_CHAR,		_T("CHAR"),			45, 45, 0, 0,	SQL_NULLABLE, _T(""), _T(""),  1,0, 45,2, _T("YES")},
		{_T("N4264B"), _T("IN1"),	SQL_PARAM_INPUT,		SQL_VARCHAR, _T("VARCHAR"),2000,2000,0,0,	SQL_NULLABLE, _T(""), _T(""), 12,0,2000,1, _T("YES")},
		{_T("N4264B"), _T("OUT1"),	SQL_PARAM_OUTPUT,		SQL_VARCHAR, _T("VARCHAR"),2000,2000,0,0,	SQL_NULLABLE, _T(""), _T(""), 12,0,2000,2, _T("YES")},
		{_T("N4264C"), _T("IN1"),	SQL_PARAM_INPUT,		SQL_WVARCHAR,	_T("NCHAR VARYING"),30, 60, 0, 0,	SQL_NULLABLE, _T(""), _T(""), -9,0, 60,1, _T("YES")},
		{_T("N4264C"), _T("OUT1"),	SQL_PARAM_OUTPUT,		SQL_WVARCHAR,	_T("NCHAR VARYING"),45, 90, 0, 0,	SQL_NULLABLE, _T(""), _T(""), -9,0, 90,2, _T("YES")},
		{_T("N4264D"), _T("IN1"),	SQL_PARAM_INPUT,		SQL_WCHAR,		_T("NCHAR"),		30, 60, 0, 0,	SQL_NULLABLE, _T(""), _T(""), -8,0, 60,1, _T("YES")},
		{_T("N4264D"), _T("OUT1"),	SQL_PARAM_OUTPUT,		SQL_WCHAR,		_T("NCHAR"),		45, 90, 0, 0,	SQL_NULLABLE, _T(""), _T(""), -8,0, 90,2, _T("YES")},
		{_T("N4264E"), _T("IN1"),	SQL_PARAM_INPUT,		SQL_WVARCHAR,_T("NCHAR VARYING"),2000,4000,0,0,	SQL_NULLABLE, _T(""), _T(""),-9,0,4000,1, _T("YES")},
		{_T("N4264E"), _T("OUT1"),	SQL_PARAM_OUTPUT,		SQL_WVARCHAR,_T("NCHAR VARYING"),2000,4000,0,0,	SQL_NULLABLE, _T(""), _T(""),-9,0,4000,2, _T("YES")},
		{_T("N4267"), _T("IN1"),	SQL_PARAM_INPUT,		SQL_NUMERIC,	_T("NUMERIC SIGNED"),9,  11, 0, 10,	SQL_NULLABLE, _T(""), _T(""), 2, 0, 0, 1, _T("YES")},
		{_T("N4267"), _T("INOUT1"), SQL_PARAM_INPUT_OUTPUT, SQL_REAL,		_T("REAL"),			22,	 4, 0, 2,	SQL_NULLABLE, _T(""), _T(""), 7, 0, 0, 2, _T("YES")},
		{_T("endloop"),}
	};

	
	int	i = 0, k = 0;
	TCHAR	State[STATE_SIZE];
	SDWORD	NativeError;
	TCHAR	buf[MAX_STRING_SIZE];
	//TCHAR	*charNameUCS2 = _T("NCHAR");
	//TCHAR	*varcharNameUCS2 = _T("NCHAR VARYING");
	
	LogMsg(SHORTTIMESTAMP,_T("Begin testing API => MX Specific SQLProcedureColumns.\n"));

//=================================================================================================
	//if(isUCS2) {
	//	LogMsg(LINEBEFORE,_T("Setup for UCS2 mode testing: ColSize,BufferLen and CharOctetlen has to be doubled\n"));

	//	k = sizeof(ProcCol)/sizeof(ProcCol[0]);
	//	while(i < k) {
	//		if(ProcCol[i].ColDataType == SQL_WCHAR)
	//		{
	//			ProcCol[i].ColDataType = SQL_WCHAR;
	//			ProcCol[i].SQLDataType = SQL_WCHAR;
	//			ProcCol[i].ColTypeName = charNameUCS2;
	//			//ProcCol[i].ColSize *= 2;  --> This is in character, no need to double
	//			ProcCol[i].BufferLen *= 2;
	//			ProcCol[i].CharOctetLen *= 2;
	//		}
	//		else if (ProcCol[i].ColDataType == SQL_WVARCHAR)
	//		{
	//			ProcCol[i].ColDataType = SQL_WVARCHAR;
	//			ProcCol[i].SQLDataType = SQL_WVARCHAR;
	//			ProcCol[i].ColTypeName = varcharNameUCS2;
	//			//ProcCol[i].ColSize *= 2; --> This is in character, no need to double
	//			ProcCol[i].BufferLen *= 2;
	//			ProcCol[i].CharOctetLen *= 2;
	//		}
	//		else if (ProcCol[i].ColDataType == SQL_WLONGVARCHAR)
	//		{
	//			ProcCol[i].ColDataType = SQL_WLONGVARCHAR;
	//			ProcCol[i].SQLDataType = SQL_WLONGVARCHAR;
	//			ProcCol[i].ColTypeName = varcharNameUCS2;
	//			//ProcCol[i].ColSize *= 2; --> This is in character, no need to double
	//			ProcCol[i].BufferLen *= 2;
	//			ProcCol[i].CharOctetLen *= 2;
	//		}
	//		else {}

	//		i++;
	//	}
	//	i = 0;
	//	k = 0;
	//}
//=================================================================================================

	
	TEST_INIT;

	TESTCASE_BEGIN("Setup for SQLProcedureColumns tests\n");

	if(!FullConnectWithOptions(pTestInfo, CONNECT_ODBC_VERSION_3))
	{
		LogMsg(NONE,_T("Unable to connect\n"));
		//TEST_FAILED;
		TEST_RETURN;
	}

	henv = pTestInfo->henv;
 	hdbc = pTestInfo->hdbc;
 	hstmt = (SQLHANDLE)pTestInfo->hstmt;
   	
 	returncode = SQLAllocHandle(SQL_HANDLE_STMT, (SQLHANDLE)hdbc, &hstmt);	
 	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLAllocHandle"))
	{
		LogAllErrorsVer3(henv,hdbc,hstmt);
		FullDisconnect3(pTestInfo);
		//TEST_FAILED;
		TEST_RETURN;
	}
	//TESTCASE_END; 

	ProcStr = (TCHAR *)malloc(MAX_NOS_SIZE);
/* SEAQUEST */
        myTestSch = (TCHAR *)malloc(MAX_NOS_SIZE);
        createSchStr = (TCHAR *)malloc(MAX_NOS_SIZE);
        setSchStr = (TCHAR *)malloc(MAX_NOS_SIZE);
        dropSchStr = (TCHAR *)malloc(MAX_NOS_SIZE);
        _tcscpy (myTestSch, _T("ODBC_PROCCOL_TEST"));
        _tcscpy (createSchStr, _T("create schema "));
        _tcscat (createSchStr, pTestInfo->Catalog);
        _tcscat (createSchStr, _T("."));
        _tcscat (createSchStr, myTestSch);
        _tcscpy (setSchStr, _T("set schema "));
        _tcscat (setSchStr, pTestInfo->Catalog);
        _tcscat (setSchStr, _T("."));
        _tcscat (setSchStr, myTestSch);
        _tcscpy (dropSchStr, _T("drop schema "));
        _tcscat (dropSchStr, pTestInfo->Catalog);
        _tcscat (dropSchStr, _T("."));
        _tcscat (dropSchStr, myTestSch);
        _tcscat (dropSchStr, _T(" cascade"));
        returncode = SQLExecDirect(hstmt,(SQLTCHAR*) dropSchStr,SQL_NTS);
        // if(!CHECKRC(SQL_SUCCESS,returncode,"Drop Schema"))
        // {
        //      TEST_FAILED;
        //      LogAllErrors(henv,hdbc,hstmt);
        // }
        returncode = SQLExecDirect(hstmt,(SQLTCHAR*) createSchStr,SQL_NTS);
        if(!CHECKRC(SQL_SUCCESS,returncode,"Create Schema"))
        {
                TEST_FAILED;
                LogAllErrors(henv,hdbc,hstmt);
        }
        returncode = SQLExecDirect(hstmt,(SQLTCHAR*) setSchStr,SQL_NTS);
        if(!CHECKRC(SQL_SUCCESS,returncode,"Set Schema"))
        {
                TEST_FAILED;
                LogAllErrors(henv,hdbc,hstmt);
        }
/* end of SEAQUEST */

	while (_tcsicmp(CreateProc[i].DropProc,_T("endloop")) != 0)
	{
		_tcscpy(ProcStr,_T(""));
		_tcscat(ProcStr,CreateProc[i].DropProc);
		SQLExecDirect(hstmt,(SQLTCHAR*) ProcStr,SQL_NTS); // cleanup
		_tcscpy(ProcStr,_T(""));
		_tcscat(ProcStr,CreateProc[i].CrtProc);
		_stprintf(Heading,_T("Adding Procedure => "));
		_tcscat(Heading,ProcStr);
		_tcscat(Heading,_T("\n"));
		TESTCASE_BEGINW(Heading);
		returncode = SQLExecDirect(hstmt,(SQLTCHAR*)ProcStr,SQL_NTS);
		if(returncode != SQL_SUCCESS)
		{
			returncode = SQLError((SQLHANDLE)NULL, (SQLHANDLE)NULL, hstmt, (SQLTCHAR*)State, &NativeError, (SQLTCHAR*)buf, MAX_STRING_SIZE, NULL);
			if (NativeError == -2013)
			{
				LogMsg(NONE, _T("Stored Procedures not supported\n"));
				_gTestCount--;
				free(ProcStr);
				FullDisconnect(pTestInfo);
				LogMsg(SHORTTIMESTAMP,_T("End testing API => MX Specific SQLProcedureColumns.\n"));
				TEST_RETURN;
			}
			else
			{
				TEST_FAILED;
				LogAllErrors(henv,hdbc,hstmt);
			}
		}
		TESTCASE_END;
		i++;
	}

	_tcscpy(ProcCatalog, pTestInfo->Catalog);
	_tcscpy(ProcSchema, myTestSch /*SEAQUEST pTestInfo->Schema*/);
	
	_stprintf(Heading,_T("Test Positive Functionality of SQLProcedureColumns \n"));
	TESTCASE_BEGINW(Heading);
	returncode = SQLProcedureColumns(hstmt,(SQLTCHAR*)pTestInfo->Catalog,(SWORD)_tcslen(pTestInfo->Catalog),(SQLTCHAR*)myTestSch/* SEAQUEST pTestInfo->Schema*/,(SWORD)_tcslen(myTestSch/* SEAQUEST pTestInfo->Schema*/),(SQLTCHAR *)_T("%"),(SWORD)1,(SQLTCHAR *)_T("%"),(SWORD)1);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLProcedureColumns"))
	{
		TEST_FAILED;
		LogAllErrors(henv,hdbc,hstmt);
	}
	if (returncode == SQL_SUCCESS)
	{
		_tcscpy(oProcCatalog,_T(""));
		_tcscpy(oProcSchema,_T(""));
		_tcscpy(oProcName,_T(""));
		_tcscpy(oColName,_T(""));
		oColType = 0;
		oColDataType = 0;
		_tcscpy(oColTypeName,_T(""));
		oColSize = 0;
		oBufferLen = 0;
		oDecDigits = 0;
		oColRadix = 0;
		oColNullable = 0;
		_tcscpy(oRemark,_T(""));
		_tcscpy(oColDef,_T(""));
		oSQLDataType = 0;
		oSQLDateTimeSub = 0;
		oCharOctetLen = 0;
		oOrdinalPos = 0;
		_tcscpy(oIsNullable,_T(""));
		SQLBindCol(hstmt,1,SQL_C_TCHAR,oProcCatalog,NAME_LEN,&oProcCataloglen);
		SQLBindCol(hstmt,2,SQL_C_TCHAR,oProcSchema,NAME_LEN,&oProcSchemalen);
		SQLBindCol(hstmt,3,SQL_C_TCHAR,oProcName,NAME_LEN,&oProcNamelen);
		SQLBindCol(hstmt,4,SQL_C_TCHAR,oColName,NAME_LEN,&oColNamelen);
		SQLBindCol(hstmt,5,SQL_C_SHORT,&oColType,0,&oColTypelen);
		SQLBindCol(hstmt,6,SQL_C_SHORT,&oColDataType,0,&oColDataTypelen);
		SQLBindCol(hstmt,7,SQL_C_TCHAR,oColTypeName,NAME_LEN,&oColTypeNamelen);
		SQLBindCol(hstmt,8,SQL_C_LONG,&oColSize,0,&oColSizelen);
		SQLBindCol(hstmt,9,SQL_C_LONG,&oBufferLen,0,&oBufferLenlen);
		SQLBindCol(hstmt,10,SQL_C_SHORT,&oDecDigits,0,&oDecDigitslen);
		SQLBindCol(hstmt,11,SQL_C_SHORT,&oColRadix,0,&oColRadixlen);
		SQLBindCol(hstmt,12,SQL_C_SHORT,&oColNullable,0,&oColNullablelen);
		SQLBindCol(hstmt,13,SQL_C_TCHAR,oRemark,REM_LEN,&oRemarklen);
		SQLBindCol(hstmt,14,SQL_C_TCHAR,oColDef,NAME_LEN,&oColDeflen);
		SQLBindCol(hstmt,15,SQL_C_SHORT,&oSQLDataType,0,&oSQLDataTypelen);
		SQLBindCol(hstmt,16,SQL_C_SHORT,&oSQLDateTimeSub,0,&oSQLDateTimeSublen);
		SQLBindCol(hstmt,17,SQL_C_LONG,&oCharOctetLen,0,&oCharOctetLenlen);
		SQLBindCol(hstmt,18,SQL_C_LONG,&oOrdinalPos,0,&oOrdinalPoslen);
		SQLBindCol(hstmt,19,SQL_C_TCHAR,oIsNullable,NAME_LEN,&oIsNullablelen);
		k = 0;
		i = 0;
		while (returncode == SQL_SUCCESS)
		{
			if(_tcscmp(ProcCol[i].ProcName,_T("endloop")) == 0)
				break;
			returncode = SQLFetch(hstmt);
			if((returncode!=SQL_NO_DATA_FOUND) &&(!CHECKRC(SQL_SUCCESS,returncode,"SQLFetch")))
			{
				LogAllErrors(henv,hdbc,hstmt);
				TEST_FAILED;
			}
			else
			{
				if (returncode == SQL_SUCCESS)
				{
					k++;
					_stprintf(Heading,_T("SQLProcedureColumns: Comparing Results\n"));
					TESTCASE_BEGINW(Heading);
					if ((_tcsicmp(ProcCatalog,oProcCatalog) == 0) 
					&& (_tcsicmp(ProcSchema,oProcSchema) == 0) 
					&& (_tcsicmp(ProcCol[i].ProcName,oProcName) == 0) 
					&& (_tcsicmp(ProcCol[i].ColName,oColName) == 0) 
					&& (ProcCol[i].ColType == oColType) 
					&& (ProcCol[i].ColDataType == oColDataType) 
					&& (_tcsicmp(ProcCol[i].ColTypeName,oColTypeName) == 0) 
					&& (ProcCol[i].ColSize == oColSize)
					&& (ProcCol[i].BufferLen == oBufferLen)
					&& (ProcCol[i].DecDigits == oDecDigits)
					&& (ProcCol[i].ColRadix == oColRadix)
					&& (ProcCol[i].ColNullable == oColNullable)
					&& (_tcsicmp(ProcCol[i].Remark,oRemark) == 0)
					&& (_tcsicmp(ProcCol[i].ColDef,oColDef) == 0)
					&& (ProcCol[i].SQLDataType == oSQLDataType)
					&& (ProcCol[i].SQLDateTimeSub == oSQLDateTimeSub)
					&& (ProcCol[i].CharOctetLen == oCharOctetLen)
					&& (ProcCol[i].OrdinalPos == oOrdinalPos)
					&& (_tcsicmp(ProcCol[i].IsNullable,oIsNullable) == 0)){
						LogMsg(NONE,_T("ProcCatalog expect: %s and actual: %s are matched\n"),ProcCatalog,oProcCatalog);
						LogMsg(NONE,_T("ProcSchema expect: %s and actual: %s are matched\n"),ProcSchema,oProcSchema);
						LogMsg(NONE,_T("ProcName expect: %s and actual: %s are matched\n"),ProcCol[i].ProcName,oProcName);
						LogMsg(NONE,_T("ColName expect: %s and actual: %s are matched\n"),ProcCol[i].ColName,oColName);
						LogMsg(NONE,_T("ColType expect: %d and actual: %d are matched\n"),ProcCol[i].ColType,oColType);
						LogMsg(NONE,_T("ColDataType expect: %d and actual: %d are matched\n"),ProcCol[i].ColDataType,oColDataType);
						LogMsg(NONE,_T("ColTypeName expect: %s and actual: %s are matched\n"),ProcCol[i].ColTypeName,oColTypeName);
						LogMsg(NONE,_T("ColSize expect: %d and actual: %d are matched\n"),ProcCol[i].ColSize,oColSize);
						LogMsg(NONE,_T("BufferLen expect: %d and actual: %d are matched\n"),ProcCol[i].BufferLen,oBufferLen);
						LogMsg(NONE,_T("DecDigits expect: %d and actual: %d are matched\n"),ProcCol[i].DecDigits,oDecDigits);
						LogMsg(NONE,_T("ColRadix expect: %d and actual: %d are matched\n"),ProcCol[i].ColRadix,oColRadix);
						LogMsg(NONE,_T("ColNullable expect: %d and actual: %d are matched\n"),ProcCol[i].ColNullable,oColNullable);
						LogMsg(NONE,_T("Remark expect: %s and actual: %s are matched\n"),ProcCol[i].Remark,oRemark);
						LogMsg(NONE,_T("ColDef expect: %s and actual: %s are matched\n"),ProcCol[i].ColDef,oColDef);
						LogMsg(NONE,_T("SQLDataType expect: %d and actual: %d are matched\n"),ProcCol[i].SQLDataType,oSQLDataType);
						LogMsg(NONE,_T("SQLDateTimeSub expect: %d and actual: %d are matched\n"),ProcCol[i].SQLDateTimeSub,oSQLDateTimeSub);
						LogMsg(NONE,_T("CharOctetLen expect: %d and actual: %d are matched\n"),ProcCol[i].CharOctetLen,oCharOctetLen);
						LogMsg(NONE,_T("OrdinalPos expect: %d and actual: %d are matched\n"),ProcCol[i].OrdinalPos,oOrdinalPos);
						LogMsg(NONE,_T("IsNullable expect: %s and actual: %s are matched\n"),ProcCol[i].IsNullable,oIsNullable);
					}	
					else
					{
						TEST_FAILED;	
						if (_tcsicmp(ProcCatalog,oProcCatalog) != 0)
							LogMsg(ERRMSG,_T("ProcCatalog expect: %s and actual: %s are not matched\n"),ProcCatalog,oProcCatalog);
						else
							LogMsg(NONE,_T("ProcCatalog expect: %s and actual: %s are matched\n"),ProcCatalog,oProcCatalog);
						if (_tcsicmp(ProcSchema,oProcSchema) != 0) 
							LogMsg(ERRMSG,_T("ProcSchema expect: %s and actual: %s are not matched\n"),ProcSchema,oProcSchema);
						else
							LogMsg(NONE,_T("ProcSchema expect: %s and actual: %s are matched\n"),ProcSchema,oProcSchema);
						if (_tcsicmp(ProcCol[i].ProcName,oProcName) != 0) 
							LogMsg(ERRMSG,_T("ProcName expect: %s and actual: %s are not matched\n"),ProcCol[i].ProcName,oProcName);
						else
							LogMsg(NONE,_T("ProcName expect: %s and actual: %s are matched\n"),ProcCol[i].ProcName,oProcName);							
						if (_tcsicmp(ProcCol[i].ColName,oColName) != 0) 
							LogMsg(ERRMSG,_T("ColName expect: %s and actual: %s are not matched\n"),ProcCol[i].ColName,oColName);
						else
							LogMsg(NONE,_T("ColName expect: %s and actual: %s are matched\n"),ProcCol[i].ColName,oColName);
						if (ProcCol[i].ColType != oColType) 
							LogMsg(ERRMSG,_T("ColType expect: %d and actual: %d are not matched\n"),ProcCol[i].ColType,oColType);
						else	
							LogMsg(NONE,_T("ColType expect: %d and actual: %d are matched\n"),ProcCol[i].ColType,oColType);
						if (ProcCol[i].ColDataType != oColDataType) 
							LogMsg(ERRMSG,_T("ColDataType expect: %d and actual: %d are not matched\n"),ProcCol[i].ColDataType,oColDataType);
						else	
							LogMsg(NONE,_T("ColDataType expect: %d and actual: %d are matched\n"),ProcCol[i].ColDataType,oColDataType);
						if (_tcsicmp(ProcCol[i].ColTypeName,oColTypeName) != 0) 
							LogMsg(ERRMSG,_T("ColTypeName expect: %s and actual: %s are not matched\n"),ProcCol[i].ColTypeName,oColTypeName);
						else							
							LogMsg(NONE,_T("ColTypeName expect: %s and actual: %s are matched\n"),ProcCol[i].ColTypeName,oColTypeName);
						if (ProcCol[i].ColSize != oColSize)
							LogMsg(ERRMSG,_T("ColSize expect: %d and actual: %d are not matched\n"),ProcCol[i].ColSize,oColSize);
						else	
							LogMsg(NONE,_T("ColSize expect: %d and actual: %d are matched\n"),ProcCol[i].ColSize,oColSize);
						if (ProcCol[i].BufferLen != oBufferLen)
							LogMsg(ERRMSG,_T("BufferLen expect: %d and actual: %d are not matched\n"),ProcCol[i].BufferLen,oBufferLen);
						else	
							LogMsg(NONE,_T("BufferLen expect: %d and actual: %d are matched\n"),ProcCol[i].BufferLen,oBufferLen);							
						if (ProcCol[i].DecDigits != oDecDigits)
							LogMsg(ERRMSG,_T("DecDigits expect: %d and actual: %d are not matched\n"),ProcCol[i].DecDigits,oDecDigits);
						else	
							LogMsg(NONE,_T("DecDigits expect: %d and actual: %d are matched\n"),ProcCol[i].DecDigits,oDecDigits);					
						if (ProcCol[i].ColRadix != oColRadix)
							LogMsg(ERRMSG,_T("ColRadix expect: %d and actual: %d are not matched\n"),ProcCol[i].ColRadix,oColRadix);
						else	
							LogMsg(NONE,_T("ColRadix expect: %d and actual: %d are matched\n"),ProcCol[i].ColRadix,oColRadix);						
						if (ProcCol[i].ColNullable != oColNullable)
							LogMsg(ERRMSG,_T("ColNullable expect: %d and actual: %d are not matched\n"),ProcCol[i].ColNullable,oColNullable);
						else	
							LogMsg(NONE,_T("ColNullable expect: %d and actual: %d are matched\n"),ProcCol[i].ColNullable,oColNullable);						
						if (_tcsicmp(ProcCol[i].Remark,oRemark) != 0)
							LogMsg(ERRMSG,_T("Remark expect: %s and actual: %s are not matched\n"),ProcCol[i].Remark,oRemark);
						else	
							LogMsg(NONE,_T("Remark expect: %s and actual: %s are matched\n"),ProcCol[i].Remark,oRemark);
						if (_tcsicmp(ProcCol[i].ColDef,oColDef) != 0)
							LogMsg(ERRMSG,_T("Remark expect: %s and actual: %s are not matched\n"),ProcCol[i].ColDef,oColDef);
						else	
							LogMsg(NONE,_T("Remark expect: %s and actual: %s are matched\n"),ProcCol[i].ColDef,oColDef);
						if (ProcCol[i].SQLDataType != oSQLDataType)
							LogMsg(ERRMSG,_T("SQLDataType expect: %d and actual: %d are not matched\n"),ProcCol[i].SQLDataType,oSQLDataType);
						else	
							LogMsg(NONE,_T("SQLDataType expect: %d and actual: %d are matched\n"),ProcCol[i].SQLDataType,oSQLDataType);
						if (ProcCol[i].SQLDateTimeSub != oSQLDateTimeSub)
							LogMsg(ERRMSG,_T("SQLDateTimeSub expect: %d and actual: %d are not matched\n"),ProcCol[i].SQLDateTimeSub,oSQLDateTimeSub);
						else	
							LogMsg(NONE,_T("SQLDateTimeSub expect: %d and actual: %d are matched\n"),ProcCol[i].SQLDateTimeSub,oSQLDateTimeSub);
						if (ProcCol[i].CharOctetLen != oCharOctetLen)
							LogMsg(ERRMSG,_T("CharOctetLen expect: %d and actual: %d are not matched\n"),ProcCol[i].CharOctetLen,oCharOctetLen);
						else	
							LogMsg(NONE,_T("CharOctetLen expect: %d and actual: %d are matched\n"),ProcCol[i].CharOctetLen,oCharOctetLen);
						if (ProcCol[i].OrdinalPos != oOrdinalPos)
							LogMsg(ERRMSG,_T("OrdinalPos expect: %d and actual: %d are not matched\n"),ProcCol[i].OrdinalPos,oOrdinalPos);
						else	
							LogMsg(NONE,_T("OrdinalPos expect: %d and actual: %d are matched\n"),ProcCol[i].OrdinalPos,oOrdinalPos);
						if (_tcsicmp(ProcCol[i].IsNullable,oIsNullable) != 0)
							LogMsg(ERRMSG,_T("IsNullable expect: %s and actual: %s are not matched\n"),ProcCol[i].IsNullable,oIsNullable);
						else	
							LogMsg(NONE,_T("IsNullable expect: %s and actual: %s are matched\n"),ProcCol[i].IsNullable,oIsNullable);
					}
				}
			}
			if(k == 0)
			{
				TEST_FAILED;
				LogMsg(ERRMSG,_T("No Data Found => Atleast one row should be fetched\n"));
			}

			TESTCASE_END;
			_tcscpy(oProcCatalog,_T(""));
			_tcscpy(oProcSchema,_T(""));
			_tcscpy(oProcName,_T(""));
			_tcscpy(oColName,_T(""));
			oColType = 0;
			oColDataType = 0;
			_tcscpy(oColTypeName,_T(""));
			oColSize = 0;
			oBufferLen = 0;
			oDecDigits = 0;
			oColRadix = 0;
			oColNullable = 0;
			_tcscpy(oRemark,_T(""));
			_tcscpy(oColDef,_T(""));
			oSQLDataType = 0;
			oSQLDateTimeSub = 0;
			oCharOctetLen = 0;
			oOrdinalPos = 0;
			_tcscpy(oIsNullable,_T(""));
			i++;
		} // while
	}

	SQLFreeStmt(hstmt,SQL_UNBIND);
	SQLFreeStmt(hstmt,SQL_CLOSE);

	i=0;
	while (_tcsicmp(CreateProc[i].DropProc,_T("endloop")) != 0)
	{
		_tcscpy(ProcStr,_T(""));
		_tcscat(ProcStr,CreateProc[i].DropProc);
		returncode = SQLExecDirect(hstmt,(SQLTCHAR*) ProcStr,SQL_NTS); // cleanup
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect"))
		{
			LogAllErrors(henv,hdbc,hstmt);
			TEST_FAILED;
		}
		i++;
	}

	SQLFreeStmt(hstmt,SQL_UNBIND);
	SQLFreeStmt(hstmt,SQL_CLOSE);
	
	//========================================================================================================

	_stprintf(Heading,_T("SQLProcedureColumns: Negative test with NULL handle\n"));
	TESTCASE_BEGINW(Heading);

	hstmt = (SQLHANDLE)NULL;
	_tcscpy(ProcName,_T("junkproc"));
	_tcscpy(ColName,_T("C1"));

	returncode = SQLProcedureColumns(hstmt,(SQLTCHAR*)pTestInfo->Catalog,(SWORD)_tcslen(pTestInfo->Catalog),(SQLTCHAR*)myTestSch /* SEAQUEST pTestInfo->Schema */,(SWORD)_tcslen(myTestSch /* SEAQUEST pTestInfo->Schema*/),(SQLTCHAR*)ProcName,(SWORD)_tcslen(ProcName),(SQLTCHAR*)ColName,(SWORD)_tcslen(ColName));
	if(!CHECKRC(SQL_INVALID_HANDLE,returncode,"SQLProcedureColumns"))
	{
		TEST_FAILED;
		LogAllErrors(henv,hdbc,hstmt);
	}
	TESTCASE_END;

	//========================================================================================================

returncode = SQLExecDirect(hstmt,(SQLTCHAR*) dropSchStr,SQL_NTS);

	free(ProcStr);
	FullDisconnect3(pTestInfo);
	LogMsg(SHORTTIMESTAMP+LINEAFTER,_T("End testing API => MX Specific SQLProcedureColumns.\n"));
	TEST_RETURN;
}
Beispiel #7
0
PassFail TestSQLDescribeParam(TestInfo *pTestInfo, int MX_MP_SPECIFIC)
{                  
	TEST_DECLARE;
 	char			Heading[MAX_STRING_SIZE];
	RETCODE			returncode;
	SQLHANDLE 		henv;
 	SQLHANDLE 		hdbc;
 	SQLHANDLE		hstmt;
	SWORD			numparam;
	UWORD			icol;

	SWORD		st, SQLType[] = 
							{
								SQL_CHAR,SQL_VARCHAR,SQL_DECIMAL,SQL_NUMERIC,SQL_SMALLINT,SQL_INTEGER,SQL_REAL,
								SQL_DOUBLE,SQL_DOUBLE,SQL_DATE,SQL_TIME,SQL_TIMESTAMP,SQL_BIGINT,SQL_LONGVARCHAR,
								SQL_NUMERIC,SQL_NUMERIC,SQL_NUMERIC,SQL_NUMERIC,SQL_NUMERIC,SQL_NUMERIC,SQL_NUMERIC,SQL_NUMERIC
																												
							};										// SQL_DOUBLE for SQL_FLOAT MX limitation
																	//SQL_BIGINT replaced by SQL_NUMERIC in MX
	SWORD		MPSQLType[] = 
							{
								SQL_CHAR,SQL_VARCHAR,SQL_DECIMAL,SQL_NUMERIC,SQL_SMALLINT,SQL_INTEGER,SQL_REAL,
								SQL_FLOAT,SQL_FLOAT,SQL_DATE,SQL_TIME,SQL_TIMESTAMP,SQL_BIGINT,SQL_LONGVARCHAR,
								SQL_NUMERIC,SQL_NUMERIC,SQL_NUMERIC,SQL_NUMERIC,SQL_NUMERIC,SQL_NUMERIC,SQL_NUMERIC,SQL_NUMERIC
							};						
    SQLULEN cp; 
	SQLULEN		ColPrec[] = {10,10,10,10,5,10,7,15,15,10,8,26,19,2000,19,19,128,128,128,10,18,30};
    SQLULEN		MPColPrec[] = {10,10,10,10,5,10,7,15,15,10,8,26,19,10,19,19,128,128,128,10,18,30};	
	SWORD		cs, cnull, ColScale[] = {0,0,5,5,0,0,0,0,0,0,0,6,0,0,0,6,0,128,64,5,5,10};

	CHAR		*DropStr[] = {"--","--","endloop"};
	CHAR		*CrtStr[] = {"--", "--", "endloop"};
	CHAR		*MPCrtStr[] = {"--", "--", "endloop"};
	CHAR		*ExecDirStr[] = {"--","--","--","--","--","--","--","--","--","--","endloop"};

	char		TempType1[50],TempType2[50];
	SWORD		ColNullable[] = {SQL_NULLABLE,SQL_NO_NULLS,SQL_NULLABLE,SQL_NO_NULLS,SQL_NULLABLE,SQL_NO_NULLS,SQL_NULLABLE,SQL_NO_NULLS,SQL_NULLABLE,SQL_NO_NULLS};

	CHAR		*TestCase[] = 
						{
							"before preparing stmt ",
							"endloop"
						};

	SQLUSMALLINT i = 0, l = 0;

//===========================================================================================================
	var_list_t *var_list;
	var_list = load_api_vars("SQLDescribeParam", charset_file);
	if (var_list == NULL) return FAILED;

//=====================Modified for Longvarchar Changes========================================================
	if(!pTestInfo->bLongOn)
	{
		int i = 0;
		char *noLong = "SQL_VARCHAR"; 
		SWORD iNoLong = SQL_VARCHAR;

		SQLType[13] = iNoLong;
		MPSQLType[13] = iNoLong;
	}
//=====================Modified for Longvarchar Changes========================================================


	//print_list(var_list);
	DropStr[0] = var_mapping("SQLDescribeParam_DropStr_1", var_list);
	DropStr[1] = var_mapping("SQLDescribeParam_DropStr_2", var_list);

	CrtStr[0] = var_mapping("SQLDescribeParam_CrtStr_1", var_list);
	CrtStr[1] = var_mapping("SQLDescribeParam_CrtStr_2", var_list);

	MPCrtStr[0] = var_mapping("SQLDescribeParam_MPCrtStr_1", var_list);
	MPCrtStr[1] = var_mapping("SQLDescribeParam_MPCrtStr_2", var_list);

	ExecDirStr[0] = var_mapping("SQLDescribeParam_ExecDirStr_1", var_list);
	ExecDirStr[1] = var_mapping("SQLDescribeParam_ExecDirStr_2", var_list);
	ExecDirStr[2] = var_mapping("SQLDescribeParam_ExecDirStr_3", var_list);
	ExecDirStr[3] = var_mapping("SQLDescribeParam_ExecDirStr_4", var_list);
	ExecDirStr[4] = var_mapping("SQLDescribeParam_ExecDirStr_5", var_list);
	ExecDirStr[5] = var_mapping("SQLDescribeParam_ExecDirStr_6", var_list);
	ExecDirStr[6] = var_mapping("SQLDescribeParam_ExecDirStr_7", var_list);
	ExecDirStr[7] = var_mapping("SQLDescribeParam_ExecDirStr_8", var_list);
	ExecDirStr[8] = var_mapping("SQLDescribeParam_ExecDirStr_9", var_list);
	ExecDirStr[9] = var_mapping("SQLDescribeParam_ExecDirStr_10", var_list);

//=================================================================================================

	if(isUCS2) {
		LogMsg(NONE,"Setup for UCS2 mode testing: ColPrec has to be doubled\n");

		l = sizeof(SQLType)/sizeof(SQLType[0]);
		while(i < l) {
			if(SQLType[i] == SQL_CHAR) {
				//SQLType[i] = SQL_WCHAR;
				ColPrec[i] *= 2;  //--> This is in character, so no need to double
			}
			else if (SQLType[i] == SQL_VARCHAR) {
				//SQLType[i] = SQL_WVARCHAR;
				ColPrec[i] *= 2;  //--> This is in character, so no need to double
			}
			else if (SQLType[i] == SQL_LONGVARCHAR)	{
				//SQLType[i] = SQL_WLONGVARCHAR;
				ColPrec[i] *= 2;  //--> This is in character, so no need to double
			}
			else {
			}

			i++;
		}
		i = 0;

		l = sizeof(MPSQLType)/sizeof(MPSQLType[0]);
		while(i < l) {
			if(MPSQLType[i] == SQL_CHAR) {
		        //MPSQLType[i] = SQL_WCHAR;
				MPColPrec[i] *= 2;  //--> This is in character, so no need to double
			}
			else if (MPSQLType[i] == SQL_VARCHAR) {
				//MPSQLType[i] = SQL_WVARCHAR;
				MPColPrec[i] *= 2;  //--> This is in character, so no need to double
			}
			else if (MPSQLType[i] == SQL_LONGVARCHAR)	{
				//MPSQLType[i] = SQL_WLONGVARCHAR;
				MPColPrec[i] *= 2;  //--> This is in character, so no need to double
			}
			else {
			}
			i++;
		}
		i = 0;
		l = 0;
	}

//===========================================================================================================

    if (MX_MP_SPECIFIC == MX_SPECIFIC)
        LogMsg(LINEBEFORE+SHORTTIMESTAMP,"Begin testing API => MX Specific SQLDescribeParam | SQLDescribeParam | desparam.c\n");
    else
        LogMsg(LINEBEFORE+SHORTTIMESTAMP,"Begin testing API => MP Specific SQLDescribeParam | SQLDescribeParam | desparam.c\n");

	TEST_INIT;
	   
	TESTCASE_BEGIN("Setup for SQLDescribeParam tests\n");

	if(!FullConnect(pTestInfo)){
		LogMsg(NONE,"Unable to connect\n");
		TEST_FAILED;
		TEST_RETURN;
	}

	henv = pTestInfo->henv;
 	hdbc = pTestInfo->hdbc;
 	hstmt = (SQLHANDLE)pTestInfo->hstmt;
   	
	returncode = SQLAllocStmt((SQLHANDLE)hdbc, &hstmt);	
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLAllocStmt"))
	{
		LogAllErrors(henv,hdbc,hstmt);
		TEST_FAILED;
		TEST_RETURN;
	}

	i = 0;
	while (_stricmp(DropStr[i],"endloop") != 0)
	{
		SQLExecDirect(hstmt,(SQLCHAR*)DropStr[i],SQL_NTS); /* cleanup */
		i++;
	}
	i = 0;
	if (MX_MP_SPECIFIC == MX_SPECIFIC)
	{
		while (_stricmp(CrtStr[i],"endloop") != 0)
		{
			returncode = SQLExecDirect(hstmt,(SQLCHAR*)CrtStr[i],SQL_NTS); /* create table */
			if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect"))
			{
				LogAllErrors(henv,hdbc,hstmt);
				TEST_FAILED;
				TEST_RETURN;
			}
			//LogMsg(NONE,"%s\n",	CrtStr[i]);
			i++;
		}
	}
	else
	{
		while (_stricmp(MPCrtStr[i],"endloop") != 0)
		{
			returncode = SQLExecDirect(hstmt,(SQLCHAR*)MPCrtStr[i],SQL_NTS); /* create table */
			if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect"))
			{
				LogAllErrors(henv,hdbc,hstmt);
				TEST_FAILED;
				TEST_RETURN;
			}
			//LogMsg(NONE,"%s\n",	MPCrtStr[i]);
			i++;
		}
	}
	TESTCASE_END;  // end of setup

	l = 0;
	while (_stricmp(TestCase[l],"endloop") != 0)
	{
		i = 0;
		while (_stricmp(ExecDirStr[i],"endloop") != 0)
		{
			//==================================================================================
			sprintf(Heading,"SQLDescribeParam: Test #%d.%d\n",l,i);
			TESTCASE_BEGIN(Heading);
			returncode = SQLPrepare(hstmt,(SQLCHAR*)ExecDirStr[i], SQL_NTS);
			//LogMsg(NONE,"%s\n", ExecDirStr[i]);
			if(!CHECKRC(SQL_SUCCESS,returncode,"SQLPrepare"))
			{
				LogAllErrors(henv,hdbc,hstmt);
				TEST_FAILED;
			}
			else
			{
				returncode=SQLNumParams(hstmt, &numparam);
				if(!CHECKRC(SQL_SUCCESS,returncode,"SQLNumResultCols"))
				{
					LogAllErrors(henv,hdbc,hstmt);
					TEST_FAILED;
				}
				//LogMsg(NONE,"SQLNumParams returns %d\n", numparam);
				for (icol = 1; icol <= numparam; icol++)
				{
					LogMsg(LINEBEFORE,"SQLDescribeParam: checking Column #%d\n",icol);
					returncode = SQLDescribeParam(hstmt,icol,&st,&cp,&cs,&cnull);
					if(!CHECKRC(SQL_SUCCESS,returncode,"SQLDescribeParam"))
					{
						TEST_FAILED;
						LogAllErrors(henv,hdbc,hstmt);
					}
					if (MX_MP_SPECIFIC == MX_SPECIFIC)
					{
						if ((st==SQLType[icol-1]) && (cp==ColPrec[icol-1]) && (cs==ColScale[icol-1]) && (cnull==ColNullable[i]))
						{
							//LogMsg(NONE,"SQLType expect: %s and actual: %s are matched\n",
							//	SQLTypeToChar(SQLType[icol-1],TempType1),SQLTypeToChar(st,TempType2));
							//LogMsg(NONE,"ColPrec expect: %d and actual: %d are matched\n",ColPrec[icol-1],cp);
							//LogMsg(NONE,"ColScale expect: %d and actual: %d are matched\n",ColScale[icol-1],cs);
							//LogMsg(NONE,"ColNullable expect: %s and actual: %s are matched\n\n",
							//	SQLNullToChar(ColNullable[i],TempType1),SQLNullToChar(cnull,TempType2));
						}	
						else
						{
							TEST_FAILED;	
							if (st != SQLType[icol-1])
								LogMsg(ERRMSG,"SQLType expect: %s and actual: %s are not matched\n",SQLTypeToChar(SQLType[icol-1],TempType1),SQLTypeToChar(st,TempType2));
							if (cp != ColPrec[icol-1])
								LogMsg(ERRMSG,"ColPrec expect: %d and actual: %d are not matched\n",ColPrec[icol-1],cp);
							if (cs != ColScale[icol-1])
								LogMsg(ERRMSG,"ColScale expect: %d and actual: %d are not matched\n",ColScale[icol-1],cs);
							if (cnull != ColNullable[i])
								LogMsg(ERRMSG,"ColNullable expect: %s and actual: %s are not matched\n\n",SQLNullToChar(ColNullable[i],TempType1),SQLNullToChar(cnull,TempType2));
						}
					}
					else
					{
						if ((st==MPSQLType[icol-1]) && (cp==MPColPrec[icol-1]) && (cs==ColScale[icol-1]) && (cnull==ColNullable[i]))
						{
							//LogMsg(NONE,"SQLType expect: %s and actual: %s are matched\n",
							//	SQLTypeToChar(MPSQLType[icol-1],TempType1),SQLTypeToChar(st,TempType2));
							//LogMsg(NONE,"ColPrec expect: %d and actual: %d are matched\n",MPColPrec[icol-1],cp);
							//LogMsg(NONE,"ColScale expect: %d and actual: %d are matched\n",ColScale[icol-1],cs);
							//LogMsg(NONE,"ColNullable expect: %s and actual: %s are matched\n\n",
							//	SQLNullToChar(ColNullable[i],TempType1),SQLNullToChar(cnull,TempType2));
						}	
						else
						{
							TEST_FAILED;	
							if (st != MPSQLType[icol-1])
								LogMsg(ERRMSG,"SQLType expect: %s and actual: %s are not matched\n",SQLTypeToChar(MPSQLType[icol-1],TempType1),SQLTypeToChar(st,TempType2));
							if (cp != MPColPrec[icol-1])
								LogMsg(ERRMSG,"ColPrec expect: %d and actual: %d are not matched\n",MPColPrec[icol-1],cp);
							if (cs != ColScale[icol-1])
								LogMsg(ERRMSG,"ColScale expect: %d and actual: %d are not matched\n",ColScale[icol-1],cs);
							if (cnull != ColNullable[i])
								LogMsg(ERRMSG,"ColNullable expect: %s and actual: %s are not matched\n\n",SQLNullToChar(ColNullable[i],TempType1),SQLNullToChar(cnull,TempType2));
						}
					}
				} /* end icol loop */
			}
			SQLFreeStmt(hstmt,SQL_CLOSE);
			i++;
			TESTCASE_END;
		}
		l++;
	}

	i = 0;
	while (_stricmp(DropStr[i],"endloop") != 0)
	{
		SQLExecDirect(hstmt,(SQLCHAR*)DropStr[i],SQL_NTS); /* cleanup */
		i++;
	}

	FullDisconnect(pTestInfo);
	LogMsg(SHORTTIMESTAMP+LINEAFTER,"End testing API => MX Specific SQLDescribeParam.\n");
	free_list(var_list);
	TEST_RETURN;
}
Beispiel #8
0
/*
---------------------------------------------------------
   TestSQLProcedures
---------------------------------------------------------
*/
PassFail TestMXSQLProcedures(TestInfo *pTestInfo)
{                  
	TEST_DECLARE;
 	char			Heading[MAX_HEADING_SIZE];
 	RETCODE			returncode;
 	SQLHANDLE 		henv;
 	SQLHANDLE 		hdbc;
 	SQLHANDLE		hstmt;
  	CHAR			*ProcStr;
	CHAR			*myTestSch = "ODBC_PROC_TEST";
 	CHAR 			createSchStr[128];
	CHAR			setSchStr[128];
	CHAR			dropSchStr[128];
 	CHAR            ProcName[NAME_LEN];
    CHAR            ServerName[NAME_LEN];
    char            SerName[4];
    SQLSMALLINT     serLen;
	SWORD			ProcType = SQL_PT_PROCEDURE;
	CHAR			opqua[NAME_LEN],opowner[NAME_LEN],opname[NAME_LEN],oremark[REM_LEN];
	SWORD			onuminpar,onumoutpar,onumresset,optype;
	SQLLEN			opqualen,opownerlen,opnamelen,onuminparlen,onumoutparlen,onumressetlen,oremarklen,optypelen;

	struct	
	{
		CHAR		*DropProc;
		CHAR		*CrtProc;
	} CreateProc[] = {
							{"DROP PROCEDURE N4210_REG",
							 "CREATE PROCEDURE N4210_REG (IN IN1 TIME) EXTERNAL NAME 'Procs.N4210' EXTERNAL PATH '/home/SQFQA/SPJRoot/odbctest_spjs' LANGUAGE JAVA PARAMETER STYLE JAVA NO SQL NO ISOLATE"},
							{"DROP PROCEDURE N4260_REG",
							 "CREATE PROCEDURE N4260_REG (IN IN1 REAL, INOUT INOUT1 INTEGER) EXTERNAL NAME 'Procs.N4260' EXTERNAL PATH '/home/SQFQA/SPJRoot/odbctest_spjs' LANGUAGE JAVA PARAMETER STYLE JAVA NO SQL NO ISOLATE"},
							{"DROP PROCEDURE N4261_REG",
 							 "CREATE PROCEDURE N4261_REG (IN IN1 NUMERIC, INOUT INOUT1 REAL) EXTERNAL NAME 'Procs.N4261' EXTERNAL PATH '/home/SQFQA/SPJRoot/odbctest_spjs' LANGUAGE JAVA PARAMETER STYLE JAVA NO SQL NO ISOLATE"},
							{"DROP PROCEDURE N4264_REG",
 							 "CREATE PROCEDURE N4264_REG (IN IN1 VARCHAR(30), OUT OUT1 VARCHAR(45)) EXTERNAL NAME 'Procs.N4264' EXTERNAL PATH '/home/SQFQA/SPJRoot/odbctest_spjs' LANGUAGE JAVA PARAMETER STYLE JAVA NO SQL NO ISOLATE"},	
							{"DROP PROCEDURE N4267_REG",
 							 "CREATE PROCEDURE N4267_REG (IN IN1 NUMERIC, INOUT INOUT1 REAL) EXTERNAL NAME 'Procs.N4267' EXTERNAL PATH '/home/SQFQA/SPJRoot/odbctest_spjs' LANGUAGE JAVA PARAMETER STYLE JAVA NO SQL NO ISOLATE"},
							{"endloop","endloop"}
					};
	struct	
	{
		CHAR		*ProcName;
		SDWORD	NumInParams;
		SDWORD	NumOutParams;
		SDWORD	NumResSet;
		CHAR		*Remark;
	} Procedure[] = {
							{"N4210_REG",0,0,0,""},
							{"N4260_REG",0,0,0,""},
							{"N4261_REG",0,0,0,""},
							{"N4264_REG",0,0,0,""},
							{"N4267_REG",0,0,0,""},
							{"endloop",0,0,0,""}
						};
	int	i = 0, k = 0;

//===========================================================================================================
// Initialization Test Case

	LogMsg(LINEBEFORE+SHORTTIMESTAMP,"Begin testing API => MX Specific SQLProcedures | SQLProcedures | MXProc.c\n");
	
	TEST_INIT;

	TESTCASE_BEGIN("Setup for SQLProcedures tests\n");

	if(!FullConnectWithOptions(pTestInfo, CONNECT_ODBC_VERSION_3))
	{
		LogMsg(NONE,"Unable to connect\n");
		TEST_RETURN;
	}

	henv = pTestInfo->henv;
 	hdbc = pTestInfo->hdbc;
 	hstmt = (SQLHANDLE)pTestInfo->hstmt;
   	
 	returncode = SQLAllocHandle(SQL_HANDLE_STMT, (SQLHANDLE)hdbc, &hstmt);	
 	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLAllocHandle"))
	{
		LogAllErrorsVer3(henv,hdbc,hstmt);
		FullDisconnect3(pTestInfo);
		TEST_RETURN;
	}

    returncode = SQLGetInfo(hdbc, SQL_SERVER_NAME, (SQLPOINTER)&ServerName, NAME_LEN, &serLen);

    strncpy(SerName, ServerName+1, 3);
    SerName[3] = '\0';

   /* sq: This test calls SQLProcedures() with wildcard characters.  It 
    * needs its own empty schema to create the procedures,  Otherwise the 
    * standard schema that everybody uses may already have other procedures 
    * created and will be returned by SQLProcedures() to confuse the test.
    */
   sprintf (createSchStr, "CREATE SCHEMA %s.%s", pTestInfo->Catalog, myTestSch);
   sprintf (setSchStr, "SET SCHEMA %s.%s", pTestInfo->Catalog, myTestSch);
   sprintf (dropSchStr, "DROP SCHEMA %s.%s cascade", pTestInfo->Catalog, myTestSch);
   returncode = SQLExecDirect(hstmt,(SQLCHAR*) dropSchStr,SQL_NTS);
   returncode = SQLExecDirect(hstmt,(SQLCHAR*) createSchStr,SQL_NTS);
   returncode = SQLExecDirect(hstmt,(SQLCHAR*) setSchStr,SQL_NTS);

	ProcStr = (char *)malloc(MAX_NOS_SIZE);

	while (_stricmp(CreateProc[i].DropProc,"endloop") != 0)
	{
        sprintf(ProcStr,"%s",CreateProc[i].DropProc);
		returncode = SQLExecDirect(hstmt,(SQLCHAR*) ProcStr,SQL_NTS); // cleanup
        sprintf(ProcStr,"%s",CreateProc[i].CrtProc);
        replace_str(ProcStr,"$$$",SerName);
		sprintf(Heading,"Procedure => %s\n",ProcStr);
		TESTCASE_BEGIN(Heading);
		
		returncode = SQLExecDirect(hstmt,(SQLCHAR*)ProcStr,SQL_NTS);
		if(returncode != SQL_SUCCESS)
		{
            TEST_FAILED;
			LogAllErrors(henv,hdbc,hstmt);
		}
		TESTCASE_END;
		i++;
	}
	
	sprintf(Heading,"Test Positive Functionality of SQLProcedures \n");
	TESTCASE_BEGIN(Heading);
	returncode = SQLProcedures(hstmt,(SQLCHAR*)pTestInfo->Catalog,(SWORD)strlen(pTestInfo->Catalog),(SQLCHAR*)myTestSch/*pTestInfo->Schema*/,(SWORD)strlen(myTestSch/*pTestInfo->Schema*/),(SQLCHAR *)"%",(SWORD)1);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLProcedures"))
		{
			TEST_FAILED;
			LogAllErrors(henv,hdbc,hstmt);
		}
	if (returncode == SQL_SUCCESS)
		{
			strcpy(opqua,"");
			strcpy(opowner,"");
			strcpy(opname,"");
			onuminpar = 0;
			onumoutpar = 0;
			onumresset = 0;
			strcpy(oremark,"");
			optype = 0;
			SQLBindCol(hstmt,1,SQL_C_CHAR,opqua,NAME_LEN,&opqualen);
			SQLBindCol(hstmt,2,SQL_C_CHAR,opowner,NAME_LEN,&opownerlen);
			SQLBindCol(hstmt,3,SQL_C_CHAR,opname,NAME_LEN,&opnamelen);
			SQLBindCol(hstmt,4,SQL_C_SHORT,&onuminpar,0,&onuminparlen);
			SQLBindCol(hstmt,5,SQL_C_SHORT,&onumoutpar,0,&onumoutparlen);
			SQLBindCol(hstmt,6,SQL_C_SHORT,&onumresset,0,&onumressetlen);
			SQLBindCol(hstmt,7,SQL_C_CHAR,oremark,NAME_LEN,&oremarklen);
			SQLBindCol(hstmt,8,SQL_C_SHORT,&optype,0,&optypelen);
			k = 0;
			i = 0;
			while (returncode == SQL_SUCCESS)
			{
				if(strcmp(Procedure[i].ProcName,"endloop") == 0)
					break;
				returncode = SQLFetch(hstmt);
				if((returncode!=SQL_NO_DATA_FOUND) &&(!CHECKRC(SQL_SUCCESS,returncode,"SQLFetch")))
					{
						LogAllErrors(henv,hdbc,hstmt);
						TEST_FAILED;
					}
				else
					{
					if (returncode == SQL_SUCCESS)
						{
						k++;
						sprintf(Heading,"SQLProcedures: Comparing Results\n");
						TESTCASE_BEGIN(Heading);
						if ((_stricmp(pTestInfo->Catalog,opqua) == 0) 
							&& (_stricmp(myTestSch/*pTestInfo->Schema*/,opowner) == 0) 
							&& (_stricmp(Procedure[i].ProcName,opname) == 0) 
							&& (Procedure[i].NumInParams == onuminpar) 
							&& (Procedure[i].NumOutParams == onumoutpar) 
							&& (Procedure[i].NumResSet == onumresset) 
							&& (_stricmp(Procedure[i].Remark,oremark) == 0) 
							&& (ProcType == optype))
							{
								//LogMsg(NONE,"Catalog Name expect: %s and actual: %s are matched\n",pTestInfo->Catalog,opqua);
								//LogMsg(NONE,"Schema Name expect: %s and actual: %s are matched\n",pTestInfo->Schema,opowner);
								//LogMsg(NONE,"ProcName expect: %s and actual: %s are matched\n",Procedure[i].ProcName,opname);
								//LogMsg(NONE,"NumInParams expect: %d and actual: %d are matched\n",Procedure[i].NumInParams,onuminpar);
								//LogMsg(NONE,"NumOutParams expect: %d and actual: %d are matched\n",Procedure[i].NumOutParams,onumoutpar);
								//LogMsg(NONE,"NumResSet expect: %d and actual: %d are matched\n",Procedure[i].NumResSet, onumresset);
								//LogMsg(NONE,"Remark expect: %s and actual: %s are matched\n",Procedure[i].Remark,oremark);
								//LogMsg(NONE,"ProcType expect: %d and actual: %d are matched\n",ProcType,optype);
							}	
						else
							{
								TEST_FAILED;	
								if (_stricmp(pTestInfo->Catalog,opqua) != 0)
									LogMsg(ERRMSG,"Catalog Name expect: %s and actual: %s are not matched\n",pTestInfo->Catalog,opqua);
								if (_stricmp(myTestSch/*pTestInfo->Schema*/,opowner) != 0) 
									LogMsg(ERRMSG,"Schema Name expect: %s and actual: %s are not matched\n",myTestSch/*pTestInfo->Schema*/,opowner);
								if (_stricmp(Procedure[i].ProcName,opname) != 0) 
									LogMsg(ERRMSG,"ProcName expect: %s and actual: %s are not matched\n",Procedure[i].ProcName,opname);
								if (Procedure[i].NumInParams != onuminpar) 
									LogMsg(ERRMSG,"NumInParams expect: %d and actual: %d are not matched\n",Procedure[i].NumInParams,onuminpar);
								if (Procedure[i].NumOutParams != onumoutpar) 
									LogMsg(ERRMSG,"NumOutParams expect: %d and actual: %d are not matched\n",Procedure[i].NumOutParams,onumoutpar);
								if (Procedure[i].NumResSet != onumresset) 
									LogMsg(ERRMSG,"NumResSet expect: %d and actual: %d are not matched\n",Procedure[i].NumResSet, onumresset);
								if (_stricmp(Procedure[i].Remark,oremark) != 0) 
									LogMsg(ERRMSG,"Remark expect: %s and actual: %s are not matched\n",Procedure[i].Remark,oremark);
								if (ProcType != optype)
									LogMsg(ERRMSG,"ProcType expect: %d and actual: %d are not matched\n",ProcType,optype);
							}
						}
					}
					if(k == 0)
					{
						TEST_FAILED;
						LogMsg(ERRMSG,"No Data Found => Atleast one row should be fetched\n");
					}
			TESTCASE_END;
			i++;
			} // while
		}
	SQLFreeStmt(hstmt,SQL_UNBIND);
	SQLFreeStmt(hstmt,SQL_CLOSE);

	//========================================================================================================

	sprintf(Heading,"SQLProcedures: Negative test with NULL handle\n");
	TESTCASE_BEGIN(Heading);

	hstmt = (SQLHANDLE)NULL;
	strcpy(ProcName,"junkproc");

	returncode = SQLProcedures(hstmt,(SQLCHAR*)pTestInfo->Catalog,(SWORD)strlen(pTestInfo->Catalog),(SQLCHAR*)myTestSch/*pTestInfo->Schema*/,(SWORD)strlen(myTestSch/*pTestInfo->Schema*/),(SQLCHAR*)ProcName,(SWORD)strlen(ProcName));
	if(!CHECKRC(SQL_INVALID_HANDLE,returncode,"SQLProcedures"))
	{
		TEST_FAILED;
		LogAllErrors(henv,hdbc,hstmt);
	}
       returncode = SQLExecDirect(hstmt,(SQLCHAR*) dropSchStr,SQL_NTS);
	TESTCASE_END;

	//========================================================================================================

	free(ProcStr);
	FullDisconnect3(pTestInfo);
	LogMsg(SHORTTIMESTAMP+LINEAFTER,"End testing API => MX Specific SQLProcedures.\n");
	TEST_RETURN;
}
Beispiel #9
0
/*
---------------------------------------------------------
   TestSQLNativeSql
---------------------------------------------------------
*/
PassFail TestSQLNativeSql(TestInfo *pTestInfo)
{                  
	TEST_DECLARE;
	RETCODE		returncode;
 	SQLHANDLE 	henv;
 	SQLHANDLE 	hdbc;
 	SQLHANDLE	hstmt;
	CHAR		*szSqlStrIn[3];
	CHAR		szSqlStrOut[SQLSTR_LEN];
	SDWORD	pcbSqlStr;
   
//===========================================================================================================
	var_list_t *var_list;
	var_list = load_api_vars("SQLNativeSql", charset_file);
	if (var_list == NULL) return FAILED;

	//print_list(var_list);
	szSqlStrIn[0] = var_mapping("SQLNativeSql_szSqlStrIn_1", var_list);
	szSqlStrIn[1] = var_mapping("SQLNativeSql_szSqlStrIn_2", var_list);
	szSqlStrIn[2] = var_mapping("SQLNativeSql_szSqlStrIn_3", var_list);
//===========================================================================================================

	LogMsg(LINEBEFORE+SHORTTIMESTAMP,"Begin testing API =>SQLNativeSql | SQLNativeSQL | natsql.c\n");

	TEST_INIT;

	returncode=FullConnect(pTestInfo);
   if (pTestInfo->hdbc == (SQLHANDLE)NULL)
	{
		TEST_FAILED;
		TEST_RETURN;
	}

	henv = pTestInfo->henv;
 	hdbc = pTestInfo->hdbc;
 	hstmt = (SQLHANDLE)pTestInfo->hstmt;
	returncode = SQLAllocStmt((SQLHANDLE)hdbc, &hstmt);	
	if (returncode == SQL_SUCCESS)
	{
	//==================================================================================================

		TESTCASE_BEGIN("Test the positive functionality of SQLNativeSql with null terminated string\n");
		returncode = SQLNativeSql((SQLHANDLE)hdbc, (SQLCHAR*)szSqlStrIn[0], SQL_NTS, (SQLCHAR*)szSqlStrOut, SQLSTR_LEN, &pcbSqlStr); 
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLNativeSql"))
		{
			TEST_FAILED;
			LogAllErrors(henv,hdbc,hstmt);
		}
		if (strcmp(szSqlStrOut,szSqlStrIn[0]) == 0)
		{
			LogMsg(NONE,"expect: %s and actual: %s are matched\n", szSqlStrIn[0], szSqlStrOut);
		}	
		else
		{
			TEST_FAILED;	
			LogMsg(NONE,"expect: %s and actual: %s are not matched\n", szSqlStrIn[0], szSqlStrOut);
		}
		TESTCASE_END;

		//==================================================================================================

		TESTCASE_BEGIN("Test the positive functionality of SQLNativeSql with string length as input\n");
		returncode = SQLNativeSql((SQLHANDLE)hdbc, (SQLCHAR*)szSqlStrIn[1], strlen(szSqlStrIn[1]), (SQLCHAR*)szSqlStrOut, SQLSTR_LEN, &pcbSqlStr); 
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLNativeSql"))
		{
			TEST_FAILED;
			LogAllErrors(henv,hdbc,hstmt);
		}
		if (strcmp(szSqlStrOut,szSqlStrIn[1]) == 0)
		{
			LogMsg(NONE,"expect: %s and actual: %s are matched\n", szSqlStrIn[1], szSqlStrOut);
		}	
		else
		{
			TEST_FAILED;	
			LogMsg(NONE,"expect: %s and actual: %s are not matched\n", szSqlStrIn[1], szSqlStrOut);
		}
		TESTCASE_END;

		//==================================================================================================
		TESTCASE_BEGIN("Test the positive functionality of SQLNativeSql with max length same as string length\n");
		returncode = SQLNativeSql((SQLHANDLE)hdbc, (SQLCHAR*)szSqlStrIn[2], strlen(szSqlStrIn[2]), (SQLCHAR*)szSqlStrOut, strlen(szSqlStrIn[2])+1, &pcbSqlStr); 
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLNativeSql"))
		{
			TEST_FAILED;
			LogAllErrors(henv,hdbc,hstmt);
		}
		if (strcmp(szSqlStrOut,szSqlStrIn[2]) == 0)
		{
			LogMsg(NONE,"expect: %s and actual: %s are matched\n", szSqlStrIn[2], szSqlStrOut);
		}	
		else
		{
			TEST_FAILED;	
			LogMsg(NONE,"expect: %s and actual: %s are not matched\n", szSqlStrIn[2], szSqlStrOut);
		}
		TESTCASE_END;
	}
//==================================================================================================

	FullDisconnect(pTestInfo);
	LogMsg(SHORTTIMESTAMP+LINEAFTER,"End testing API => SQLNativeSql.\n");
	free_list(var_list);
	TEST_RETURN;
}
Beispiel #10
0
/*
---------------------------------------------------------
   TestSQLDescribeColVer3 for MP Specific
---------------------------------------------------------
*/
PassFail TestMXSQLDescribeColVer3(TestInfo *pTestInfo)
{
	TEST_DECLARE;
 	char			Heading[MAX_STRING_SIZE];
	RETCODE			returncode;
	SQLHANDLE 		henv, hdbc, hstmt;
	UWORD			icol;
	SWORD			numcol, st, cs, cnull, cl, colsize = 2;
	SQLULEN         cp; 
	CHAR			cn[COLNAME_LEN];
	CHAR			*colname[21];
	CHAR			*ExecDirStr[12];

#ifndef _WM
	SWORD			SQLType[] = {SQL_CHAR,SQL_VARCHAR,SQL_DECIMAL,SQL_NUMERIC,SQL_SMALLINT,SQL_INTEGER,
									SQL_REAL,SQL_DOUBLE,SQL_DOUBLE,SQL_TYPE_DATE,SQL_TYPE_TIME,SQL_TYPE_TIMESTAMP,SQL_LONGVARCHAR,SQL_BIGINT,
									SQL_NUMERIC,SQL_NUMERIC,SQL_NUMERIC,SQL_NUMERIC,SQL_NUMERIC,SQL_NUMERIC,SQL_NUMERIC};
	SQLULEN			ColPrec[] = {254,254,18,18,5,10,7,15,15,10,8,26,2000,19,19,19,128,128,10,18,30};
#else
	SWORD			SQLType[] = {SQL_CHAR,SQL_VARCHAR,SQL_DECIMAL,SQL_NUMERIC,SQL_SMALLINT,SQL_INTEGER,
									SQL_REAL,SQL_DOUBLE,SQL_DOUBLE,SQL_CHAR,SQL_TYPE_TIME,SQL_TYPE_TIMESTAMP,SQL_LONGVARCHAR,SQL_BIGINT,
									SQL_NUMERIC,SQL_NUMERIC,SQL_NUMERIC,SQL_NUMERIC,SQL_NUMERIC,SQL_NUMERIC,SQL_NUMERIC};
	SQLULEN			ColPrec[] = {254,254,18,18,5,10,7,15,15,8,8,26,2000,19,19,19,128,128,10,18,30};
#endif
	SWORD			ColScale[]= {0,  0,  6, 6, 0,0, 0,0, 0, 0, 0,6, 0,   0, 0, 6, 0,  128,5, 5, 10};
	char			TempType1[50],TempType2[50];
	SWORD			ColNullable[] = {SQL_NULLABLE,SQL_NO_NULLS,SQL_NULLABLE};

	CHAR			*TestCase[] = {
					"before preparing stmt ",
					"before preparing & executing stmt ",
					"before preparing, executing & fetching stmt ",
					"before execdirect stmt ",
					"before execdirect & fetching stmt ",
					"before preparing param stmt ",
					"before preparing & binding stmt ",
					"before preparing, binding & executing stmt ",
					"before preparing, binding, executing & fetching stmt "
					};

	int				lend = 9, iend = 3;
	SQLUSMALLINT	i = 0, l = 0;
	SQLLEN			cbIn = SQL_NTS;

//===========================================================================================================
	var_list_t *var_list;
	var_list = load_api_vars("SQLDescribeColumns30", charset_file);
	if (var_list == NULL) return FAILED;
//================Modified for Longvarchar Changes===========================================================
	if(!pTestInfo->bLongOn)
	{
		SWORD iNoLong = SQL_VARCHAR;
		SQLType[12] = iNoLong;
	}
//================Modified for Longvarchar Changes===========================================================
	//print_list(var_list);
	colname[0] = var_mapping("SQLDescribeColumns30_colname_1", var_list);
	colname[1] = var_mapping("SQLDescribeColumns30_colname_2", var_list);
	colname[2] = var_mapping("SQLDescribeColumns30_colname_3", var_list);
	colname[3] = var_mapping("SQLDescribeColumns30_colname_4", var_list);
	colname[4] = var_mapping("SQLDescribeColumns30_colname_5", var_list);
	colname[5] = var_mapping("SQLDescribeColumns30_colname_6", var_list);
	colname[6] = var_mapping("SQLDescribeColumns30_colname_7", var_list);
	colname[7] = var_mapping("SQLDescribeColumns30_colname_8", var_list);
	colname[8] = var_mapping("SQLDescribeColumns30_colname_9", var_list);
	colname[9] = var_mapping("SQLDescribeColumns30_colname_10", var_list);
	colname[10] = var_mapping("SQLDescribeColumns30_colname_11", var_list);
	colname[11] = var_mapping("SQLDescribeColumns30_colname_12", var_list);
	colname[12] = var_mapping("SQLDescribeColumns30_colname_13", var_list);
	colname[13] = var_mapping("SQLDescribeColumns30_colname_14", var_list);
	colname[14] = var_mapping("SQLDescribeColumns30_colname_15", var_list);
	colname[15] = var_mapping("SQLDescribeColumns30_colname_16", var_list);
	colname[16] = var_mapping("SQLDescribeColumns30_colname_17", var_list);
	colname[17] = var_mapping("SQLDescribeColumns30_colname_18", var_list);
	colname[18] = var_mapping("SQLDescribeColumns30_colname_19", var_list);
	colname[19] = var_mapping("SQLDescribeColumns30_colname_20", var_list);
	colname[20] = var_mapping("SQLDescribeColumns30_colname_21", var_list);

	ExecDirStr[0] = var_mapping("SQLDescribeColumns30_ExecDirStr_1", var_list);
	ExecDirStr[1] = var_mapping("SQLDescribeColumns30_ExecDirStr_2", var_list);
	ExecDirStr[2] = var_mapping("SQLDescribeColumns30_ExecDirStr_3", var_list);
	ExecDirStr[3] = var_mapping("SQLDescribeColumns30_ExecDirStr_4", var_list);
	ExecDirStr[4] = var_mapping("SQLDescribeColumns30_ExecDirStr_5", var_list);
	ExecDirStr[5] = var_mapping("SQLDescribeColumns30_ExecDirStr_6", var_list);
	ExecDirStr[6] = var_mapping("SQLDescribeColumns30_ExecDirStr_7", var_list);
	ExecDirStr[7] = var_mapping("SQLDescribeColumns30_ExecDirStr_8", var_list);
	ExecDirStr[8] = var_mapping("SQLDescribeColumns30_ExecDirStr_9", var_list);
	ExecDirStr[9] = var_mapping("SQLDescribeColumns30_ExecDirStr_10", var_list);
	ExecDirStr[10] = var_mapping("SQLDescribeColumns30_ExecDirStr_11", var_list);
	ExecDirStr[11] = var_mapping("SQLDescribeColumns30_ExecDirStr_12", var_list);

//=========================================================================================

	if(isUCS2) {
		LogMsg(NONE,"Setup for UCS2 mode testing: ColPrec has to be doubled\n");

        ExecDirStr[3] = replace_str(ExecDirStr[3],"$$$","127");
        ExecDirStr[4] = replace_str(ExecDirStr[4],"$$$","127");
        ExecDirStr[5] = replace_str(ExecDirStr[5],"$$$","127");

		l = sizeof(SQLType)/sizeof(SQLType[0]);
		while(i < l) {
			if(SQLType[i] == SQL_CHAR) {
				//SQLType[i] = SQL_WCHAR;
				ColPrec[i] *= 2;  //--> This is in character, so no need to double
			}
			else if (SQLType[i] == SQL_VARCHAR) {
				//SQLType[i] = SQL_WVARCHAR;
			}
			else if (SQLType[i] == SQL_LONGVARCHAR)	{
				//SQLType[i] = SQL_WLONGVARCHAR;
				ColPrec[i] *= 2;  //--> This is in character, so no need to double
			}
			else {
			}
			i++;
		}
		i = 0;
		l = 0;
	} else {
        ExecDirStr[3] = replace_str(ExecDirStr[3],"$$$","254");
        ExecDirStr[4] = replace_str(ExecDirStr[4],"$$$","254");
        ExecDirStr[5] = replace_str(ExecDirStr[5],"$$$","254");
    }

//===========================================================================================================

	LogMsg(LINEBEFORE+SHORTTIMESTAMP,"Begin testing API => MX Specific SQLDescribeColumns | SQLDescribeColumns30 | sqldescribecolver3.c\n");
	TEST_INIT;

	TESTCASE_BEGIN("Setup for SQLDescribCol tests\n");

	if(!FullConnectWithOptions(pTestInfo, CONNECT_ODBC_VERSION_3))
	{
		LogMsg(NONE,"Unable to connect\n");
		TEST_FAILED;
		TEST_RETURN;
	}

	henv = pTestInfo->henv;
	hdbc = pTestInfo->hdbc;
	hstmt = (SQLHANDLE)pTestInfo->hstmt;
	
	returncode = SQLAllocHandle(SQL_HANDLE_STMT, (SQLHANDLE)hdbc, &hstmt);	
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLAllocHandle"))
	{
		LogAllErrorsVer3(henv,hdbc,hstmt);
		TEST_FAILED;
		TEST_RETURN;
	}
	TESTCASE_END;  // end of setup
	for (l = 0; l < lend; l++)
	{
		for (i = 0; i < iend; i++)
		{
			//==================================================================================
			sprintf(Heading,"SQLDescribeCol: Test #%d.%d\n",l,i);
			TESTCASE_BEGIN(Heading);
			if ((i != (iend-1)) && (l < 5))
			{
				rerutncode = SQLExecDirect(hstmt,(SQLCHAR*)ExecDirStr[i],SQL_NTS); /* cleanup */
				 if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect"))
                                        {
                                                LogAllErrorsVer3(henv,hdbc,hstmt);
                                                TEST_FAILED;
                                        }

                                returncode = SQLExecDirect(hstmt,(SQLCHAR*)ExecDirStr[i+iend],SQL_NTS); /* create table */
				LogMsg(NONE,"%s\n", ExecDirStr[i+iend]);
				if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect"))
				{
					LogAllErrorsVer3(henv,hdbc,hstmt);
					TEST_FAILED;
				}
				else
				{
					returncode = SQLExecDirect(hstmt,(SQLCHAR*)ExecDirStr[i+iend+iend],SQL_NTS); /* insert into table */
					if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect"))
					{
						LogAllErrorsVer3(henv,hdbc,hstmt);
						TEST_FAILED;
					}
					else
					{
						LogMsg(NONE,"SQLDescribeCol: %s\n",TestCase[l]);
						LogMsg(NONE,"     %s\n",ExecDirStr[i+iend+iend+iend]);
						switch( l )
						{
							case 0:
								returncode = SQLPrepare(hstmt,(SQLCHAR*)ExecDirStr[i+iend+iend+iend], SQL_NTS);
								if(!CHECKRC(SQL_SUCCESS,returncode,"SQLPrepare"))
								{
									LogAllErrorsVer3(henv,hdbc,hstmt);
									TEST_FAILED;
								}
								break;
							case 1 :
								returncode = SQLPrepare(hstmt,(SQLCHAR*)ExecDirStr[i+iend+iend+iend], SQL_NTS);
								if(!CHECKRC(SQL_SUCCESS,returncode,"SQLPrepare"))
								{
									LogAllErrorsVer3(henv,hdbc,hstmt);
									TEST_FAILED;
								}
								else
								{
									returncode = SQLExecute(hstmt);
									if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecute"))
									{
										LogAllErrorsVer3(henv,hdbc,hstmt);
										TEST_FAILED;
									}
								}
								break;
							case 2 :
								returncode = SQLPrepare(hstmt,(SQLCHAR*)ExecDirStr[i+iend+iend+iend], SQL_NTS);
								if(!CHECKRC(SQL_SUCCESS,returncode,"SQLPrepare"))
								{
									LogAllErrorsVer3(henv,hdbc,hstmt);
									TEST_FAILED;
								}
								else
								{
									returncode = SQLExecute(hstmt);
									if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecute"))
									{
										LogAllErrorsVer3(henv,hdbc,hstmt);
										TEST_FAILED;
									}
									else
									{
										returncode = SQLFetch(hstmt);
										if(!CHECKRC(SQL_SUCCESS,returncode,"SQLFetch"))
										{
											LogAllErrorsVer3(henv,hdbc,hstmt);
											TEST_FAILED;
										}
									}
								}
								break;
							case 3 :
								returncode = SQLExecDirect(hstmt,(SQLCHAR*)ExecDirStr[i+iend+iend+iend], SQL_NTS);
								if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect"))
								{
									LogAllErrorsVer3(henv,hdbc,hstmt);
									TEST_FAILED;
								}
								break;
							case 4 :
								returncode = SQLExecDirect(hstmt,(SQLCHAR*)ExecDirStr[i+iend+iend+iend], SQL_NTS);
								if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect"))
								{
									LogAllErrorsVer3(henv,hdbc,hstmt);
									TEST_FAILED;
								}
								else
								{
									returncode = SQLFetch(hstmt);
									if(!CHECKRC(SQL_SUCCESS,returncode,"SQLFetch"))
									{
										LogAllErrorsVer3(henv,hdbc,hstmt);
										TEST_FAILED;
									}
								}
								break;
						}
						if (returncode == SQL_SUCCESS)
						{
							returncode=SQLNumResultCols(hstmt, &numcol);
							if(!CHECKRC(SQL_SUCCESS,returncode,"SQLNumResultCols"))
							{
								LogAllErrorsVer3(henv,hdbc,hstmt);
								TEST_FAILED;
							}
							for (icol = 1; icol <= numcol; icol++)
							{
								LogMsg(LINEBEFORE,"SQLDescribeCol: checking Column #%d\n",icol);
								returncode = SQLDescribeCol(hstmt,icol,(SQLCHAR*)cn,COLNAME_LEN,&cl,&st,&cp,&cs,&cnull);
								if(!CHECKRC(SQL_SUCCESS,returncode,"SQLDescribeCol"))
								{
									TEST_FAILED;
									LogAllErrorsVer3(henv,hdbc,hstmt);
								}
								colsize=strlen(colname[icol-1]);
								if(isCharSet == TRUE)
									colsize -= 2;
								if ((cstrcmp(cn,colname[icol-1],FALSE,isCharSet) == 0) 
									 && (cl == colsize) 
									 && (st == SQLType[icol-1]) 
									 && (cp == ColPrec[icol-1]) 
									 && (cs == ColScale[icol-1]) 
									 && (cnull == ColNullable[i]))
								{
									//LogMsg(NONE,"colname expect: %s and actual: %s are matched\n",colname[icol-1],cn);
									//LogMsg(NONE,"ColNameLen expect: %d and actual: %d are matched\n",colsize,cl);
									//LogMsg(NONE,"SQLType expect: %s and actual: %s are matched\n",
									//SQLTypeToChar(SQLType[icol-1],TempType1),SQLTypeToChar(st,TempType2));
									//LogMsg(NONE,"ColPrec expect: %d and actual: %d are matched\n",ColPrec[icol-1],cp);
									//LogMsg(NONE,"ColScale expect: %d and actual: %d are matched\n",ColScale[icol-1],cs);
									//LogMsg(NONE,"ColNullable expect: %s and actual: %s are matched\n\n",
									//SQLNullToChar(ColNullable[i],TempType1),SQLNullToChar(cnull,TempType2));
								}
								else
								{
									TEST_FAILED;	
									if (cstrcmp(cn,colname[icol-1],FALSE,isCharSet) != 0)
										LogMsg(ERRMSG,"colname expect: %s and actual: %s are not matched\n",colname[icol-1],cn);
									if (cl != colsize)
										LogMsg(ERRMSG,"ColNameLen expect: %d and actual: %d are not matched\n",colsize,cl);
									if (st != SQLType[icol-1])
										LogMsg(ERRMSG,"SQLType expect: %s and actual: %s are not matched\n",
											SQLTypeToChar(SQLType[icol-1],TempType1),SQLTypeToChar(st,TempType2));
									if (cp != ColPrec[icol-1])
										LogMsg(ERRMSG,"ColPrec expect: %d and actual: %d are not matched\n",ColPrec[icol-1],cp);
									if (cs != ColScale[icol-1])
										LogMsg(ERRMSG,"ColScale expect: %d and actual: %d are not matched\n",ColScale[icol-1],cs);
									if (cnull != ColNullable[i])
										LogMsg(ERRMSG,"ColNullable expect: %s and actual: %s are not matched\n\n",
											SQLNullToChar(ColNullable[i],TempType1),SQLNullToChar(cnull,TempType2));
								}
							} /* end icol loop */
						}
						else
						{
							TEST_FAILED;
							LogAllErrorsVer3(henv,hdbc,hstmt);
						}
						SQLFreeStmt(hstmt,SQL_CLOSE);
						SQLExecDirect(hstmt,(SQLCHAR*) ExecDirStr[i],SQL_NTS); /* cleanup */
					}
				}
			}
			else if ((i == (iend-1)) && (l >= 5))
			{
				SQLExecDirect(hstmt,(SQLCHAR*)ExecDirStr[i],SQL_NTS); /* cleanup */ 
				returncode = SQLExecDirect(hstmt,(SQLCHAR*)ExecDirStr[i+iend],SQL_NTS); /* create table */
				LogMsg(NONE,"%s\n", ExecDirStr[i+iend]);
				if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect"))
				{
					LogAllErrorsVer3(henv,hdbc,hstmt);
					TEST_FAILED;
				}
				else
				{
					returncode = SQLExecDirect(hstmt,(SQLCHAR*)ExecDirStr[i+iend+iend],SQL_NTS); /* insert into table */
					if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect"))
					{
						LogAllErrorsVer3(henv,hdbc,hstmt);
						TEST_FAILED;
					}
					else
					{
						LogMsg(NONE,"SQLDescribeCol: %s\n",TestCase[l]);
						LogMsg(NONE,"     %s\n",ExecDirStr[i+iend+iend+iend]);
						switch( l ) 
						{
							case 5 :
								returncode = SQLPrepare(hstmt,(SQLCHAR*)ExecDirStr[i+iend+iend+iend], SQL_NTS);
								if(!CHECKRC(SQL_SUCCESS,returncode,"SQLPrepare"))
								{
									LogAllErrorsVer3(henv,hdbc,hstmt);
									TEST_FAILED;
								}
								break;
							case 6 :
								returncode = SQLPrepare(hstmt,(SQLCHAR*)ExecDirStr[i+iend+iend+iend], SQL_NTS);
								if(!CHECKRC(SQL_SUCCESS,returncode,"SQLPrepare"))
								{
									LogAllErrorsVer3(henv,hdbc,hstmt);
									TEST_FAILED;
								}
								else
								{
									returncode = SQLBindParameter(hstmt,1,SQL_PARAM_INPUT,SQL_C_CHAR,SQL_CHAR,2000,0,(SQLPOINTER) "0123456789",300,&cbIn);
									if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindParameter"))
									{
										LogAllErrorsVer3(henv,hdbc,hstmt);
										TEST_FAILED;
									}
									returncode = SQLBindParameter(hstmt,2,SQL_PARAM_INPUT,SQL_C_CHAR,SQL_CHAR,2000,0,(SQLPOINTER)"0123456789",300,&cbIn);
									if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindParameter"))
									{
										LogAllErrorsVer3(henv,hdbc,hstmt);
										TEST_FAILED;
									}
								}
								break;
							case 7 :
								returncode = SQLPrepare(hstmt,(SQLCHAR*)ExecDirStr[i+iend+iend+iend], SQL_NTS);
								if(!CHECKRC(SQL_SUCCESS,returncode,"SQLPrepare"))
								{
									LogAllErrorsVer3(henv,hdbc,hstmt);
									TEST_FAILED;
								}
								else
								{
									returncode = SQLBindParameter(hstmt,1,SQL_PARAM_INPUT,SQL_C_CHAR,SQL_CHAR,2000,0,(SQLPOINTER)"0123456789",300,&cbIn);
									if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindParameter"))
									{
										LogAllErrorsVer3(henv,hdbc,hstmt);
										TEST_FAILED;
									}
									returncode = SQLBindParameter(hstmt,2,SQL_PARAM_INPUT,SQL_C_CHAR,SQL_CHAR,2000,0,(SQLPOINTER)"0123456789",300,&cbIn);
									if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindParameter"))
									{
										LogAllErrorsVer3(henv,hdbc,hstmt);
										TEST_FAILED;
									}
									returncode = SQLExecute(hstmt);
									if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecute"))
									{
										LogAllErrorsVer3(henv,hdbc,hstmt);
										TEST_FAILED;
									}
								}
								break;
							  case 8 :
								returncode = SQLPrepare(hstmt,(SQLCHAR*)ExecDirStr[i+iend+iend+iend], SQL_NTS);
								if(!CHECKRC(SQL_SUCCESS,returncode,"SQLPrepare"))
								{
									LogAllErrorsVer3(henv,hdbc,hstmt);
									TEST_FAILED;
								}
								else
								{
									returncode = SQLBindParameter(hstmt,1,SQL_PARAM_INPUT,SQL_C_CHAR,SQL_CHAR,2000,0,(SQLPOINTER)"0123456789",300,&cbIn);
									if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindParameter"))
									{
										LogAllErrorsVer3(henv,hdbc,hstmt);
										TEST_FAILED;
									}
									returncode = SQLBindParameter(hstmt,2,SQL_PARAM_INPUT,SQL_C_CHAR,SQL_CHAR,2000,0,(SQLPOINTER)"0123456789",300,&cbIn);
									if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindParameter"))
									{
										LogAllErrorsVer3(henv,hdbc,hstmt);
										TEST_FAILED;
									}
									returncode = SQLExecute(hstmt);
									if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecute"))
									{
										LogAllErrorsVer3(henv,hdbc,hstmt);
										TEST_FAILED;
									}
									else
									{
										returncode = SQLFetch(hstmt);
										if(!CHECKRC(SQL_SUCCESS,returncode,"SQLFetch"))
										{
											LogAllErrorsVer3(henv,hdbc,hstmt);
											TEST_FAILED;
										}
									}
								}
								break;
						}
						if (returncode == SQL_SUCCESS)
						{
							SQLNumResultCols(hstmt, &numcol);
							if(!CHECKRC(SQL_SUCCESS,returncode,"SQLNumResultCols"))
							{
								LogAllErrorsVer3(henv,hdbc,hstmt);
								TEST_FAILED;
							}
							for (icol = 1; icol <= numcol; icol++)
							{
								LogMsg(LINEBEFORE,"SQLDescribeCol: checking Column #%d\n",icol);
								returncode = SQLDescribeCol(hstmt,icol,(SQLCHAR*)cn,COLNAME_LEN,&cl,&st,&cp,&cs,&cnull);
								if(!CHECKRC(SQL_SUCCESS,returncode,"SQLDescribeCol"))
								{
									TEST_FAILED;
									LogAllErrorsVer3(henv,hdbc,hstmt);
								}
								colsize=strlen(colname[icol-1]);
								if(isCharSet == TRUE)
									colsize -= 2;
								if ((cstrcmp(cn,colname[icol-1],FALSE,isCharSet) == 0) 
									 && (cl == colsize) 
									 && (st == SQLType[icol-1]) 
									 && (cp == ColPrec[icol-1]) 
									 && (cs == ColScale[icol-1]) 
									 && (cnull == ColNullable[i]))
								{
									//LogMsg(NONE,"colname expect: %s and actual: %s are matched\n",colname[icol-1],cn);
									//LogMsg(NONE,"ColNameLen expect: %d and actual: %d are matched\n",colsize,cl);
									//LogMsg(NONE,"SQLType expect: %s and actual: %s are matched\n",
									//	SQLTypeToChar(SQLType[icol-1],TempType1),SQLTypeToChar(st,TempType2));
									//LogMsg(NONE,"ColPrec expect: %d and actual: %d are matched\n",ColPrec[icol-1],cp);
									//LogMsg(NONE,"ColScale expect: %d and actual: %d are matched\n",ColScale[icol-1],cs);
									//LogMsg(NONE,"ColNullable expect: %s and actual: %s are matched\n\n",
									//	SQLNullToChar(ColNullable[i],TempType1),SQLNullToChar(cnull,TempType2));
								}
								else
								{
									TEST_FAILED;	
									if (cstrcmp(cn,colname[icol-1],FALSE,isCharSet) != 0)
										LogMsg(ERRMSG,"colname expect: %s and actual: %s are not matched\n",colname[icol-1],cn);
									if (cl != colsize)
										LogMsg(ERRMSG,"ColNameLen expect: %d and actual: %d are not matched\n",colsize,cl);
									if (st != SQLType[icol-1])
										LogMsg(ERRMSG,"SQLType expect: %s and actual: %s are not matched\n",
											SQLTypeToChar(SQLType[icol-1],TempType1),SQLTypeToChar(st,TempType2));
									if (cp != ColPrec[icol-1])
										LogMsg(ERRMSG,"ColPrec expect: %d and actual: %d are not matched\n",ColPrec[icol-1],cp);
									if (cs != ColScale[icol-1])
										LogMsg(ERRMSG,"ColScale expect: %d and actual: %d are not matched\n",ColScale[icol-1],cs);
									if (cnull != ColNullable[i])
										LogMsg(ERRMSG,"ColNullable expect: %s and actual: %s are not matched\n\n",
											SQLNullToChar(ColNullable[i],TempType1),SQLNullToChar(cnull,TempType2));
								}
							}
						}
					}
					SQLFreeStmt(hstmt,SQL_CLOSE);
					SQLExecDirect(hstmt,(SQLCHAR*) ExecDirStr[i],SQL_NTS); 
				}
			}
			TESTCASE_END;
		} /* iend loop */
	} /* lend loop */
	SQLFreeHandle(SQL_HANDLE_STMT, hstmt);
	FullDisconnect3(pTestInfo);
	LogMsg(SHORTTIMESTAMP+LINEAFTER,"End testing API => MX Specific SQLDescribeColumns.\n");
	free_list(var_list);
	TEST_RETURN;
}
Beispiel #11
0
//---------------------------------------------------------
//   TestSQLAllocStmt()
//---------------------------------------------------------
PassFail TestSQLAllocStmt (TestInfo *pTestInfo, int MX_MP_SPECIFIC)
{
	TEST_DECLARE;
 	char			Heading[MAX_STRING_SIZE];
 	RETCODE			returncode;
 	SQLHANDLE 		henv;
 	SQLHANDLE 		hdbc;
 	SQLHANDLE		hstmt[NUM_STMT];
	//RETCODE		AsyncStmt[NUM_ASYNC_STMT];
	char			*StmtHndlStr;
	int				i = 0, j = 0, k = 0;
	int				AnyAsync;
	int				AsyncOper[] = {CREATE_TABLE,INSERT_TABLE,SELECT_TABLE,DROP_TABLE,999};

	char			*teststmthndl[21];

//===========================================================================================================
	var_list_t *var_list;
	var_list = load_api_vars("SQLAllocateStatement", charset_file);
	if (var_list == NULL) return FAILED;

	teststmthndl[0] = var_mapping("TestStmtHndl_0", var_list);
	teststmthndl[1] = var_mapping("TestStmtHndl_1", var_list);
	teststmthndl[2] = var_mapping("TestStmtHndl_2", var_list);
	teststmthndl[3] = var_mapping("TestStmtHndl_3", var_list);
	teststmthndl[4] = var_mapping("TestStmtHndl_4", var_list);
	teststmthndl[5] = var_mapping("TestStmtHndl_5", var_list);
	teststmthndl[6] = var_mapping("TestStmtHndl_6", var_list);
	teststmthndl[7] = var_mapping("TestStmtHndl_7", var_list);
	teststmthndl[8] = var_mapping("TestStmtHndl_8", var_list);
	teststmthndl[9] = var_mapping("TestStmtHndl_9", var_list);
	teststmthndl[10] = var_mapping("TestStmtHndl_10", var_list);
	teststmthndl[11] = var_mapping("TestStmtHndl_11", var_list);
	teststmthndl[12] = var_mapping("TestStmtHndl_12", var_list);
	teststmthndl[13] = var_mapping("TestStmtHndl_13", var_list);
	teststmthndl[14] = var_mapping("TestStmtHndl_14", var_list);
	teststmthndl[15] = var_mapping("TestStmtHndl_15", var_list);
	teststmthndl[16] = var_mapping("TestStmtHndl_16", var_list);
	teststmthndl[17] = var_mapping("TestStmtHndl_17", var_list);
	teststmthndl[18] = var_mapping("TestStmtHndl_18", var_list);
	teststmthndl[19] = var_mapping("TestStmtHndl_19", var_list);
	teststmthndl[20] = var_mapping("TestStmtHndl_20", var_list);
//======================================================================================

	if (MX_MP_SPECIFIC == MX_SPECIFIC)
		LogMsg(LINEBEFORE+SHORTTIMESTAMP,"Begin testing API => MX specific SQLAllocStmt | SQLAllocStmt | alocstmt.c\n");
	else
		LogMsg(LINEBEFORE+SHORTTIMESTAMP,"Begin testing API => MP specific SQLAllocStmt | SQLAllocStmt | alocstmt.c\n");

	TEST_INIT;

	TESTCASE_BEGIN("Setup for SQLAllocStmt/SQLFreeStmt tests\n");

	/* 6-5-00:
	Need to turn Autocommit off since MX will close all open cursors that are
	open if the end of ANY of the cursors is reached. */
	if(!FullConnectWithOptions(pTestInfo, CONNECT_ODBC_VERSION_2))
	{
		LogMsg(NONE,"Unable to connect\n");
		TEST_FAILED;
		TEST_RETURN;
	}

	henv = pTestInfo->henv;
 	hdbc = pTestInfo->hdbc;
	//set the connection attribute to SQL_AUTOCOMMIT_OFF to enable use of multiple stmt  without errors 
	SQLSetConnectAttr((SQLHANDLE)hdbc, SQL_ATTR_AUTOCOMMIT, SQL_AUTOCOMMIT_OFF, SQL_IS_UINTEGER);

	TESTCASE_END;  // end of setup

	StmtHndlStr = (char *)malloc(MAX_NOS_SIZE);

//====================================================================================================
// General statement handle exercise testcases.

	for (k = 0; k < 2; k++)
	{
		for (i = 0; i < NUM_STMT; i++)
		{
			hstmt[i] = (SQLHANDLE)pTestInfo->hstmt;

			sprintf(Heading,"SQLAllocstmt: Test #%d\n",i);
			TESTCASE_BEGIN(Heading);
			returncode = SQLAllocStmt((SQLHANDLE)hdbc, &hstmt[i]);
			if(!CHECKRC(SQL_SUCCESS,returncode,"SQLAllocStmt"))
			{
				TEST_FAILED;
				LogAllErrors(henv,hdbc,hstmt[i]);
			}
			TESTCASE_END;
			if (returncode == SQL_SUCCESS)
			{
		 		if (i == 0)									// cleanup 
				{
					for (j = 0; j < NUM_STMT; j++)
					{
						SQLExecDirect(hstmt[0],StmtQueries(DROP_TABLE,teststmthndl[j],StmtHndlStr),SQL_NTS); 
					}
				}
				sprintf(Heading,"SQLAllocStmt: create table teststmthndl%d\n",i+1);
				TESTCASE_BEGIN(Heading);
				if (k == 0)	// prepare & execute 
				{
					returncode = SQLPrepare(hstmt[i],StmtQueries(CREATE_TABLE,teststmthndl[i],StmtHndlStr),SQL_NTS); 
					if(!CHECKRC(SQL_SUCCESS,returncode,"SQLPrepare"))
					{
						TEST_FAILED;
						LogAllErrors(henv,hdbc,hstmt[i]);
					}
					else{
						returncode = SQLExecute(hstmt[i]);
						if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecute")){
							TEST_FAILED;
							LogAllErrors(henv,hdbc,hstmt[i]);
							}
						}
					}
				else	// execdirect 
				{
					returncode = SQLExecDirect(hstmt[i],StmtQueries(CREATE_TABLE,teststmthndl[i],StmtHndlStr),SQL_NTS);
					if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect"))
					{
						TEST_FAILED;
						LogAllErrors(henv,hdbc,hstmt[i]);
					}
				}
				}
				if (returncode == SQL_SUCCESS) TESTCASE_END;
			}

		for (i = 0; i < NUM_STMT; i++)
		{
			sprintf(Heading,"SQLAllocStmt: inserts on Stmt Handle(%d)\n",i);
			TESTCASE_BEGIN(Heading);
			if (k == 0)	// prepare & execute 
			{
				returncode = SQLPrepare(hstmt[i],StmtQueries(INSERT_TABLE,teststmthndl[i],StmtHndlStr),SQL_NTS); 
				if(!CHECKRC(SQL_SUCCESS,returncode,"SQLPrepare"))
				{
					TEST_FAILED;
					LogAllErrors(henv,hdbc,hstmt[i]);
				}
				else
				{
					returncode = SQLExecute(hstmt[i]);
					if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecute"))
					{
						TEST_FAILED;
						LogAllErrors(henv,hdbc,hstmt[i]);
					}
				}
			}
			else	// execdirect 
			{
				returncode = SQLExecDirect(hstmt[i],StmtQueries(INSERT_TABLE,teststmthndl[i],StmtHndlStr),SQL_NTS); 
				if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect"))
				{
					TEST_FAILED;
					LogAllErrors(henv,hdbc,hstmt[i]);
				}
			}
			if (returncode == SQL_SUCCESS)TESTCASE_END;
		}

		for (i = 0; i < NUM_STMT; i++)
		{
			sprintf(Heading,"SQLAllocStmt: selects on Stmt Handle(%d)\n",i);
			TESTCASE_BEGIN(Heading);
			if (k == 0)	// prepare & execute 
			{
				returncode = SQLPrepare(hstmt[i],StmtQueries(SELECT_TABLE,teststmthndl[i],StmtHndlStr),SQL_NTS); 
				if(!CHECKRC(SQL_SUCCESS,returncode,"SQLPrepare"))
				{
					TEST_FAILED;
					LogAllErrors(henv,hdbc,hstmt[i]);
				}
				else{
					returncode = SQLExecute(hstmt[i]);
					if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecute")){
						TEST_FAILED;
						LogAllErrors(henv,hdbc,hstmt[i]);
						}
					}
			}
			else	// execdirect 
			{
				returncode = SQLExecDirect(hstmt[i],StmtQueries(SELECT_TABLE,teststmthndl[i],StmtHndlStr),SQL_NTS); 
				if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect"))
				{
					TEST_FAILED;
					LogAllErrors(henv,hdbc,hstmt[i]);
				}
			}
			if (returncode == SQL_SUCCESS) TESTCASE_END;
		}

		for (i = (NUM_STMT-1); i > -1; i--)
		{
			sprintf(Heading,"SQLAllocStmt: fetches on selects on Stmt Handle(%d)\n",i);
			TESTCASE_BEGIN(Heading);
			returncode = SQLFetch(hstmt[i]);
			if(!CHECKRC(SQL_SUCCESS,returncode,"SQLFetch"))
			{
				TEST_FAILED;
				LogAllErrors(henv,hdbc,hstmt[i]);
			}			
			if (returncode == SQL_SUCCESS) TESTCASE_END;
		}

		for (i = 0; i < NUM_STMT; i++)
		{
			sprintf(Heading,"SQLAllocStmt: SQLFreeStmt(%d) with SQL_CLOSE\n",i);
			TESTCASE_BEGIN(Heading);
			returncode = SQLFreeStmt(hstmt[i],SQL_CLOSE);
			if(!CHECKRC(SQL_SUCCESS,returncode,"SQLFreeStmt"))
			{
				TEST_FAILED;
				LogAllErrors(henv,hdbc,hstmt[i]);
			}
			else{
				TESTCASE_END;
				}

			if (i == (NUM_STMT-1))					// cleanup 
			{
				for (j = 0; j < NUM_STMT; j++)
				{
					SQLExecDirect(hstmt[0],StmtQueries(DROP_TABLE,teststmthndl[j],StmtHndlStr),SQL_NTS); 
				}
			}
		}

		for (i = 0; i < NUM_STMT; i++)
		{
			sprintf(Heading,"SQLAllocStmt: SQLFreeStmt(%d) with SQL_DROP\n",i);
			TESTCASE_BEGIN(Heading);
			returncode = SQLFreeStmt(hstmt[i],SQL_DROP);
			if(!CHECKRC(SQL_SUCCESS,returncode,"SQLFreeStmt"))
			{
				TEST_FAILED;
				LogAllErrors(henv,hdbc,hstmt[i]);
			}
			else{
				TESTCASE_END;
				}
		}

		sprintf(Heading,"SLQAllocStmt: same sql operations on different of SQLAllocstmt(%d)s\n",i);
		TESTCASE_BEGIN(Heading);
 		for (i = 0; i < NUM_STMT; i++)
		{
			hstmt[i] = (SQLHANDLE)pTestInfo->hstmt;
			returncode = SQLAllocStmt((SQLHANDLE)hdbc, &hstmt[i]);
			if(!CHECKRC(SQL_SUCCESS,returncode,"SQLAllocStmt"))
			{
				TEST_FAILED;
				LogAllErrors(henv,hdbc,hstmt[i]);
			}
			if (returncode == SQL_SUCCESS)
			{
		 		if (i == 0)									// cleanup
				{
					SQLExecDirect(hstmt[0],StmtQueries(DROP_TABLE,teststmthndl[20],StmtHndlStr),SQL_NTS); 
					returncode = SQLExecDirect(hstmt[0],StmtQueries(CREATE_TABLE,teststmthndl[20],StmtHndlStr),SQL_NTS); 
					if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect"))
					{
						TEST_FAILED;
						LogAllErrors(henv,hdbc,hstmt[0]);
					}			
				}
				if (k == 0)	// prepare & execute 
				{
					returncode = SQLPrepare(hstmt[i],StmtQueries(INSERT_TABLE,teststmthndl[20],StmtHndlStr),SQL_NTS);
					if(!CHECKRC(SQL_SUCCESS,returncode,"SQLPrepare"))
					{
						TEST_FAILED;
						LogAllErrors(henv,hdbc,hstmt[i]);
					}			
					returncode = SQLExecute(hstmt[i]);
					if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecute"))
					{
						TEST_FAILED;
						LogAllErrors(henv,hdbc,hstmt[i]);
					}
				}
				else	// execdirect
				{
					returncode = SQLExecDirect(hstmt[i],StmtQueries(INSERT_TABLE,teststmthndl[20],StmtHndlStr),SQL_NTS);
					if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect"))
					{
						TEST_FAILED;
						LogAllErrors(henv,hdbc,hstmt[i]);
					}
				}
				if (k == 0)	// prepare & execute 
				{
					returncode = SQLPrepare(hstmt[i],StmtQueries(SELECT_TABLE,teststmthndl[20],StmtHndlStr),SQL_NTS);
					if(!CHECKRC(SQL_SUCCESS,returncode,"SQLPrepare"))
					{
						TEST_FAILED;
						LogAllErrors(henv,hdbc,hstmt[i]);
					}			
					returncode = SQLExecute(hstmt[i]);
					if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecute"))
					{
						TEST_FAILED;
						LogAllErrors(henv,hdbc,hstmt[i]);
					}
				}
				else
				{
					returncode = SQLExecDirect(hstmt[i],StmtQueries(SELECT_TABLE,teststmthndl[20],StmtHndlStr),SQL_NTS);
					if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect"))
					{
						TEST_FAILED;
						LogAllErrors(henv,hdbc,hstmt[i]);
					}
				}
				returncode = SQLFetch(hstmt[i]); 
				if(!CHECKRC(SQL_SUCCESS,returncode,"SQLFetch"))
				{
					TEST_FAILED;
					LogAllErrors(henv,hdbc,hstmt[i]);
				}
			}
		}
 		for (i = 0; i < NUM_STMT; i++)
		{
			returncode = SQLFreeStmt(hstmt[i],SQL_CLOSE);
			if(!CHECKRC(SQL_SUCCESS,returncode,"SQLAllocStmt"))
			{
				TEST_FAILED;
				LogAllErrors(henv,hdbc,hstmt[i]);
			}
			if (i == 0)
			{
				SQLExecDirect(hstmt[0],StmtQueries(DROP_TABLE,teststmthndl[20],StmtHndlStr),SQL_NTS); 
			}
			returncode = SQLFreeStmt(hstmt[i],SQL_DROP);
			if(!CHECKRC(SQL_SUCCESS,returncode,"SQLFreeStmt"))
			{
				TEST_FAILED;
				LogAllErrors(henv,hdbc,hstmt[i]);
			}
		}
		TESTCASE_END;
	}

//====================================================================================================
// Asynchronus Testcases

	if (MX_MP_SPECIFIC == MX_SPECIFIC)
	{
		for (i = 0; i < NUM_ASYNC_STMT; i++)
		{
			hstmt[i] = (SQLHANDLE)pTestInfo->hstmt;
			// Creating statement handles
			sprintf(Heading,"SQLAllocstmt: Test #%d and Enable the ASYNC MODE ON.\n",i);
			TESTCASE_BEGIN(Heading);
			returncode = SQLAllocStmt((SQLHANDLE)hdbc, &hstmt[i]);
			if(!CHECKRC(SQL_SUCCESS,returncode,"SQLAllocStmt"))
			{
				TEST_FAILED;
				LogAllErrors(henv,hdbc,hstmt[i]);
			}
			else
			{
		 		if (i == 0)									// cleanup 
				{
					// Creating tables to be used by each of the stmt handles
					for (j = 0; j < NUM_ASYNC_STMT; j++)
					{
						SQLExecDirect(hstmt[0],StmtQueries(DROP_TABLE,teststmthndl[j],StmtHndlStr),SQL_NTS); 
					}
				}
				// Putting each stmthandle into Asynchronus mode
				returncode = SQLSetStmtOption(hstmt[i],SQL_ASYNC_ENABLE,SQL_ASYNC_ENABLE_ON);
				if(!CHECKRC(SQL_SUCCESS,returncode,"SQLSetStmtOptions"))
				{
					TEST_FAILED;
					LogAllErrors(henv,hdbc,hstmt[i]);
				}
			}
			TESTCASE_END;
		}

		// Running the Asynchronus tests
		// WHAT IS GOING ON
		//   Two tests cases are being checked:
		//     1. That the status of an asynchronus stmt handle CAN be checked.
		//     2. That the stmt handle completes correctly.
		//
		// HOW IT'S BEING RUN
		//   Steps being performed until all handles are no longer executing:
		//     1. Prepare the async test data structure.
		//     2. Generate table name based on statement handle being used.
		//     3. If handle's status has not been checked already, check as test case 1.
		//        Else, check it's status NOT as a test case.
		//     4. Run the statement (also used to check the status of the handle).
		//     5. If the stmt completes, verify that it does so successfully. Test case 2.
		//
		//   Once all of the handles have completed, perform the next Async Operation
		//   until the terminating operation (a.k.a "999") is reached.
		k = 0;
		while (AsyncOper[k] != 999)
		{
			// 1. Preparing the async test data structure
			for (i = 0; i < NUM_ASYNC_STMT; i++)
			{
				AsyncStmt[i].status = SQL_STILL_EXECUTING;
				AsyncStmt[i].checked = FALSE;
			}
			AnyAsync = 1;
			// Testing begins
			while (AnyAsync > 0)
			{
				for (i = 0; i < NUM_ASYNC_STMT; i++)
				{
					if (AsyncStmt[i].status == SQL_STILL_EXECUTING)
					{
						// 3. Has the handle been checked for its status?
						if (AsyncStmt[i].checked)
						{
							// 4. Run the statement.
							returncode = SQLExecDirect(hstmt[i],StmtQueries(AsyncOper[k],teststmthndl[i],StmtHndlStr),SQL_NTS);
							AsyncStmt[i].status = returncode;
							// 5. Result Test: Verifying that the statement completes correctly.
							if (returncode != SQL_STILL_EXECUTING)
							{
								sprintf(Heading,"SQLAllocStmt: Result Test: %d; SQLStmt: %s.\n",i,StmtQueries(AsyncOper[k],teststmthndl[i],StmtHndlStr));
								TESTCASE_BEGIN(Heading);
								if (returncode != SQL_SUCCESS)
								{
									TEST_FAILED;
									LogAllErrors(henv,hdbc,hstmt[i]);
								}
								TESTCASE_END;
							}
						}
						else
						{
							// Status Test (Test case 1):
							// Only EXECUTING and SUCCESS are acceptable, others are errors.
							//   This test is only run once!
							sprintf(Heading,"SQLAllocStmt: Status Test: %d; SQLStmt: %s.\n",i,StmtQueries(AsyncOper[k],teststmthndl[i],StmtHndlStr));
							TESTCASE_BEGIN(Heading);
							
							// 4. Run the statement.
							returncode = SQLExecDirect(hstmt[i],StmtQueries(AsyncOper[k],teststmthndl[i],StmtHndlStr),SQL_NTS);
							AsyncStmt[i].status = returncode;
							AsyncStmt[i].checked = TRUE;
							if ((returncode != SQL_STILL_EXECUTING) && (returncode != SQL_SUCCESS))
							{
								TEST_FAILED;
								LogAllErrors(henv,hdbc,hstmt[i]);
							}
							TESTCASE_END;
							
							// 5. If the stmt completes, verify that it does so successfully.
							if (returncode != SQL_STILL_EXECUTING)
							{
								// Result Test: Verifying that the stmt completes successfully.
								sprintf(Heading,"SQLAllocStmt: Result Test: %d; SQLStmt: %s.\n",i,StmtQueries(AsyncOper[k],teststmthndl[i],StmtHndlStr));
								TESTCASE_BEGIN(Heading);
								if (returncode != SQL_SUCCESS)
								{
									TEST_FAILED;
									LogAllErrors(henv,hdbc,hstmt[i]);
								}
								TESTCASE_END;
							}
							//Sleep (500);
						}
					}
				}
				AnyAsync = 0;
				for (i = 0; i < NUM_ASYNC_STMT; i++)
				{
					if (AsyncStmt[i].status == SQL_STILL_EXECUTING)
					{
						AnyAsync = AnyAsync + 1;
					}
				}
			}

			// Special tests for Fetching after doing a SELECT
			// Steps are identical to the above steps.
			if (AsyncOper[k] == SELECT_TABLE)
			{
				// Preparing data structure
				for (i = 0; i < NUM_ASYNC_STMT; i++)
				{
					AsyncStmt[i].status = SQL_STILL_EXECUTING;
					AsyncStmt[i].checked = FALSE;
				}
				AnyAsync = 1;
				// Select testing begins
				while (AnyAsync > 0)
				{
					for (i = 0; i < NUM_ASYNC_STMT; i++)
					{
						if (AsyncStmt[i].status == SQL_STILL_EXECUTING)
						{
							if (AsyncStmt[i].checked)
							{
								returncode = SQLFetch(hstmt[i]);
								AsyncStmt[i].status = returncode;									
								if (returncode != SQL_STILL_EXECUTING)
								{
									// Result Test
									sprintf(Heading,"SQLAllocStmt: Result Test:%d; performing SQLFetch.\n",i);
									TESTCASE_BEGIN(Heading);
									if (returncode != SQL_SUCCESS)
									{
										TEST_FAILED;
										LogAllErrors(henv,hdbc,hstmt[i]);
									}
									TESTCASE_END;
								}
							}
							else
							{
								// Status Test
								sprintf(Heading,"SQLAllocStmt: Status Test:%d; performing SQLFetch.\n",i);
								TESTCASE_BEGIN(Heading);
								returncode = SQLFetch(hstmt[i]);
								AsyncStmt[i].status = returncode;
								AsyncStmt[i].checked = TRUE;
								if ((returncode != SQL_STILL_EXECUTING) && (returncode != SQL_SUCCESS))
								{
									TEST_FAILED;
									LogAllErrors(henv,hdbc,hstmt[i]);
								}
								TESTCASE_END;

								// Result Test
								if (returncode != SQL_STILL_EXECUTING)
								{
									sprintf(Heading,"SQLAllocStmt: Result Test:%d; performing SQLFetch.\n",i);
									TESTCASE_BEGIN(Heading);
									if (returncode != SQL_SUCCESS)
									{
										TEST_FAILED;
										LogAllErrors(henv,hdbc,hstmt[i]);
									}
									TESTCASE_END;
								}
							}
						}
					}
					AnyAsync = 0;
					for (i = 0; i < NUM_ASYNC_STMT; i++)
					{
						if (AsyncStmt[i].status == SQL_STILL_EXECUTING)
						{
							AnyAsync = AnyAsync + 1;
						}
					}
				}
				// Closing the cursor from the SELECT stmt result set.
				for (i = 0; i < NUM_ASYNC_STMT; i++)
				{
					sprintf(Heading,"SQLFreeStmt: %d.\n",i);
					TESTCASE_BEGIN(Heading);
					returncode = SQLFreeStmt(hstmt[i],SQL_CLOSE);
					if(!CHECKRC(SQL_SUCCESS,returncode,"SQLFreeStmt"))
					{
						TEST_FAILED;
						LogAllErrors(henv,hdbc,hstmt[i]);
					}
					TESTCASE_END;
				}
			} // End of async SELECT test.

			// Resetting the checked status for the next operation.
			for (i = 0; i < NUM_ASYNC_STMT; i++)
			{
				AsyncStmt[i].checked = FALSE;
			}

			k++;
		}
	}
//====================================================================================================

	free(StmtHndlStr);
	returncode = SQLDisconnect((SQLHANDLE)hdbc);
    if(!CHECKRC(SQL_ERROR,returncode,"SQLDisconnect")) 
	{
		TEST_FAILED;	
		LogAllErrorsVer3(henv,hdbc,hstmt[0]);
	}	
	
	// Free the open transactions.
	returncode=SQLTransact((SQLHANDLE)henv,(SQLHANDLE)hdbc,SQL_ROLLBACK);
	Sleep(2);	

	returncode=FullDisconnect(pTestInfo);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLFullDisconnect"))
	{
		TEST_FAILED;
		LogAllErrorsVer3(henv,hdbc,hstmt[0]);
	}
	
	LogMsg(SHORTTIMESTAMP+LINEAFTER,"End testing API => SQLAllocStmt.\n");

	free_list(var_list);

	TEST_RETURN;
}
Beispiel #12
0
/*
---------------------------------------------------------
   TestHash2
---------------------------------------------------------
*/
PassFail TestHash2(TestInfo *pTestInfo)
{                  
	TEST_DECLARE;
	SQLRETURN		returncode;      
	SQLHENV			henv = 0;
	SQLHDBC			hdbc = 0;
	SQLHSTMT		hstmt= 0;
	SQLUSMALLINT	ParamStatusArray[ARRAY_SIZE];
	SQLUSMALLINT	expParamStatusArray[ARRAY_SIZE];
	SQLUSMALLINT	lastExpParamStatusArray[ARRAY_SIZE];
	SQLULEN			lastParamsProcessed=ARRAY_SIZE, ParamsProcessed = 0;
	SQLLEN			rowcount = 0, expRowcount = 0, lastExpRowcount = 0;
	int				i,j,k,counter = 1, loopcount = 0;
	TCHAR			buffer[256];

	typedef struct {
    		TCHAR	num[15];	SQLLEN numLenOrInd;
    		TCHAR	val[15];	SQLLEN valLenOrInd;
	}nameStruct;
	nameStruct  nameArray1[ARRAY_SIZE];

	SQLUINTEGER mode = 1; 
	SQLUINTEGER startnode = 2;
	SQLUINTEGER streams_per_node = 4;
	SQLUINTEGER delay_error = 1;
	SQLUINTEGER suggested_rowset_size=0;

	SQLTCHAR *sqlDrvInsert = (SQLTCHAR*)_T("PLANLOADTABLE HASH2_TABLE");
	SQLTCHAR *dropTbl = (SQLTCHAR *)_T("DROP TABLE HASH2_TABLE cascade");
	SQLTCHAR *crtTbl = (SQLTCHAR *)_T("CREATE TABLE HASH2_TABLE (A int NOT NULL NOT DROPPABLE, B varchar(10), PRIMARY KEY (A))");
	SQLTCHAR *insTbl = (SQLTCHAR *)_T("INSERT INTO HASH2_TABLE values (?,?)");
//	SQLTCHAR *selTbl = (SQLTCHAR *)_T("SELECT * HASH2_TABLE");

	//==================================================================================================
	LogMsg(LINEBEFORE+SHORTTIMESTAMP,_T("Begin testing feature => Hash2.\n"));
	TEST_INIT;

	returncode = SQLAllocEnv(&henv);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLAllocEnv"))
	{
		LogAllErrors(henv,hdbc,hstmt);
		TEST_FAILED;
		TEST_RETURN;
	}

	returncode = SQLAllocConnect( henv, &hdbc);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLAllocConnect"))
	{
		LogAllErrors(henv,hdbc,hstmt);
		TEST_FAILED;
		TEST_RETURN;
	}

	returncode = SQLSetConnectAttr(hdbc, SQL_ATTR_AUTOCOMMIT, (SQLPOINTER)SQL_AUTOCOMMIT_ON,0);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLSetConnectAttr"))
	{
		LogAllErrors(henv,hdbc,hstmt);
		TEST_FAILED;
		TEST_RETURN;
	}

	//==================================================================================================
	// Set Mode to Loader
	returncode = SQLSetConnectAttr(hdbc, SQL_MODE_LOADER, (void *) mode, 0);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQL_MODE_LOADER"))
	{
		LogAllErrors(henv,hdbc,hstmt);
		TEST_FAILED;
		TEST_RETURN;
	}

	// Set Start mode
	returncode = SQLSetConnectAttr(hdbc,  SQL_START_NODE,  (void *) startnode,  0);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQL_START_NODE"))
	{
		LogAllErrors(henv,hdbc,hstmt);
		TEST_FAILED;
		TEST_RETURN;
	}

	// Set Desired Streams Per Node
	returncode = SQLSetConnectAttr(hdbc,  SQL_STREAMS_PER_SEG,  (void *) streams_per_node,  0);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQL_STREAMS_PER_SEG"))
	{
		LogAllErrors(henv,hdbc,hstmt);
		TEST_FAILED;
		TEST_RETURN;
	}

	// Set delay_error mode
	returncode = SQLSetConnectAttr(hdbc,  SQL_LOADER_DELAYERROR, (void *) delay_error, 0);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQL_LOADER_DELAYERROR"))
	{
		LogAllErrors(henv,hdbc,hstmt);
		TEST_FAILED;
		TEST_RETURN;
	}
	//==================================================================================================

	returncode = SQLConnect(hdbc,
					   (SQLTCHAR*)pTestInfo->DataSource,(SWORD)_tcslen(pTestInfo->DataSource),
					   (SQLTCHAR*)pTestInfo->UserID,(SWORD)_tcslen(pTestInfo->UserID),
					   (SQLTCHAR*)pTestInfo->Password,(SWORD)_tcslen(pTestInfo->Password)
					   );
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLConnect"))
	{
		LogAllErrors(henv,hdbc,hstmt);
		TEST_FAILED;
		TEST_RETURN;
	}

	returncode = SQLAllocStmt(hdbc, &hstmt);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLConnect"))
	{
		LogAllErrors(henv,hdbc,hstmt);
		TEST_FAILED;
		TEST_RETURN;
	}

	returncode = SQLExecDirect(hstmt, dropTbl, SQL_NTS);
	returncode = SQLExecDirect(hstmt, crtTbl, SQL_NTS);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect"))
	{
		LogAllErrors(henv,hdbc,hstmt);
		TEST_FAILED;
		TEST_RETURN;
	}

	returncode = SQLPrepare(hstmt, (SQLTCHAR *) sqlDrvInsert, SQL_NTS);
	if (returncode != SQL_SUCCESS) {
		LogMsg(ERRMSG,_T("PLANLOADTABLE is expected to return SQL_SUCCESS, actual is %d\n"), returncode);
		LogAllErrors(henv,hdbc,hstmt);
		TEST_FAILED;
		TEST_RETURN;
	}

	returncode = SQLGetConnectAttr(hdbc, SQL_ATTR_SUG_ROWSET_SIZE, &suggested_rowset_size, 0, NULL);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQL_ATTR_SUG_ROWSET_SIZE"))
	{
		LogAllErrors(henv,hdbc,hstmt);
		TEST_FAILED;
		TEST_RETURN;
	}
	LogMsg(LINEAFTER,_T("suggested_rowset_size=%d\n"), suggested_rowset_size);

	//==================================================================================================
	// Set the SQL_ATTR_PARAM_BIND_TYPE statement attribute to use row-wise binding.
	returncode = SQLSetStmtAttr(hstmt, SQL_ATTR_PARAM_BIND_TYPE, (void *)sizeof(nameStruct), 0);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQL_ATTR_PARAM_BIND_TYPE"))
	{
		LogAllErrors(henv,hdbc,hstmt);
		TEST_FAILED;
		TEST_RETURN;
	}
	// Specify the number of elements in each parameter array.
	returncode = SQLSetStmtAttr(hstmt, SQL_ATTR_PARAMSET_SIZE, (void *)ARRAY_SIZE, 0);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQL_ATTR_PARAMSET_SIZE"))
	{
		LogAllErrors(henv,hdbc,hstmt);
		TEST_FAILED;
		TEST_RETURN;
	}
	// Specify an array in which to return the status of each set of parameters.
	returncode = SQLSetStmtAttr(hstmt, SQL_ATTR_PARAM_STATUS_PTR, ParamStatusArray, 0);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQL_ATTR_PARAM_STATUS_PTR"))
	{
		LogAllErrors(henv,hdbc,hstmt);
		TEST_FAILED;
		TEST_RETURN;
	}
	// Specify an SQLUINTEGER value in which to return the number of sets of parameters processed.
	returncode = SQLSetStmtAttr(hstmt, SQL_ATTR_PARAMS_PROCESSED_PTR, &ParamsProcessed, 0);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQL_ATTR_PARAMS_PROCESSED_PTR"))
	{
		LogAllErrors(henv,hdbc,hstmt);
		TEST_FAILED;
		TEST_RETURN;
	}

	returncode = SQLPrepare(hstmt, insTbl, SQL_NTS);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLPrepare"))
	{
		LogAllErrors(henv,hdbc,hstmt);
		TEST_FAILED;
		TEST_RETURN;
	}

	returncode = SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_TCHAR, SQL_INTEGER, 10, 0,
                 &nameArray1[0].num, 300, &nameArray1[0].numLenOrInd);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindParameter"))
	{
		LogAllErrors(henv,hdbc,hstmt);
		TEST_FAILED;
		TEST_RETURN;
	}
	returncode = SQLBindParameter(hstmt, 2, SQL_PARAM_INPUT, SQL_C_TCHAR, SQL_WCHAR, 10, 0,
                 &nameArray1[0].val, 300, &nameArray1[0].valLenOrInd);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindParameter"))
	{
		LogAllErrors(henv,hdbc,hstmt);
		TEST_FAILED;
		TEST_RETURN;
	}

	for (j=0; j<ARRAY_SIZE; j++) {
		lastExpParamStatusArray[j] = SQL_PARAM_SUCCESS;
		expParamStatusArray[j] = SQL_PARAM_SUCCESS;
	}

	//==================================================================================================
	TESTCASE_BEGIN("Test the positive functionality of Hash2, with delay_error mode ON.\n");
	loopcount = 4;
	k = 0;
	while ( k < (loopcount+1)) {
		expRowcount = 0;

		if (k==loopcount) { //Send a dummy rowsets to get the status array of the previous rowsets in delay-mode
			LogMsg(LINEAFTER,_T("Insert dummy rowsets with size=0\n"));
			returncode = SQLSetStmtAttr(hstmt, SQL_ATTR_PARAMSET_SIZE, (void *)0, 0);
			if(!CHECKRC(SQL_SUCCESS,returncode,"SQL_ATTR_PARAMSET_SIZE"))
			{
				LogAllErrors(henv,hdbc,hstmt);
				TEST_FAILED;
				TEST_RETURN;
			}
		}
		else {
			_stprintf(buffer, _T("Data inserted: "));
			for (j=0; j<ARRAY_SIZE; j++) {
				if ((j+1)%(3+2*k) == 0) {
					counter--;
					expParamStatusArray[j] = SQL_PARAM_ERROR;
				}
				else {
					expParamStatusArray[j] = SQL_PARAM_SUCCESS;
					expRowcount++;
				}
				_stprintf(nameArray1[j].num,_T("%d"),counter++);
				nameArray1[j].numLenOrInd = SQL_NTS;
				_stprintf(nameArray1[j].val,_T("%s"),_T("chochet"));
				nameArray1[j].valLenOrInd = SQL_NTS;
				_tcscat(buffer,nameArray1[j].num);
				_tcscat(buffer,_T(" "));
			}
			_tcscat(buffer,_T("\n"));
		}
		LogMsg(NONE,_T("%s\n"), buffer);

		returncode = SQLExecute(hstmt);
		if (delay_error == 1 && k != 0) {
			if(returncode != SQL_SUCCESS_WITH_INFO)
			{
				LogMsg(ERRMSG,_T("SQLExecute: returncode expected: SQL_SUCCESS_WITH_INFO, actual: %d at line=%d\n"), returncode, __LINE__);
				LogAllErrors(henv,hdbc,hstmt);
				TEST_FAILED;
				TEST_RETURN;
			}
		}
		else {
			if(returncode != SQL_SUCCESS)
			{
				LogMsg(ERRMSG,_T("SQLExecute: returncode expected: SQL_SUCCESS, actual: %d at line=%d\n"), returncode, __LINE__);
				LogAllErrors(henv,hdbc,hstmt);
				TEST_FAILED;
				TEST_RETURN;
			}
		}

		if ((k == loopcount && ParamsProcessed != 0) || (k != loopcount && ParamsProcessed != ARRAY_SIZE)) {
			LogMsg(ERRMSG,_T("ParamsProcessed is not the same as rowset size from client, at line=%d\n"), __LINE__);
			TEST_FAILED;
		}

		returncode = SQLRowCount(hstmt, &rowcount);
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLRowCount"))
		{
			LogAllErrors(henv,hdbc,hstmt);
			TEST_FAILED;
		}

		if (delay_error == 1) {
			if (lastExpRowcount != rowcount) {
				TEST_FAILED;
				LogMsg(ERRMSG,_T("Expected Rowcount=%d, Actual Rowcount=%d\n"), expRowcount, rowcount);
			}
			lastExpRowcount = expRowcount;

			LogMsg(NONE,_T("\n%d last rows processed, %d current rows processed, rowcount=%d\n"), lastParamsProcessed, ParamsProcessed, rowcount);
			for (i = 0; i < (int)lastParamsProcessed; i++) {
   				LogMsg(NONE,_T("Parameter Set  Status\n"));
				LogMsg(NONE,_T("-------------  -------------\n"));
				if (ParamStatusArray[i] != lastExpParamStatusArray[i]) {
					TEST_FAILED;
					LogMsg(ERRMSG,_T("Param status array at row #%d is expected: %d, actual %d\n"), i, lastExpParamStatusArray[i], ParamStatusArray[i]);
					continue;
				}
				switch (ParamStatusArray[i]) {
					case SQL_PARAM_SUCCESS:
					case SQL_PARAM_SUCCESS_WITH_INFO:
         					LogMsg(NONE,_T("%13d  Success\n"), i);
         					break;

      					case SQL_PARAM_ERROR:
         					LogMsg(NONE,_T("%13d  Error  <-------\n"), i);
         					break;

      					case SQL_PARAM_UNUSED:
        					LogMsg(NONE,_T("%13d  Not processed\n"), i);
        					break;

     					case SQL_PARAM_DIAG_UNAVAILABLE:
         					LogMsg(NONE,_T("%13d  Unknown\n"), i);
         					break;
   				}
			}
			LogMsg(NONE,_T("\n============================================================\n"));
			lastParamsProcessed = ParamsProcessed;
			for (j=0; j<ARRAY_SIZE; j++) {
				lastExpParamStatusArray[j] = expParamStatusArray[j];
			}
		}
		else {
			if (expRowcount != rowcount) {
				TEST_FAILED;
				LogMsg(ERRMSG,_T("Expected Rowcount=%d, Actual Rowcount=%d\n"), expRowcount, rowcount);
			}

			LogMsg(NONE,_T("\n%d current rows processed, rowcount=%d\n"), ParamsProcessed, rowcount);
			for (i = 0; i < (int)ParamsProcessed; i++) {
   				LogMsg(NONE,_T("Parameter Set  Status\n"));
				LogMsg(NONE,_T("-------------  -------------\n"));
				if (ParamStatusArray[i] != expParamStatusArray[i]) {
					TEST_FAILED;
					LogMsg(ERRMSG,_T("Param status array at row #%d is expected: %d, actual %d\n"), i, expParamStatusArray[i], ParamStatusArray[i]);
					continue;
				}
				switch (ParamStatusArray[i]) {
					case SQL_PARAM_SUCCESS:
					case SQL_PARAM_SUCCESS_WITH_INFO:
         					LogMsg(NONE,_T("%13d  Success\n"), i);
         					break;

      					case SQL_PARAM_ERROR:
         					LogMsg(NONE,_T("%13d  Error  <-------\n"), i);
         					break;

      					case SQL_PARAM_UNUSED:
        					LogMsg(NONE,_T("%13d  Not processed\n"), i);
        					break;

     					case SQL_PARAM_DIAG_UNAVAILABLE:
         					LogMsg(NONE,_T("%13d  Unknown\n"), i);
         					break;
   				}
			}
			LogMsg(NONE,_T("\n============================================================\n"));
		}
		k++;
	}
	TESTCASE_END;

	SQLFreeStmt( hstmt, SQL_CLOSE );
	SQLFreeStmt( hstmt, SQL_UNBIND );
	SQLDisconnect( hdbc );
	SQLFreeConnect( hdbc );
	SQLFreeEnv( henv );

	//==================================================================================================
	LogMsg(SHORTTIMESTAMP+LINEAFTER,_T("End testing feature => Hash2.\n"));
	TEST_RETURN;
}
Beispiel #13
0
/*
---------------------------------------------------------
   TestSQLBrowseConnect
---------------------------------------------------------
*/
PassFail TestSQLBrowseConnect(TestInfo *pTestInfo)
{                  
	TEST_DECLARE;
	RETCODE		returncode;
	SQLHANDLE 	henv = (SQLHANDLE)NULL, henv1[NUM_ENV_HND];
	SQLHANDLE 	hdbc = (SQLHANDLE)NULL, badhdbc, hdbc1[NUM_ENV_HND * NUM_CONN_HND];
	SQLHANDLE	hstmt = (SQLHANDLE)NULL;
	SQLCHAR 	szConnStrIn[BRWS_LEN], szConnStrOut[BRWS_LEN];
	char		connstr[BRWS_LEN];
	char		tstConnStr[BRWS_LEN];
	SWORD		cbConnStrOut;
	int i = 0, j = 0;

	LogMsg(LINEBEFORE+SHORTTIMESTAMP,"Begin testing API => SQLBrowseConnect | SQLBrowseConnect | browse.c\n");

	TEST_INIT;


//==========================================================================================
   TESTCASE_BEGIN("Test Negative Functionality of SQLBrowseConnect: Invalid CONN handle pointer\n");
	badhdbc = (SQLHANDLE)NULL;
	//strcpy(connstr,"");
	//strcat(connstr,"DSN=");
	//strcat(connstr,pTestInfo->DataSource);
	//strcat(connstr,";");
	//strcat(connstr,"UID=");
	//strcat(connstr,pTestInfo->UserID);
	//strcat(connstr,";");
	//strcat(connstr,"PWD=");
	//strcat(connstr,pTestInfo->Password);
	//strcat(connstr,";");
    strcpy(connstr,"");
    sprintf(connstr, "DSN=%s;UID=%s;PWD=%s;",pTestInfo->DataSource,pTestInfo->UserID,pTestInfo->Password);
	strcpy((char*)szConnStrIn,"");
	strcat((char*)szConnStrIn,connstr);
	returncode = SQLBrowseConnect(badhdbc, szConnStrIn, SQL_NTS, szConnStrOut, BRWS_LEN, &cbConnStrOut);
	if(!CHECKRC(SQL_INVALID_HANDLE,returncode,"SQLBrowseConnect")){
		TEST_FAILED;
		LogAllErrors(henv,hdbc,hstmt);
		}

	SQLDisconnect(badhdbc);
   TESTCASE_END;
//==========================================================================================
   TESTCASE_BEGIN("Test Negative Functionality of SQLBrowseConnect: NULL szConnStrIn\n");
	returncode = SQLAllocEnv(&henv);                 /* Environment handle */
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLAllocEnv")){
		TEST_FAILED;
		TEST_RETURN;
		}

	returncode = SQLAllocConnect(henv, &hdbc);    /* Connection handle  */
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLAllocConnect")){
		LogAllErrors(henv,hdbc,hstmt);
		TEST_FAILED;
		TEST_RETURN;
		}

	returncode = SQLBrowseConnect(hdbc, NULL, SQL_NTS, szConnStrOut, BRWS_LEN, &cbConnStrOut);
	if(!CHECKRC(SQL_ERROR,returncode,"SQLBrowseConnect")){
		TEST_FAILED;
		LogAllErrors(henv,hdbc,hstmt);
		}

	SQLDisconnect(hdbc);
	SQLFreeConnect(hdbc);
	SQLFreeEnv(henv);
   TESTCASE_END;
//==========================================================================================
   TESTCASE_BEGIN("Test Negative Functionality of SQLBrowseConnect: Invalid szConnStrIn length\n");
	returncode = SQLAllocEnv(&henv);                 /* Environment handle */
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLAllocEnv")){
		TEST_FAILED;
		TEST_RETURN;
		}

	returncode = SQLAllocConnect(henv, &hdbc);    /* Connection handle  */
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLAllocConnect")){
		LogAllErrors(henv,hdbc,hstmt);
		TEST_FAILED;
		TEST_RETURN;
		}

	returncode = SQLBrowseConnect(hdbc, szConnStrIn, (SWORD)(strlen(pTestInfo->DataSource)+4), szConnStrOut, BRWS_LEN, &cbConnStrOut);
	if(!CHECKRC(SQL_NEED_DATA,returncode,"SQLBrowseConnect")){
		TEST_FAILED;
		LogAllErrors(henv,hdbc,hstmt);
		}

	SQLDisconnect(hdbc);
	SQLFreeConnect(hdbc);
	SQLFreeEnv(henv);
   TESTCASE_END;
//==========================================================================================
   TESTCASE_BEGIN("Test Negative Functionality of SQLBrowseConnect: zero length\n");
	returncode = SQLAllocEnv(&henv);                 /* Environment handle */
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLAllocEnv")){
		TEST_FAILED;
		TEST_RETURN;
		}

	returncode = SQLAllocConnect(henv, &hdbc);    /* Connection handle  */
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLAllocConnect")){
		LogAllErrors(henv,hdbc,hstmt);
		TEST_FAILED;
		TEST_RETURN;
		}

	returncode = SQLBrowseConnect(hdbc, szConnStrIn,0, szConnStrOut, BRWS_LEN, &cbConnStrOut);
	if(!CHECKRC(SQL_ERROR,returncode,"SQLBrowseConnect")){
		TEST_FAILED;
		LogAllErrors(henv,hdbc,hstmt);
		}

	SQLDisconnect(hdbc);
	SQLFreeConnect(hdbc);
	SQLFreeEnv(henv);
   TESTCASE_END;
//==========================================================================================
   TESTCASE_BEGIN("Test Negative Functionality of SQLBrowseConnect: Invalid DSN\n");
	returncode = SQLAllocEnv(&henv);                 /* Environment handle */
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLAllocEnv")){
		TEST_FAILED;
		TEST_RETURN;
		}

	returncode = SQLAllocConnect(henv, &hdbc);    /* Connection handle  */
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLAllocConnect")){
		LogAllErrors(henv,hdbc,hstmt);
		TEST_FAILED;
		TEST_RETURN;
		}
	strcpy(connstr,"");
	strcat(connstr,"DSN=");
	strcat(connstr,"baddsn");
	strcat(connstr,";");
	strcat(connstr,"UID=");
	strcat(connstr,pTestInfo->UserID);
	strcat(connstr,";");
	strcat(connstr,"PWD=");
	strcat(connstr,pTestInfo->Password);
	strcat(connstr,";");
	returncode = SQLBrowseConnect(hdbc,(SQLCHAR*)connstr,SQL_NTS,szConnStrOut,BRWS_LEN,&cbConnStrOut);
	if(!CHECKRC(SQL_ERROR,returncode,"SQLBrowseConnect")){
		TEST_FAILED;
		LogAllErrors(henv,hdbc,hstmt);
		}

	SQLDisconnect(hdbc);
	SQLFreeConnect(hdbc);
	SQLFreeEnv(henv);
   TESTCASE_END;


//==========================================================================================

	TESTCASE_BEGIN("Test Positive Functionality of SQLBrowseConnect with SQL_NTS\n");

	returncode = SQLAllocEnv(&henv);                 /* Environment handle */
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLAllocEnv")){
		TEST_FAILED;
		TEST_RETURN;
		}

	returncode = SQLAllocConnect(henv, &hdbc);    /* Connection handle  */
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLAllocConnect")){
		LogAllErrors(henv,hdbc,hstmt);
		TEST_FAILED;
		TEST_RETURN;
		}

	returncode = SQLBrowseConnect(hdbc,szConnStrIn,SQL_NTS,szConnStrOut,BRWS_LEN,&cbConnStrOut);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBrowseConnect")){
		TEST_FAILED;
		printf("\nIn string = %s\n",szConnStrIn);
		printf("Out string = %s\n",szConnStrOut);
		LogAllErrors(henv,hdbc,hstmt);
		}

	SQLDisconnect(hdbc);
	SQLFreeConnect(hdbc);
	SQLFreeEnv(henv);
   TESTCASE_END;


//==========================================================================================
   TESTCASE_BEGIN("Test Positive Functionality of SQLBrowseConnect with strlen\n");
	returncode = SQLAllocEnv(&henv);                 // Environment handle 
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLAllocEnv")){
		TEST_FAILED;
		TEST_RETURN;
		}

	returncode = SQLAllocConnect(henv, &hdbc);    // Connection handle  
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLAllocConnect")){
		LogAllErrors(henv,hdbc,hstmt);
		TEST_FAILED;
		TEST_RETURN;
		}

	returncode = SQLBrowseConnect(hdbc,szConnStrIn,(SWORD)strlen((char*)szConnStrIn),szConnStrOut,BRWS_LEN,&cbConnStrOut);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBrowseConnect")){
		TEST_FAILED;
		LogAllErrors(henv,hdbc,hstmt);
		}

	SQLDisconnect(hdbc);
	SQLFreeConnect(hdbc);
	SQLFreeEnv(henv);
   TESTCASE_END;
//==========================================================================================
   TESTCASE_BEGIN("Test Positive Functionality of SQLBrowseConnect to check need data\n");
	returncode = SQLAllocEnv(&henv);                 /* Environment handle */
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLAllocEnv")){
		TEST_FAILED;
		TEST_RETURN;
		}

	returncode = SQLAllocConnect(henv, &hdbc);    /* Connection handle  */
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLAllocConnect")){
		TEST_FAILED;
		TEST_RETURN;
		}

	sprintf(tstConnStr,"DSN=%s;",pTestInfo->DataSource);

	//printf("\nIn string = %s\n",tstConnStr);

	returncode = SQLBrowseConnect(hdbc, (SQLCHAR*)tstConnStr, SQL_NTS, szConnStrOut, BRWS_LEN, &cbConnStrOut);
	if(!CHECKRC(SQL_NEED_DATA,returncode,"SQLBrowseConnect")){
		TEST_FAILED;
		LogAllErrors(henv,hdbc,hstmt);
		}

	strcat(tstConnStr,"UID=");
	strcat(tstConnStr,pTestInfo->UserID);
	strcat(tstConnStr,";");

		//printf("\nIn string = %s\n",tstConnStr);

	returncode = SQLBrowseConnect(hdbc, (SQLCHAR*)tstConnStr, SQL_NTS, szConnStrOut, BRWS_LEN, &cbConnStrOut);
	if((returncode != SQL_NEED_DATA) && (returncode != SQL_SUCCESS)){
		TEST_FAILED;
		LogAllErrors(henv,hdbc,hstmt);
		}

	if(returncode == SQL_NEED_DATA)
	{
		strcat(tstConnStr,"PWD=");
		strcat(tstConnStr,pTestInfo->Password);
		strcat(tstConnStr,";");

		//printf("\nIn string = %s\n",tstConnStr);

		returncode = SQLBrowseConnect(hdbc, (SQLCHAR*)tstConnStr, SQL_NTS, szConnStrOut, BRWS_LEN, &cbConnStrOut);
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBrowseConnect"))
		{
			TEST_FAILED;
			LogAllErrors(henv,hdbc,hstmt);
		}
	}

	SQLDisconnect(hdbc);
	SQLFreeConnect(hdbc);
	SQLFreeEnv(henv);
	TESTCASE_END;

//==========================================================================================

	TESTCASE_BEGIN("Test Positive Functionality of SQLBrowseConnect, SQLDisconnect then SQLBrowseConnect.\n");
	for (i = 0; i < 3; i++)
	{
		returncode = SQLAllocEnv(&henv);                 /* Environment handle */
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLAllocEnv"))
		{
			TEST_FAILED;
			TEST_RETURN;
		}
		returncode = SQLAllocConnect(henv, &hdbc);    /* Connection handle  */
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLAllocConnect"))
		{
			LogAllErrors(henv,hdbc,hstmt);
			TEST_FAILED;
			TEST_RETURN;
		}
		returncode = SQLBrowseConnect(hdbc, szConnStrIn, SQL_NTS, szConnStrOut, BRWS_LEN, &cbConnStrOut);
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLConnect"))
		{
			TEST_FAILED;
			LogAllErrors(henv,hdbc,hstmt);
		}
		switch (i)
		{
			case 0:
				returncode = SQLDisconnect(hdbc);
				if(!CHECKRC(SQL_SUCCESS,returncode,"SQLConnect"))
				{
					TEST_FAILED;
					LogAllErrors(henv,hdbc,hstmt);
				}
				returncode = SQLBrowseConnect(hdbc, szConnStrIn, SQL_NTS, szConnStrOut, BRWS_LEN, &cbConnStrOut);
				if(!CHECKRC(SQL_SUCCESS,returncode,"SQLConnect"))
				{
					TEST_FAILED;
					LogAllErrors(henv,hdbc,hstmt);
				}
				break;
			case 1:
				returncode = SQLDisconnect(hdbc);
				if(!CHECKRC(SQL_SUCCESS,returncode,"SQLConnect"))
				{
					TEST_FAILED;
					LogAllErrors(henv,hdbc,hstmt);
				}
				returncode = SQLFreeConnect(hdbc);
				if(!CHECKRC(SQL_SUCCESS,returncode,"SQLConnect"))
				{
					TEST_FAILED;
					LogAllErrors(henv,hdbc,hstmt);
				}
				returncode = SQLAllocConnect(henv, &hdbc);    /* Connection handle  */
				if(!CHECKRC(SQL_SUCCESS,returncode,"SQLAllocConnect"))
				{
					LogAllErrors(henv,hdbc,hstmt);
					TEST_FAILED;
					TEST_RETURN;
				}
				returncode = SQLBrowseConnect(hdbc, szConnStrIn, SQL_NTS, szConnStrOut, BRWS_LEN, &cbConnStrOut);
				if(!CHECKRC(SQL_SUCCESS,returncode,"SQLConnect"))
				{
					TEST_FAILED;
					LogAllErrors(henv,hdbc,hstmt);
				}
				break;
			case 2:
				returncode = SQLDisconnect(hdbc);
				if(!CHECKRC(SQL_SUCCESS,returncode,"SQLConnect"))
				{
					TEST_FAILED;
					LogAllErrors(henv,hdbc,hstmt);
				}
				returncode = SQLFreeConnect(hdbc);
				if(!CHECKRC(SQL_SUCCESS,returncode,"SQLConnect"))
				{
					TEST_FAILED;
					LogAllErrors(henv,hdbc,hstmt);
				}
				returncode = SQLFreeEnv(henv);
				if(!CHECKRC(SQL_SUCCESS,returncode,"SQLConnect"))
				{
					TEST_FAILED;
					LogAllErrors(henv,hdbc,hstmt);
				}
				returncode = SQLAllocEnv(&henv);                 /* Environment handle */
				if(!CHECKRC(SQL_SUCCESS,returncode,"SQLAllocEnv"))
				{
					TEST_FAILED;
					TEST_RETURN;
				}
				returncode = SQLAllocConnect(henv, &hdbc);    /* Connection handle  */
				if(!CHECKRC(SQL_SUCCESS,returncode,"SQLAllocConnect"))
				{
					LogAllErrors(henv,hdbc,hstmt);
					TEST_FAILED;
					TEST_RETURN;
				}
				returncode = SQLBrowseConnect(hdbc, szConnStrIn, SQL_NTS, szConnStrOut, BRWS_LEN, &cbConnStrOut);
				if(!CHECKRC(SQL_SUCCESS,returncode,"SQLConnect"))
				{
					TEST_FAILED;
					LogAllErrors(henv,hdbc,hstmt);
				}
				break;
			default:
				// End
				break;
		}
		SQLDisconnect(hdbc);
		SQLFreeConnect(hdbc);
		SQLFreeEnv(henv);
	}
  TESTCASE_END;
//==========================================================================================
   TESTCASE_BEGIN("Test Positive Functionality of SQLBrowseConnect with different connection handles\n");
	returncode = SQLAllocEnv(&henv);               
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLAllocEnv")){
		TEST_FAILED;
		TEST_RETURN;
		}

	for (i = 0; i < NUM_CONN_HND; i++){
		returncode = SQLAllocConnect(henv, &hdbc1[i]);    
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLAllocConnect")){
			LogAllErrors(henv,hdbc,hstmt);
			TEST_FAILED;
			TEST_RETURN;
		}

		returncode = SQLBrowseConnect(hdbc1[i],szConnStrIn,SQL_NTS,szConnStrOut,BRWS_LEN,&cbConnStrOut);
		//printf("\n\nret=%d  i=%d %s\n%s\n\n", returncode, i, szConnStrIn, szConnStrOut);		
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBrowseConnect")){
			TEST_FAILED;
			LogAllErrors(henv,hdbc,hstmt);
		}
	}
	for (i = 0; i < NUM_CONN_HND; i++){
		//printf("%d %d\n", i, NUM_CONN_HND);
		SQLDisconnect(hdbc1[i]);
		SQLFreeConnect(hdbc1[i]);
	}
	SQLFreeEnv(henv);
   TESTCASE_END;
//==========================================================================================
   TESTCASE_BEGIN("Test Positive Functionality of SQLBrowseConnect with different env & conn handles\n");
	for (j = 0; j < NUM_ENV_HND / 5; j++)
	{
		returncode = SQLAllocEnv(&henv1[j]);                 /* Environment handle */
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLAllocEnv"))
		{
			TEST_FAILED;
			TEST_RETURN;
		}
		for (i = 0; i < NUM_CONN_HND / 2; i++)
		{
			returncode = SQLAllocConnect(henv1[j], &hdbc1[j * NUM_CONN_HND + i]);    /* Connection handle  */
			if(!CHECKRC(SQL_SUCCESS,returncode,"SQLAllocConnect"))
			{
				LogAllErrors(henv1[j],hdbc1[j * NUM_CONN_HND + i],hstmt);
				TEST_FAILED;
				TEST_RETURN;
			}
			returncode = SQLBrowseConnect(hdbc1[j * NUM_CONN_HND + i],szConnStrIn,SQL_NTS,szConnStrOut,BRWS_LEN,&cbConnStrOut);
			if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBrowseConnect"))
			{
				TEST_FAILED;
				LogAllErrors(henv1[j],hdbc1[j * NUM_CONN_HND + i],hstmt);
			}
		}
	}
	for (j = 0; j < NUM_ENV_HND / 5; j++)
	{
		for (i = 0; i < NUM_CONN_HND / 2; i++)
		{
			//printf("%d %d %d \n", j, i, NUM_CONN_HND);
			SQLDisconnect(hdbc1[j * NUM_CONN_HND + i]);
			SQLFreeConnect(hdbc1[j * NUM_CONN_HND + i]);
		}
		SQLFreeEnv(henv1[j]);
	}
   TESTCASE_END;
	 LogMsg(SHORTTIMESTAMP+LINEAFTER,"End of testing API ===> SQLBrowseConnect \n");  
//==========================================================================================


   TEST_RETURN;

}
Beispiel #14
0
PassFail TestMXSQLTables (TestInfo *pTestInfo)
{
	TEST_DECLARE;
 	TCHAR			Heading[MAX_HEADING_SIZE];
 	RETCODE			returncode;
 	SQLHANDLE 		henv;
 	SQLHANDLE 		hdbc;
 	SQLHANDLE		hstmt, hstmt1;
	TCHAR			TableQualifier[NAME_LEN],TableOwner[NAME_LEN],Remark[REM_LEN],*TableStr;
	TCHAR			oTableQualifier[NAME_LEN];
	TCHAR			oTableOwner[NAME_LEN];
	TCHAR			oTableName[NAME_LEN];
	TCHAR			oTableType[NAME_LEN];
	TCHAR			oRemark[REM_LEN];
	SQLLEN			oTableQualifierlen,oTableOwnerlen,oTableNamelen,oTableTypelen,oRemarklen;

	int				cols, iatt;
	SWORD numOfCols = 0;
	SWORD pcbDesc;
	SQLLEN pfDesc;
	TCHAR cn[TabType_LEN];
	SWORD cl;
	SWORD st;
	SQLULEN cp;
	SWORD cs, cnull;
	TCHAR rgbDesc[RGB_MAX_LEN];
	TCHAR *CharOutput[12];
	SQLLEN stringlength;
	struct
	{
		TCHAR		*TableName;
		TCHAR		*TableType;
		TCHAR		*TableTypeIn;
	} Table[] = {
							{_T("--")	,_T("TABLE")	,_T("")},
							{_T("--")	,_T("TABLE")	,_T("TABLE")},
							{_T("--")	,_T("TABLE")	,_T("TABLE,VIEW,SYSTEM TABLE")}, 
							{_T("--")	,_T("TABLE")	,_T("TABLE,SYSTEM TABLE,VIEW")},
							{_T("--")	,_T("TABLE")	,_T("TABLE,VIEW,SYSTEM TABLE,SYNONYM,MV,MVG")},
							{_T("--")	,_T("VIEW"),_T("VIEW")},
							{_T("--")	,_T("VIEW"),_T("TABLE,VIEW,SYSTEM TABLE")},
							{_T("--")	,_T("MATERIALIZED VIEW"),_T("")}, 
							{_T("--")	,_T("MATERIALIZED VIEW"),_T("MV")},
							{_T("--")	,_T("SYNONYM"),_T("")}, 
							{_T("--")	,_T("SYNONYM"),_T("SYNONYM")},
							{_T("endloop"),}
					};

	struct
	{
		TCHAR		*TabQua;
		TCHAR		*TabOwner;
		TCHAR		*TabName;
		TCHAR		*TabType;
		int			changedSchema;
	} TableWC[] = 
						{		
							{_T(SQL_ALL_CATALOGS),_T("")			,_T("--")	,_T("")						,-1},		//0
							{_T("")				,_T(SQL_ALL_SCHEMAS),_T("--")	,_T("")						,-1},		//1
							{_T("")				,_T("")				,_T("--")	,_T(SQL_ALL_TABLE_TYPES)	,-1},		//2
							{pTestInfo->Catalog	,pTestInfo->Schema	,_T("--")	,_T("TABLE")				,-1},		//3
							{pTestInfo->Catalog	,_T(SQL_ALL_SCHEMAS),_T("--")	,_T(SQL_ALL_TABLE_TYPES)	,-1},		//4
							{pTestInfo->Catalog	,_T(SQL_ALL_SCHEMAS),_T("--")	,_T(SQL_ALL_TABLE_TYPES)	,-1},		//5
							{pTestInfo->Catalog	,_T(SQL_ALL_SCHEMAS),_T("--")	,_T("TABLE")				,-1},		//6
							{pTestInfo->Catalog	,_T(SQL_ALL_SCHEMAS),_T("--")	,_T(SQL_ALL_TABLE_TYPES)	,-1},		//7
							{pTestInfo->Catalog	,_T(SQL_ALL_SCHEMAS),_T("--")	,_T(SQL_ALL_TABLE_TYPES)	,-1},		//8
							{pTestInfo->Catalog	,_T(SQL_ALL_SCHEMAS),_T("--")	,_T("TABLE")				,-1},		//9
							{pTestInfo->Catalog	,_T("--")			,_T("--")	,_T("TABLE")				,1},		//10
							{pTestInfo->Catalog	,_T("--")			,_T("--")	,_T("TABLE")				,1},		//11
							{pTestInfo->Catalog	,pTestInfo->Schema	,_T("--")	,_T("TABLE")				,-1},		//12
							{pTestInfo->Catalog	,pTestInfo->Schema	,_T("--")	,_T("TABLE")				,-1},		//13
							{pTestInfo->Catalog	,pTestInfo->Schema	,_T("--")	,_T(SQL_ALL_TABLE_TYPES)	,-1},		//14
							{pTestInfo->Catalog	,pTestInfo->Schema	,_T("--")	,_T("TABLE")				,-1},		//15
							{pTestInfo->Catalog	,pTestInfo->Schema	,_T("--")	,_T("TABLE")				,-1},		//16
							{pTestInfo->Catalog	,pTestInfo->Schema	,_T("--")	,_T("TABLE")				,-1},		//17
							{pTestInfo->Catalog	,pTestInfo->Schema	,_T("--")	,_T("TABLE")				,-1},		//18
							{pTestInfo->Catalog	,_T(SQL_ALL_SCHEMAS),_T("--")	,_T(SQL_ALL_TABLE_TYPES)	,-1},		//19
							{pTestInfo->Catalog	,_T(SQL_ALL_SCHEMAS),_T("--")	,_T("TABLE")				,-1},		//20
							{pTestInfo->Catalog	,_T(SQL_ALL_SCHEMAS),_T("--")	,_T("TABLE")				,-1},		//21
							{pTestInfo->Catalog	,_T("--")			,_T("--")	,_T("TABLE")				,1},		//22
							{pTestInfo->Catalog	,_T(SQL_ALL_SCHEMAS),_T("--")	,_T("TABLE")				,-1},		//23
							{pTestInfo->Catalog	,_T("--")			,_T("--")	,_T("TABLE")				,1},		//24
							{pTestInfo->Catalog	,pTestInfo->Schema	,_T("--")	,_T("TABLE")				,-1},		//25
							{pTestInfo->Catalog	,_T("--")			,_T("--")	,_T("TABLE")				,1},		//26
							{pTestInfo->Catalog	,pTestInfo->Schema	,_T("--")	,_T("VIEW")					,-1},		//27
							{pTestInfo->Catalog	,pTestInfo->Schema	,_T("--")	,_T("TABLE")				,-1},		//28
							{pTestInfo->Catalog	,pTestInfo->Schema	,_T("--")	,_T(SQL_ALL_TABLE_TYPES)	,-1},		//29
							{pTestInfo->Catalog	,pTestInfo->Schema	,_T("--")	,_T("TABLE")				,-1},		//30
							{pTestInfo->Catalog	,pTestInfo->Schema	,_T("--")	,_T("VIEW")					,-1},		//31
							{pTestInfo->Catalog	,pTestInfo->Schema	,_T("--")	,_T("TABLE")				,-1},		//32
							{pTestInfo->Catalog	,pTestInfo->Schema	,_T("--")	,_T("TABLE")				,-1},		//33
							{pTestInfo->Catalog	,pTestInfo->Schema	,_T("--")	,_T("TABLE")				,-1},		//34
							{_T("NULL")			,pTestInfo->Schema	,_T("--")	,_T("TABLE")				,-1},		//35
							{pTestInfo->Catalog	,pTestInfo->Schema	,_T("--")	,_T("TABLE")				,-1},		//36
							{pTestInfo->Catalog	,pTestInfo->Schema	,_T("--")	,_T("TABLE")				,-1},		//37
							{_T("NULL")			,_T("--")			,_T("--")	,_T("TABLE")				,0},		//38
							{_T("NULL")			,pTestInfo->Schema	,_T("--")	,_T("TABLE")				,-1},		//39
							{_T("NULL")			,_T("NULL")			,_T("--")	,_T("TABLE")				,-1},		//40
							{pTestInfo->Catalog	,_T("--")			,_T("--")	,_T(SQL_ALL_TABLE_TYPES)	,0},		//41
							{pTestInfo->Catalog	,_T("--")			,_T("--")	,_T(SQL_ALL_TABLE_TYPES)	,0},		//42
							{pTestInfo->Catalog	,_T("--")			,_T("--")	,_T(SQL_ALL_TABLE_TYPES)	,2},		//43
							{_T("endloop"),}
						};	

	struct
	{
		TCHAR		*TabQua;
		SWORD		TabQuaLen;
		TCHAR		*TabOwner;
		SWORD		TabOwnerLen;
		TCHAR		*TabName;
		SWORD		TabNameLen;
		TCHAR		*TabType;
		SWORD		TabTypeLen;
	} TableWC2[] = {		// wild cards from here
							{pTestInfo->Catalog, (SWORD)-1, pTestInfo->Schema,(SWORD)-1, _T("--"),(SWORD)-1, _T(""), (SWORD)-1},
							//{pTestInfo->Catalog, (SWORD)4, pTestInfo->Schema,(SWORD)2, "OBJECTS",(SWORD)2, _T(""), (SWORD)2},
							//{pTestInfo->Catalog, (SWORD)3, pTestInfo->Schema,(SWORD)7, "OBJECTS",(SWORD)3, _T(""), (SWORD)0},
							{_T("endloop"),}
						};
	//attributes for columns added for negative testing
	UWORD DescrType[] = 
				{
					SQL_COLUMN_AUTO_INCREMENT,SQL_COLUMN_CASE_SENSITIVE,SQL_COLUMN_COUNT,
					SQL_COLUMN_DISPLAY_SIZE,SQL_COLUMN_LENGTH,SQL_COLUMN_MONEY,
					SQL_COLUMN_NULLABLE,SQL_COLUMN_PRECISION,SQL_COLUMN_SCALE,
					SQL_COLUMN_SEARCHABLE,SQL_COLUMN_TYPE,SQL_COLUMN_UNSIGNED,
					SQL_COLUMN_UPDATABLE,SQL_COLUMN_NAME,SQL_COLUMN_TYPE_NAME,
					SQL_COLUMN_OWNER_NAME,SQL_COLUMN_QUALIFIER_NAME,SQL_COLUMN_TABLE_NAME,
					SQL_COLUMN_LABEL
				};

    struct {
        TCHAR cat[STR_LEN];
        TCHAR sch[STR_LEN];
        TCHAR tab[STR_LEN];
        TCHAR typ[STR_LEN];
    } displayBuf;
	
	int	i = 0, k = 0, NullValue = 0;
	TCHAR tmpSchema[129];
	TCHAR schemaList[3][256];
	int myInd=1;
	int len = _tcslen(pTestInfo->Schema);

	TCHAR *CrtCol[] = { _T("--"), _T("--") };
	TCHAR *DrpTab[] = { _T("--"), _T("--"), _T("--")};
	TCHAR *CrtTab[] = { _T("--"), _T("--"), _T("--")};

//===========================================================================================================
	var_list_t *var_list;
	var_list = load_api_vars(_T("SQLTables"), charset_file);
	if (var_list == NULL) return FAILED;

	Table[0].TableName = var_mapping(_T("SQLTables_Table_TableName_0"), var_list);
	Table[1].TableName = var_mapping(_T("SQLTables_Table_TableName_1"), var_list);
	Table[2].TableName = var_mapping(_T("SQLTables_Table_TableName_2"), var_list);
	Table[3].TableName = var_mapping(_T("SQLTables_Table_TableName_3"), var_list);
	Table[4].TableName = var_mapping(_T("SQLTables_Table_TableName_4"), var_list);
	Table[5].TableName = var_mapping(_T("SQLTables_Table_TableName_5"), var_list);
	Table[6].TableName = var_mapping(_T("SQLTables_Table_TableName_6"), var_list);
	Table[7].TableName = var_mapping(_T("SQLTables_Table_TableName_7"), var_list);
	Table[8].TableName = var_mapping(_T("SQLTables_Table_TableName_8"), var_list);
	Table[9].TableName = var_mapping(_T("SQLTables_Table_TableName_9"), var_list);
	Table[10].TableName = var_mapping(_T("SQLTables_Table_TableName_10"), var_list);
	
	TableWC[10].TabOwner = var_mapping(_T("SQLTables_TableWC_TabOwner_10"), var_list);
	TableWC[11].TabOwner = var_mapping(_T("SQLTables_TableWC_TabOwner_11"), var_list);
	TableWC[22].TabOwner = var_mapping(_T("SQLTables_TableWC_TabOwner_22"), var_list);
	TableWC[24].TabOwner = var_mapping(_T("SQLTables_TableWC_TabOwner_24"), var_list);
	TableWC[26].TabOwner = var_mapping(_T("SQLTables_TableWC_TabOwner_26"), var_list);
	TableWC[38].TabOwner = var_mapping(_T("SQLTables_TableWC_TabOwner_38"), var_list);
	TableWC[41].TabOwner = var_mapping(_T("SQLTables_TableWC_TabOwner_10"), var_list);
	TableWC[42].TabOwner = var_mapping(_T("SQLTables_TableWC_TabOwner_41"), var_list);
	TableWC[43].TabOwner = var_mapping(_T("SQLTables_TableWC_TabOwner_43"), var_list);

	TableWC[0].TabName = var_mapping(_T("SQLTables_TableWC_TabName_0"), var_list);
	TableWC[1].TabName = var_mapping(_T("SQLTables_TableWC_TabName_1"), var_list);
	TableWC[2].TabName = var_mapping(_T("SQLTables_TableWC_TabName_2"), var_list);
	TableWC[3].TabName = var_mapping(_T("SQLTables_TableWC_TabName_3"), var_list);
	TableWC[4].TabName = var_mapping(_T("SQLTables_TableWC_TabName_4"), var_list);
	TableWC[5].TabName = var_mapping(_T("SQLTables_TableWC_TabName_5"), var_list);
	TableWC[6].TabName = var_mapping(_T("SQLTables_TableWC_TabName_6"), var_list);
	TableWC[7].TabName = var_mapping(_T("SQLTables_TableWC_TabName_7"), var_list);
	TableWC[8].TabName = var_mapping(_T("SQLTables_TableWC_TabName_8"), var_list);
	TableWC[9].TabName = var_mapping(_T("SQLTables_TableWC_TabName_9"), var_list);
	TableWC[10].TabName = var_mapping(_T("SQLTables_TableWC_TabName_10"), var_list);
	TableWC[11].TabName = var_mapping(_T("SQLTables_TableWC_TabName_11"), var_list);
	TableWC[12].TabName = var_mapping(_T("SQLTables_TableWC_TabName_12"), var_list);
	TableWC[13].TabName = var_mapping(_T("SQLTables_TableWC_TabName_13"), var_list);
	TableWC[14].TabName = var_mapping(_T("SQLTables_TableWC_TabName_14"), var_list);
	TableWC[15].TabName = var_mapping(_T("SQLTables_TableWC_TabName_15"), var_list);
	TableWC[16].TabName = var_mapping(_T("SQLTables_TableWC_TabName_16"), var_list);
	TableWC[17].TabName = var_mapping(_T("SQLTables_TableWC_TabName_17"), var_list);
	TableWC[18].TabName = var_mapping(_T("SQLTables_TableWC_TabName_18"), var_list);
	TableWC[19].TabName = var_mapping(_T("SQLTables_TableWC_TabName_19"), var_list);
	TableWC[20].TabName = var_mapping(_T("SQLTables_TableWC_TabName_20"), var_list);
	TableWC[21].TabName = var_mapping(_T("SQLTables_TableWC_TabName_21"), var_list);
	TableWC[22].TabName = var_mapping(_T("SQLTables_TableWC_TabName_22"), var_list);
	TableWC[23].TabName = var_mapping(_T("SQLTables_TableWC_TabName_23"), var_list);
	TableWC[24].TabName = var_mapping(_T("SQLTables_TableWC_TabName_24"), var_list);
	TableWC[25].TabName = var_mapping(_T("SQLTables_TableWC_TabName_25"), var_list);
	TableWC[26].TabName = var_mapping(_T("SQLTables_TableWC_TabName_26"), var_list);
	TableWC[27].TabName = var_mapping(_T("SQLTables_TableWC_TabName_27"), var_list);
	TableWC[28].TabName = var_mapping(_T("SQLTables_TableWC_TabName_28"), var_list);
	TableWC[29].TabName = var_mapping(_T("SQLTables_TableWC_TabName_29"), var_list);
	TableWC[30].TabName = var_mapping(_T("SQLTables_TableWC_TabName_30"), var_list);
	TableWC[31].TabName = var_mapping(_T("SQLTables_TableWC_TabName_31"), var_list);
	TableWC[32].TabName = var_mapping(_T("SQLTables_TableWC_TabName_32"), var_list);
	TableWC[33].TabName = var_mapping(_T("SQLTables_TableWC_TabName_33"), var_list);
	TableWC[34].TabName = var_mapping(_T("SQLTables_TableWC_TabName_34"), var_list);
	TableWC[35].TabName = var_mapping(_T("SQLTables_TableWC_TabName_35"), var_list);
	TableWC[36].TabName = var_mapping(_T("SQLTables_TableWC_TabName_36"), var_list);
	TableWC[37].TabName = var_mapping(_T("SQLTables_TableWC_TabName_37"), var_list);
	TableWC[38].TabName = var_mapping(_T("SQLTables_TableWC_TabName_38"), var_list);
	TableWC[39].TabName = var_mapping(_T("SQLTables_TableWC_TabName_39"), var_list);
	TableWC[40].TabName = var_mapping(_T("SQLTables_TableWC_TabName_40"), var_list);
	TableWC[41].TabName = var_mapping(_T("SQLTables_TableWC_TabName_41"), var_list);
	TableWC[42].TabName = var_mapping(_T("SQLTables_TableWC_TabName_42"), var_list);
	TableWC[43].TabName = var_mapping(_T("SQLTables_TableWC_TabName_43"), var_list);

	TableWC2[0].TabName = var_mapping(_T("SQLTables_TableWC2_TabName_0"), var_list);

	CrtCol[0] = var_mapping(_T("SQLTables_CrtCol_0"), var_list);
	CrtCol[1] = var_mapping(_T("SQLTables_CrtCol_1"), var_list);

	DrpTab[0] = var_mapping(_T("SQLTables_DrpTab_0"), var_list);
	DrpTab[1] = var_mapping(_T("SQLTables_DrpTab_1"), var_list);
	DrpTab[2] = var_mapping(_T("SQLTables_DrpTab_2"), var_list);

	CrtTab[0] = var_mapping(_T("SQLTables_CrtTab_0"), var_list);
	CrtTab[1] = var_mapping(_T("SQLTables_CrtTab_1"), var_list);
	CrtTab[2] = var_mapping(_T("SQLTables_CrtTab_2"), var_list);
//===========================================================================================================

	memset(schemaList[0],'\0', 256*sizeof(TCHAR));
	memset(schemaList[1],'\0', 256*sizeof(TCHAR));
	memset(schemaList[2],'\0', 256*sizeof(TCHAR));

	myInd = len - 2;
	if (len>5) myInd=4;

/*
#ifndef UNICODE
	if (_tcscmp("English", _tsetlocale(LC_ALL, _T(""))) != 0) {
		_mbsncpy(schemaList[0],pTestInfo->Schema,myInd);
		_mbscat(schemaList[0], "%");

		_mbsncpy(schemaList[1],pTestInfo->Schema,myInd+1);
		_mbscat(schemaList[1], "%");
	}
	else {
#endif
*/
		_tcsncpy(schemaList[0],pTestInfo->Schema,myInd);
		_tcscat(schemaList[0], _T("%"));

		_tcsncpy(schemaList[1],pTestInfo->Schema,myInd+1);
		_tcscat(schemaList[1], _T("%"));
/*
#ifndef UNICODE
	}
#endif
*/

	len = 0; myInd = 0;
	do {
		if (pTestInfo->Schema[myInd] == '_')
			schemaList[2][len++] = '\\';
		schemaList[2][len++] = pTestInfo->Schema[myInd];
	} while (pTestInfo->Schema[myInd++] != '\0');

    LogMsg(NONE,_T("%s %s %s\n"), schemaList[0], schemaList[1], schemaList[2]);

	if (isCharSet) {
		_stprintf(tmpSchema, _T("\"SQLTABLES_%s\""), pTestInfo->Schema);
	}
	else {
		_stprintf(tmpSchema, _T("SQLTABLES_%s"), pTestInfo->Schema);
	}
	_tcsupr(tmpSchema);
//======================================================================================================

	LogMsg(LINEBEFORE+SHORTTIMESTAMP,_T("Begin testing API => MX SPECIFIC SQLTables.\n"));

	TEST_INIT;

	TESTCASE_BEGIN("Setup for SQLTables tests\n");
	// for ODBC 3.0
	if(!FullConnectWithOptions(pTestInfo, CONNECT_ODBC_VERSION_3))
	{
		LogMsg(NONE,_T("Unable to connect as ODBC3.0 application.\n"));
		TEST_FAILED;
		TEST_RETURN;
	}

	henv = pTestInfo->henv;
 	hdbc = pTestInfo->hdbc;
 	hstmt = (SQLHANDLE)pTestInfo->hstmt;
	returncode = SQLAllocStmt((SQLHANDLE)hdbc, &hstmt);	
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLAllocStmt"))
	{
		TEST_FAILED;
		LogAllErrors(henv,hdbc,hstmt);
	}
	else
	{
		LogMsg(NONE,_T("Allocate a stmt handle successfully.\n"));
	}

   TESTCASE_END;

   _tcscpy(pTestInfo->Catalog, _T("TRAFODION"));
	if (returncode == SQL_SUCCESS)
	{
        _stprintf(Heading,_T("drop schema %s.%s cascade"),pTestInfo->Catalog,tmpSchema);
		returncode = SQLExecDirect(hstmt,(SQLTCHAR*)Heading, SQL_NTS);
        _stprintf(Heading,_T("create schema %s.%s"),pTestInfo->Catalog,tmpSchema);
		returncode = SQLExecDirect(hstmt,(SQLTCHAR*)Heading, SQL_NTS);
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect"))
		{
			LogAllErrors(henv,hdbc,hstmt);
			TEST_FAILED;
			TEST_RETURN;
		}

        _stprintf(Heading,_T("set schema %s.%s"),pTestInfo->Catalog,tmpSchema);
		returncode = SQLExecDirect(hstmt,(SQLTCHAR*)Heading, SQL_NTS);
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect"))
		{
			LogAllErrors(henv,hdbc,hstmt);
			TEST_FAILED;
			TEST_RETURN;
		}

		_tcscpy(TableQualifier,pTestInfo->Catalog);
		_tcscpy(TableOwner, tmpSchema);
		_tcscpy(Remark,_T(""));
		TableStr = (TCHAR *)malloc(MAX_NOS_SIZE);

		i = 0;
		while (_tcsicmp(Table[i].TableName,_T("endloop")) != 0) // cleanup 
		{
			_tcscpy(TableStr,_T(""));
			_tcscat(TableStr,_T("drop "));
			_tcscat(TableStr,Table[i].TableType);
			_tcscat(TableStr,_T(" "));
			_tcscat(TableStr,Table[i].TableName);
			_tcscat(TableStr,_T(" cascade"));
			LogMsg(NONE,_T("Cleanup: %s\n"),TableStr);
			returncode = SQLExecDirect(hstmt,(SQLTCHAR*) TableStr,SQL_NTS);
			i++;
		}
		
		i = 0;
		while (_tcsicmp(Table[i].TableName,_T("endloop")) != 0)
		{
			_tcscpy(TableStr,_T(""));
			_tcscat(TableStr,_T("create "));
			_tcscat(TableStr,Table[i].TableType);
			_tcscat(TableStr,_T(" "));
			_tcscat(TableStr,Table[i].TableName);
			if (_tcsicmp(Table[i].TableType,_T("VIEW")) == 0) {
				_tcscat(TableStr,CrtCol[1]);
				_tcscat(TableStr, Table[0].TableName);
			}
			else if (_tcsicmp(Table[i].TableType,_T("MATERIALIZED VIEW")) == 0) {
				_tcscat(TableStr, _T(" REFRESH ON REQUEST INITIALIZE ON REFRESH "));
				_tcscat(TableStr,CrtCol[1]);
				_tcscat(TableStr, Table[0].TableName); 
			}
			else if (_tcsicmp(Table[i].TableType,_T("SYNONYM")) == 0) {
				_tcscat(TableStr, _T(" FOR "));
				_tcscat(TableStr, Table[0].TableName);
			}
			else
			{
				_tcscat(TableStr,CrtCol[0]);
			}
		
			_stprintf(Heading,_T("SQLTables: Test %d: using the following table create command=> \n"),i);
			_tcscat(Heading,TableStr);
			_tcscat(Heading,_T("\n"));
			TESTCASE_BEGINW(Heading);
			
			returncode = SQLExecDirect(hstmt,(SQLTCHAR*)TableStr,SQL_NTS);
			if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect"))
			{
				LogAllErrors(henv,hdbc,hstmt);
				TEST_FAILED;
			}
			else
			{
				LogMsg(NONE,_T("Created table successfully.\n"));
			}

			if(isCharSet) {
				returncode = SQLSetStmtAttr(hstmt,SQL_ATTR_METADATA_ID,(SQLPOINTER)SQL_TRUE,0);
				if(!CHECKRC(SQL_SUCCESS,returncode,"SQLSetStmtAttr(SQL_ATTR_METADATA_ID"))
				{
					TEST_FAILED;
					LogAllErrors(henv,hdbc,hstmt);
				}
			}
			
			if (returncode == SQL_SUCCESS)
			{
				if (_tcslen(TableQualifier) > 0)
					returncode = SQLTables(hstmt,(SQLTCHAR*)TableQualifier,(SWORD)_tcslen(TableQualifier),(SQLTCHAR*)TableOwner,(SWORD)_tcslen(TableOwner),(SQLTCHAR*)Table[i].TableName,(SWORD)_tcslen(Table[i].TableName),(SQLTCHAR*)Table[i].TableTypeIn,(SWORD)_tcslen(Table[i].TableTypeIn));
				else
					returncode = SQLTables(hstmt,NULL,(SWORD)_tcslen(TableQualifier),(SQLTCHAR*)TableOwner,(SWORD)_tcslen(TableOwner),(SQLTCHAR*)Table[i].TableName,(SWORD)_tcslen(Table[i].TableName),(SQLTCHAR*)Table[i].TableTypeIn,(SWORD)_tcslen(Table[i].TableTypeIn));
				
				if(!CHECKRC(SQL_SUCCESS,returncode,"SQLTables"))
				{
					TEST_FAILED;
					LogAllErrors(henv,hdbc,hstmt);
				}
				else
				{
					LogMsg(NONE,_T("Call to SQLTables() executed successfully.\n"));
					
					_tcscpy(oTableQualifier,_T(""));
					_tcscpy(oTableOwner,_T(""));
					_tcscpy(oTableName,_T(""));
					_tcscpy(oTableType,_T(""));
					_tcscpy(oRemark,_T(""));
					returncode=SQLBindCol(hstmt,1,SQL_C_TCHAR,oTableQualifier,NAME_LEN,&oTableQualifierlen);
					if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol")){
						LogAllErrors(henv,hdbc,hstmt);
						TEST_FAILED;
						}
				   returncode=SQLBindCol(hstmt,2,SQL_C_TCHAR,oTableOwner,NAME_LEN,&oTableOwnerlen);
					if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol")){
						LogAllErrors(henv,hdbc,hstmt);
						TEST_FAILED;
						}
					returncode=SQLBindCol(hstmt,3,SQL_C_TCHAR,oTableName,NAME_LEN,&oTableNamelen);
					if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol")){
						LogAllErrors(henv,hdbc,hstmt);
						TEST_FAILED;
						}
				   returncode=SQLBindCol(hstmt,4,SQL_C_TCHAR,oTableType,NAME_LEN,&oTableTypelen);
					if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol")){
						LogAllErrors(henv,hdbc,hstmt);
						TEST_FAILED;
						}
					returncode=SQLBindCol(hstmt,5,SQL_C_TCHAR,oRemark,NAME_LEN,&oRemarklen);
					if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol")){
						LogAllErrors(henv,hdbc,hstmt);
						TEST_FAILED;
						}

					k = 0;
					while (returncode == SQL_SUCCESS)
					{
						returncode = SQLFetch(hstmt);
						if((returncode != SQL_NO_DATA_FOUND)&&(!CHECKRC(SQL_SUCCESS,returncode,"SQLFetch")))
						{
							LogAllErrors(henv,hdbc,hstmt);
							TEST_FAILED;
						}
						else if (returncode == SQL_SUCCESS)
						{
							if (_tcslen(TableQualifier) == 0)
							{
								//_tcscpy(TableQualifier, _T("TRAFODION"));
								_tcscpy(TableQualifier, _T("TRAFODION"));
							}
							if ((_tcsicmp(TableQualifier,oTableQualifier) == 0) 
								&& (cwcscmp(TableOwner,oTableOwner,TRUE) == 0) 
								&& (cwcscmp(Table[i].TableName,oTableName,TRUE) == 0) 
								&& (_tcsnicmp(Table[i].TableType,oTableType,_tcslen(Table[i].TableType)) == 0) 
								&& (_tcsicmp(Remark,oRemark) == 0))
							{
								LogMsg(NONE,_T("TableQualifier expect: '%s' and actual: '%s' are matched\n"),(SQLTCHAR*)TableQualifier,oTableQualifier);
								LogMsg(NONE,_T("TableOwner expect: '%s' and actual: '%s' are matched\n"),(SQLTCHAR*)TableOwner,oTableOwner);
								LogMsg(NONE,_T("TableName expect: '%s' and actual: '%s' are matched\n"),(SQLTCHAR*)Table[i].TableName,oTableName);
								LogMsg(NONE,_T("TableType expect: '%s' and actual: '%s' are matched\n"),Table[i].TableType,oTableType);
								LogMsg(NONE,_T("Remark expect: '%s' and actual: '%s' are matched\n"),Remark,oRemark);
							}	
							else
							{
								TEST_FAILED;	
								if (_tcsicmp(TableQualifier,oTableQualifier) != 0)
									LogMsg(ERRMSG,_T("TableQualifier expect: '%s' and actual: '%s' are not matched\n"),(SQLTCHAR*)TableQualifier,oTableQualifier);
								if (cwcscmp(TableOwner,oTableOwner,TRUE) != 0) 
									LogMsg(ERRMSG,_T("TableOwner expect: '%s' and actual: '%s' are not matched\n"),(SQLTCHAR*)TableOwner,oTableOwner);
								if (cwcscmp(Table[i].TableName,oTableName,TRUE) != 0) 
									LogMsg(ERRMSG,_T("TableName expect: '%s' and actual: '%s' are not matched\n"),(SQLTCHAR*)Table[i].TableName,oTableName);
								if (_tcsnicmp(Table[i].TableType,oTableType,10) != 0) 
									LogMsg(ERRMSG,_T("TableType expect: '%s' and actual: '%s' are not matched\n"),Table[i].TableType,oTableType);
								if (_tcsicmp(Remark,oRemark) != 0) 
									LogMsg(ERRMSG,_T("Remark expect: '%s' and actual: '%s' are not matched\n"),Remark,oRemark);
							}

							k++;
						}
					}//End while loop

					if(k != 1)
					{
						TEST_FAILED;
						LogMsg(ERRMSG,_T("Only one row should be fetched, the actual number of rows fetched: %d\n"), k);
					} else {
						LogMsg(NONE, _T("Number of rows fetched: %d\n"), k);
					}
				}
				SQLFreeStmt(hstmt,SQL_UNBIND);
				SQLFreeStmt(hstmt,SQL_CLOSE);
			}
			TESTCASE_END;
			i++;
		}
//		i = 0;
//		while (_tcsicmp(Table[i].TableName,"endloop") != 0) // cleanup
//		{
//			_tcscpy(TableStr,_T(""));
//			_tcscat(TableStr,"drop ");
//			_tcscat(TableStr,Table[i].TableType);
//			_tcscat(TableStr," ");
//			_tcscat(TableStr,Table[i].TableName);
//			SQLExecDirect(hstmt,(SQLTCHAR*) TableStr,SQL_NTS);
//			i++;
//		}

        _stprintf(Heading,_T("drop schema %s.%s cascade"),pTestInfo->Catalog,tmpSchema);
		returncode = SQLExecDirect(hstmt,(SQLTCHAR*)Heading, SQL_NTS);
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect"))
		{
			LogAllErrors(henv,hdbc,hstmt);
			TEST_FAILED;
			TEST_RETURN;
		}

		if (isCharSet) {
			_stprintf(Heading,_T("set schema %s.\"%s\""),pTestInfo->Catalog,pTestInfo->Schema);
		}
		else {
			_stprintf(Heading,_T("set schema %s.%s"),pTestInfo->Catalog,pTestInfo->Schema);
		}
		returncode = SQLExecDirect(hstmt,(SQLTCHAR*)Heading, SQL_NTS);
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect"))
		{
			LogAllErrors(henv,hdbc,hstmt);
			TEST_FAILED;
			TEST_RETURN;
		}

//======================================================================================================
		_stprintf(Heading,_T("Setting up Table & view to test SQLTables for wildcard options => \n"));
		_tcscat(Heading,_T("\n"));
		TESTCASE_BEGINW(Heading);
		SQLExecDirect(hstmt,(SQLTCHAR*)DrpTab[0],SQL_NTS);
		SQLExecDirect(hstmt,(SQLTCHAR*)DrpTab[1],SQL_NTS);
		SQLExecDirect(hstmt,(SQLTCHAR*)DrpTab[2],SQL_NTS);
		LogMsg(NONE,_T("%s\n"), CrtTab[0]);
		returncode = SQLExecDirect(hstmt,(SQLTCHAR*)CrtTab[0],SQL_NTS);

		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect"))
		{
			LogAllErrors(henv,hdbc,hstmt);
			TEST_FAILED;
		}
		else
		{
			returncode = SQLExecDirect(hstmt,(SQLTCHAR*)CrtTab[1],SQL_NTS);
			LogMsg(NONE,_T("%s\n"), CrtTab[1]);
			if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect"))
			{
				LogAllErrors(henv,hdbc,hstmt);
				TEST_FAILED;
			}
			else
			{
				LogMsg(NONE,_T("setting up tables & views executed successfully.\n"));
				TESTCASE_END;
			}
		}
		returncode = SQLExecDirect(hstmt,(SQLTCHAR*)CrtTab[2],SQL_NTS);
		LogMsg(NONE,_T("%s\n"), CrtTab[2]);
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect"))
		{
			LogAllErrors(henv,hdbc,hstmt);
			TEST_FAILED;
		}
		i = 0;
		while (_tcsicmp(TableWC[i].TabQua,_T("endloop")) != 0)
		{
			if(TableWC[i].changedSchema == -1) {
				printSymbol(TableWC[i].TabQua,displayBuf.cat);
                printSymbol(TableWC[i].TabOwner,displayBuf.sch);
				printSymbol(TableWC[i].TabName,displayBuf.tab);
                printSymbol(TableWC[i].TabType,displayBuf.typ);

				_stprintf(Heading,_T("Test Positive Functionality of SQLTables for following wildcard options => \n TableQualifier: %s\n TableOwner: %s\n TableName: %s\n TableType: %s\n"),
				displayBuf.cat, displayBuf.sch,	displayBuf.tab, displayBuf.typ);
			}
			else {
				printSymbol(TableWC[i].TabQua,displayBuf.cat);
                printSymbol(schemaList[TableWC[i].changedSchema],displayBuf.sch);
				printSymbol(TableWC[i].TabName,displayBuf.tab);
                printSymbol(TableWC[i].TabType,displayBuf.typ);

				_stprintf(Heading,_T("Test Positive Functionality of SQLTables for following wildcard options => \n TableQualifier: %s\n TableOwner: %s\n TableName: %s\n TableType: %s\n"),
				displayBuf.cat, displayBuf.sch, displayBuf.tab, displayBuf.typ);
			}

			TESTCASE_BEGINW(Heading);
			NullValue = 0;

			returncode = SQLSetStmtAttr(hstmt,SQL_ATTR_METADATA_ID,(SQLPOINTER)SQL_FALSE,0);
			if(!CHECKRC(SQL_SUCCESS,returncode,"SQLSetStmtAttr(SQL_ATTR_METADATA_ID"))
			{
				TEST_FAILED;
				LogAllErrors(henv,hdbc,hstmt);
			}

			if (_tcsicmp(TableWC[i].TabType,_T("NULL")) == 0)
			{
				TableWC[i].TabType = NULL;
				NullValue = 1;
				returncode = SQLTables(hstmt,NULL,0,NULL,0,NULL,0,NULL,0);
			}
			else if (_tcsicmp(TableWC[i].TabName,_T("NULL")) == 0)
			{
				TableWC[i].TabName = NULL;
				NullValue = 1;
				returncode = SQLTables(hstmt,NULL,0,NULL,0,NULL,0,(SQLTCHAR*)TableWC[i].TabType,(SWORD)_tcslen(TableWC[i].TabType));
			}
			else if (_tcsicmp(TableWC[i].TabOwner,_T("NULL")) == 0)
			{
				TableWC[i].TabOwner = NULL;
				NullValue = 1;
				returncode = SQLTables(hstmt,NULL,0,NULL,0,(SQLTCHAR*)removeQuotes(TableWC[i].TabName,displayBuf.tab),(SWORD)_tcslen(displayBuf.tab),(SQLTCHAR*)TableWC[i].TabType,(SWORD)_tcslen(TableWC[i].TabType));
			}
			else if (_tcsicmp(TableWC[i].TabQua,_T("NULL")) == 0)
			{
				TableWC[i].TabQua = NULL;
				NullValue = 1;
				if (TableWC[i].changedSchema == -1)
					returncode = SQLTables(hstmt,NULL,0,(SQLTCHAR*)TableWC[i].TabOwner,(SWORD)_tcslen(TableWC[i].TabOwner),(SQLTCHAR*)removeQuotes(TableWC[i].TabName,displayBuf.tab),(SWORD)_tcslen(displayBuf.tab),(SQLTCHAR*)TableWC[i].TabType,(SWORD)_tcslen(TableWC[i].TabType));
				else
					returncode = SQLTables(hstmt,NULL,0,(SQLTCHAR*)schemaList[TableWC[i].changedSchema],(SWORD)_tcslen(schemaList[TableWC[i].changedSchema]),(SQLTCHAR*)removeQuotes(TableWC[i].TabName,displayBuf.tab),(SWORD)_tcslen(displayBuf.tab),(SQLTCHAR*)TableWC[i].TabType,(SWORD)_tcslen(TableWC[i].TabType));
			}
			else
			{
				if (TableWC[i].changedSchema == -1)
					returncode = SQLTables(hstmt,(SQLTCHAR*)TableWC[i].TabQua,(SWORD)_tcslen(TableWC[i].TabQua),(SQLTCHAR*)TableWC[i].TabOwner,(SWORD)_tcslen(TableWC[i].TabOwner),(SQLTCHAR*)removeQuotes(TableWC[i].TabName,displayBuf.tab),(SWORD)_tcslen(displayBuf.tab),(SQLTCHAR*)TableWC[i].TabType,(SWORD)_tcslen(TableWC[i].TabType));
				else
					returncode = SQLTables(hstmt,(SQLTCHAR*)TableWC[i].TabQua,(SWORD)_tcslen(TableWC[i].TabQua),(SQLTCHAR*)schemaList[TableWC[i].changedSchema],(SWORD)_tcslen(schemaList[TableWC[i].changedSchema]),(SQLTCHAR*)removeQuotes(TableWC[i].TabName,displayBuf.tab),(SWORD)_tcslen(displayBuf.tab),(SQLTCHAR*)TableWC[i].TabType,(SWORD)_tcslen(TableWC[i].TabType));
			}

			if(!CHECKRC(SQL_SUCCESS,returncode,"SQLTables"))
			{
				TEST_FAILED;
				LogAllErrors(henv,hdbc,hstmt);
			}
			else
			{
				LogMsg(NONE,_T("Call to SQLTables() executed successfully.\n"));
				_tcscpy(oTableQualifier,_T(""));
				_tcscpy(oTableOwner,_T(""));
				_tcscpy(oTableName,_T(""));
				_tcscpy(oTableType,_T(""));
				_tcscpy(oRemark,_T(""));
				returncode=SQLBindCol(hstmt,1,SQL_C_TCHAR,oTableQualifier,NAME_LEN,&oTableQualifierlen);
				if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol"))
				{
					LogAllErrors(henv,hdbc,hstmt);
					TEST_FAILED;
				}
				returncode=SQLBindCol(hstmt,2,SQL_C_TCHAR,oTableOwner,NAME_LEN,&oTableOwnerlen);
				if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol"))
				{
					LogAllErrors(henv,hdbc,hstmt);
					TEST_FAILED;
				}
				returncode=SQLBindCol(hstmt,3,SQL_C_TCHAR,oTableName,NAME_LEN,&oTableNamelen);
				if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol"))
				{
					LogAllErrors(henv,hdbc,hstmt);
					TEST_FAILED;
				}
				returncode=SQLBindCol(hstmt,4,SQL_C_TCHAR,oTableType,NAME_LEN,&oTableTypelen);
				if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol"))
				{
					LogAllErrors(henv,hdbc,hstmt);
					TEST_FAILED;
				}
				returncode=SQLBindCol(hstmt,5,SQL_C_TCHAR,oRemark,NAME_LEN,&oRemarklen);
				if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol"))
				{
					LogAllErrors(henv,hdbc,hstmt);
					TEST_FAILED;
				}
				k = 0;
				while (returncode == SQL_SUCCESS)
				{
					returncode = SQLFetch(hstmt);
					if((returncode!=SQL_NO_DATA_FOUND) && (!CHECKRC(SQL_SUCCESS,returncode,"SQLFetch")))
					{
						LogAllErrors(henv,hdbc,hstmt);
						TEST_FAILED;
					}
					if (returncode == SQL_SUCCESS)
						k++;
				}
				if(k == 0)
				{
					TEST_FAILED;
					LogMsg(ERRMSG,_T("No Data Found => Atleast one row should be fetched\n"));
                } else {
                    LogMsg(NONE, _T("Number of rows fetched: %d\n"), k);
                }
			}
			SQLFreeStmt(hstmt,SQL_CLOSE);
			i++;
			TESTCASE_END;
		}
		free(TableStr);
	}

//=========================================================================================

	TESTCASE_BEGIN("SQLTables: Negative test with NULL handle.\n");

	hstmt1 = (SQLHANDLE)NULL;
	i = 0;
	returncode = SQLTables(hstmt1,(SQLTCHAR*)TableWC[i].TabQua,(SWORD)_tcslen(TableWC[i].TabQua),(SQLTCHAR*)TableWC[i].TabOwner,(SWORD)_tcslen(TableWC[i].TabOwner),(SQLTCHAR*)TableWC[i].TabName,(SWORD)_tcslen(TableWC[i].TabName),(SQLTCHAR*)TableWC[i].TabType,(SWORD)_tcslen(TableWC[i].TabType));
	if(!CHECKRC(SQL_INVALID_HANDLE,returncode,"SQLTables"))
	{
		TEST_FAILED;
		LogAllErrors(henv,hdbc,hstmt);
	}
	TESTCASE_END;

//=========================================================================================

	TESTCASE_BEGIN("SQLTables: Negative test with invalid arg lengths.\n");
	i = 0;
	while (_tcsicmp(TableWC2[i].TabQua,_T("endloop")) != 0)
	{
		returncode = SQLTables(hstmt,(SQLTCHAR*)TableWC2[i].TabQua,TableWC2[i].TabQuaLen,(SQLTCHAR*)TableWC2[i].TabOwner,TableWC2[i].TabOwnerLen,(SQLTCHAR*)TableWC2[i].TabName,TableWC2[i].TabNameLen,(SQLTCHAR*)TableWC2[i].TabType,TableWC2[i].TabTypeLen);
		if(!CHECKRC(SQL_ERROR,returncode,"SQLTables"))
		{
			TEST_FAILED;
			LogAllErrors(henv,hdbc,hstmt);
		}
		i++;
	}
	TESTCASE_END;

//=========================================================================================

	TESTCASE_BEGIN("Testing SQLColAttribute, SQLDescribeCol, SQLBindCol and SQLFetch functions for catalog names.\n");

    if(isCharSet) {
		returncode = SQLSetStmtAttr(hstmt,SQL_ATTR_METADATA_ID,(SQLPOINTER)SQL_FALSE,0);
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLSetStmtAttr(SQL_ATTR_METADATA_ID"))
		{
			TEST_FAILED;
			LogAllErrors(henv,hdbc,hstmt);
		}
	}

	for(i = 0; i < 5; i++)
	{
		returncode = SQLTables(hstmt,(SQLTCHAR*)TableWC[i].TabQua,(SWORD)_tcslen(TableWC[i].TabQua),(SQLTCHAR*)TableWC[i].TabOwner,(SWORD)_tcslen(TableWC[i].TabOwner),(SQLTCHAR*)TableWC[i].TabName,(SWORD)_tcslen(TableWC[i].TabName),(SQLTCHAR*)TableWC[i].TabType,(SWORD)_tcslen(TableWC[i].TabType));
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLColumns"))
		{
			TEST_FAILED;
			LogAllErrors(henv,hdbc,hstmt);
		}
		returncode = SQLNumResultCols(hstmt, &numOfCols);
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLNumResultsCol"))
		{
			TEST_FAILED;
			LogMsg(ERRMSG,_T("Test failed while executing call for SQLNUMRESULTSCOL"));
			LogAllErrors(henv,hdbc,hstmt);
		}
		for(cols = 0; cols < numOfCols; cols++)
		{
			returncode = SQLDescribeCol(hstmt,(SWORD)(cols+1),(SQLTCHAR*)cn,TabType_LEN,&cl,&st,&cp,&cs,&cnull);
			if(!CHECKRC(SQL_SUCCESS,returncode,"SQLDescribeCol"))
			{
				TEST_FAILED;
				LogMsg(ERRMSG,_T("Test failed while executing call for SQLDESCRIBECOL of column"));
				LogAllErrors(henv,hdbc,hstmt);
			}
			CharOutput[cols] = (TCHAR *)malloc(STR_LEN);
			for (iatt = 0; iatt <= TOTALATTRIBS; iatt++)
			{
				_tcscpy(rgbDesc,_T(""));
				pcbDesc = 0;
				pfDesc = 0;
				returncode = SQLColAttributes(hstmt,(SWORD)(cols+1),DescrType[iatt],(SQLTCHAR*)rgbDesc,STR_LEN,&pcbDesc,&pfDesc);
				if(!CHECKRC(SQL_SUCCESS,returncode,"SQLColAttribute"))
				{
					TEST_FAILED;
					LogAllErrors(henv,hdbc,hstmt);
				}
			}
			returncode = SQLBindCol(hstmt,(SWORD)(cols+1),SQL_C_TCHAR,(SQLTCHAR*)CharOutput[cols],STR_LEN,&stringlength);
			if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol"))
			{
				TEST_FAILED;
				LogMsg(ERRMSG,_T("Test failed while executing call for SQLBindCols of column : %d.\n"),cols);
				LogAllErrors(henv,hdbc,hstmt);
			}
		}

		k = 0;
		while (returncode == SQL_SUCCESS)
		{
			returncode = SQLFetch(hstmt);
			if((returncode!=SQL_NO_DATA_FOUND) && (!CHECKRC(SQL_SUCCESS,returncode,"SQLFetch")))
			{
				LogAllErrors(henv,hdbc,hstmt);
				TEST_FAILED;
			}
			if (returncode == SQL_SUCCESS)
				k++;
		}
		if(k == 0)
		{
            _stprintf(Heading,_T("\n TableQualifier: %s\n TableOwner: %s\n TableName: %s\n TableType: %s\n"),
				printSymbol(TableWC[i].TabQua,displayBuf.cat),
                printSymbol(TableWC[i].TabOwner,displayBuf.sch),
				printSymbol(TableWC[i].TabName,displayBuf.tab),
                printSymbol(TableWC[i].TabType,displayBuf.typ));
            LogMsg(NONE,Heading);
			TEST_FAILED;
			LogMsg(ERRMSG,_T("No Data Found => Atleast one row should be fetched\n"));
		} else {
            LogMsg(NONE, _T("Number of rows fetched: %d\n"), k);
        }

		for(cols = 0; cols < numOfCols; cols++)
		{
			free(CharOutput[cols]);
		}
		TESTCASE_END;
	}

	// Clean up
	SQLExecDirect(hstmt,(SQLTCHAR*)DrpTab[0],SQL_NTS);
	SQLExecDirect(hstmt,(SQLTCHAR*)DrpTab[1],SQL_NTS);
	SQLExecDirect(hstmt,(SQLTCHAR*)DrpTab[2],SQL_NTS);

//=========================================================================================

	FullDisconnect(pTestInfo);
	LogMsg(SHORTTIMESTAMP+LINEAFTER,_T("End testing API => SQLTables.\n"));
	free_list(var_list);
	TEST_RETURN;
}
Beispiel #15
0
PassFail TestSQLFetch(TestInfo *pTestInfo)
{   
	TEST_DECLARE;
 	TCHAR				Heading[MAX_STRING_SIZE];
 	RETCODE				returncode;
 	SQLHANDLE 			henv;
 	SQLHANDLE 			hdbc;
 	SQLHANDLE			hstmt;
	SQLUSMALLINT		i, j, k, fn, h;
	SWORD				col;
	TCHAR				*CCharOutput1[MAX_NUM1], CCharOutput2[NAME_LEN];
	SQLLEN				OutputLen1[MAX_NUM1], OutputLen2;
	SQLSMALLINT			CType[] = {SQL_C_TCHAR};
	//TCHAR					*TestCType[] = 
	//							{
	//								"SQL_C_TCHAR","SQL_C_BINARY","SQL_C_SSHORT","SQL_C_USHORT","SQL_C_SHORT","SQL_C_SLONG",
	//								"SQL_C_ULONG","SQL_C_FLOAT","SQL_C_DOUBLE","SQL_C_DATE","SQL_C_TIME","SQL_C_TIMESTAMP"
	//							};
	//TCHAR					*TestSQLType[] = 
	//							{
	//								"SQL_CHAR","SQL_VARCHAR","SQL_DECIMAL","SQL_NUMERIC","SQL_SMALLINT","SQL_INTEGER","SQL_REAL",
	//								"SQL_FLOAT","SQL_DOUBLE","SQL_DATE","SQL_TIME","SQL_TIMESTAMP","SQL_BIGINT",
	//								"SQL_DECIMAL","SQL_DECIMAL","SQL_DECIMAL","SQL_DECIMAL","SQL_DECIMAL","SQL_DECIMAL","SQL_DECIMAL","SQL_DECIMAL"
	//								"SQL_LONGVARCHAR","SQL_WCHAR","SQL_WVARCHAR","SQL_WLONGVARCHAR"
	//							};
	TCHAR					*ExecDirStr[5];
	TCHAR					*CResults[] = 
								{
#ifndef _WM
									_T("--"),_T("--"),_T("1234.56789"),_T("1234.56789"),_T("1200"),_T("12000"),
									_T("12345.0"),_T("123450.0"),_T("1234500.0"),_T("1993-07-01"),_T("09:45:30"),
									_T("1993-08-02 08:44:31.001000"),_T("120000"),
									_T("1234567890123456789"),
									_T("1234567890123.456789"),
									_T("1234567890123456789012345678901234567890"),
									_T("0.12345678901234567890123456789012345678900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"),
									_T("1234567890.1234567890123456789012345678901234567890000000000000000000000000"),
									_T("12345.56789"),
									_T("1234567890123.56789"),
									_T("12345678901234567890.0123456789"),
#ifdef UNICODE
									_T("--"),_T("--"),_T("--"),_T("--"),_T("--"),_T("--")
#else
									_T("--"),_T("--"),_T("--"),_T("--")
#endif

#else
									_T("--"),_T("--"),_T("1234.56789"),_T("1234.56789"),_T("1200"),_T("12000"),
									_T("12345.0"),_T("123450.0"),_T("1234500.0"),_T("93/07/01"),_T("09:45:30"),
									_T("1993-08-02 08:44:31.001000"),_T("120000"),
									_T("1234567890123456789"),
									_T("1234567890123.456789"),
									_T("1234567890123456789012345678901234567890"),
									_T(".12345678901234567890123456789012345678900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"),
									_T("1234567890.1234567890123456789012345678901234567890000000000000000000000000"),
									_T("12345.56789"),
									_T("1234567890123.56789"),
									_T("12345678901234567890.0123456789"),
									_T("--"),_T("--"),_T("--"),_T("--"),_T("--")
#endif
								};

	TCHAR					*FetchNStr[5];

	struct 
	{
		SQLULEN	AccessParam[2];
		SQLULEN	TransactParam[2];
	} ConnOption = {
			SQL_MODE_READ_WRITE,
			SQL_MODE_READ_ONLY,
			SQL_TXN_READ_COMMITTED,
			SQL_TXN_READ_UNCOMMITTED
		};

	struct _timeb	fetchstarttime;
	struct _timeb fetchendtime;
	long		AccessTime[2];

	//Added for transaction isolation problems
	TCHAR *iso_level_cqd[] = {
		_T("control query default isolation_level 'READ_COMMITTED'"),
		_T("control query default isolation_level 'READ_UNCOMMITTED'"),
		_T("control query default isolation_level 'REPEATABLE_READ'"),
		_T("control query default isolation_level 'SERIALIZABLE'"),
		_T("endloop")
	};

	TCHAR *access_mode[] = {
		_T("default"),
		_T("set transaction READ ONLY"),
		_T("set transaction READ WRITE"),
		_T("endloop")
	};

	SQLTCHAR *sqlstring0 = (SQLTCHAR*)_T("DROP TABLE YRWK_TY_POS_2");
	SQLTCHAR *sqlstring1 = (SQLTCHAR*)_T("CREATE TABLE YRWK_TY_POS_2 ( C1 NUMERIC (9, 2) , C2 NUMERIC (9, 2)) NO PARTITION");
	SQLTCHAR *sqlstring2 = (SQLTCHAR*)_T("INSERT INTO YRWK_TY_POS_2 VALUES (119.28, 6)");
	SQLTCHAR *sqlstring3 = (SQLTCHAR*)_T("SELECT SUM(C1) + SUM(C2) FROM YRWK_TY_POS_2");
	//SQLTCHAR sqlstring0[] = _T("DROP TABLE YRWK_TY_POS_2");
	//SQLTCHAR sqlstring1[] = _T("CREATE TABLE YRWK_TY_POS_2 ( C1 NUMERIC (9, 2) , C2 NUMERIC (9, 2)) NO PARTITION");
	//SQLTCHAR sqlstring2[] = _T("INSERT INTO YRWK_TY_POS_2 VALUES (119.28, 6)");
	//SQLTCHAR sqlstring3[] = _T("SELECT SUM(C1) + SUM(C2) FROM YRWK_TY_POS_2");

//===========================================================================================================
	var_list_t *var_list;
	var_list = load_api_vars(_T("SQLFetch"), charset_file);
	if (var_list == NULL) return FAILED;

	//print_list(var_list);
	ExecDirStr[0] = var_mapping(_T("SQLFetch_ExecDirStr_1"), var_list);
	ExecDirStr[1] = var_mapping(_T("SQLFetch_ExecDirStr_2"), var_list);
	ExecDirStr[2] = var_mapping(_T("SQLFetch_ExecDirStr_3"), var_list);
	ExecDirStr[3] = var_mapping(_T("SQLFetch_ExecDirStr_4"), var_list);
	ExecDirStr[4] = var_mapping(_T("SQLFetch_ExecDirStr_5"), var_list);

	CResults[0] = var_mapping(_T("SQLFetch_CResults_1"), var_list);
	CResults[1] = var_mapping(_T("SQLFetch_CResults_2"), var_list);

#ifdef UNICODE	
	CResults[21] = var_mapping(_T("SQLFetch_datastr1"), var_list);
	CResults[22] = var_mapping(_T("SQLFetch_datastr2"), var_list);
	CResults[23] = var_mapping(_T("SQLFetch_datastr3"), var_list);

	CResults[24] = var_mapping(_T("SQLFetch_CResults_24"), var_list);
	CResults[25] = var_mapping(_T("SQLFetch_CResults_25"), var_list);
	CResults[26] = var_mapping(_T("SQLFetch_CResults_26"), var_list);
#else
	CResults[21] = var_mapping(_T("SQLFetch_CResults_21"), var_list);
	CResults[22] = var_mapping(_T("SQLFetch_CResults_22"), var_list);
	CResults[23] = var_mapping(_T("SQLFetch_CResults_23"), var_list);
	CResults[24] = var_mapping(_T("SQLFetch_CResults_24"), var_list);
#endif

	FetchNStr[0] = var_mapping(_T("SQLFetch_FetchNStr_1"), var_list);
	FetchNStr[1] = var_mapping(_T("SQLFetch_FetchNStr_2"), var_list);
	FetchNStr[2] = var_mapping(_T("SQLFetch_FetchNStr_3"), var_list);
	FetchNStr[3] = var_mapping(_T("SQLFetch_FetchNStr_4"), var_list);
	FetchNStr[4] = var_mapping(_T("SQLFetch_FetchNStr_5"), var_list);

//=================================================================================================

	LogMsg(LINEBEFORE+SHORTTIMESTAMP,_T("Begin testing API =>SQLFetch.\n"));

	TEST_INIT;

	TESTCASE_BEGIN("Setup for SQLFetch tests\n");

	if(!FullConnect(pTestInfo))
	{
		LogMsg(ERRMSG,_T("Unable to connect\n"));
		TEST_FAILED;
		TEST_RETURN;
	}

	henv = pTestInfo->henv;
 	hdbc = pTestInfo->hdbc;
 	hstmt = (SQLHANDLE)pTestInfo->hstmt;
   	
	returncode = SQLAllocStmt((SQLHANDLE)hdbc, &hstmt);	
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLAllocStmt"))
	{
		LogAllErrors(henv,hdbc,hstmt);
		TEST_FAILED;
		TEST_RETURN;
	}

	SQLExecDirect(hstmt,(SQLTCHAR*) ExecDirStr[0],SQL_NTS); /* cleanup */
	returncode = SQLExecDirect(hstmt,(SQLTCHAR*)ExecDirStr[1],SQL_NTS);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect"))
	{
		LogAllErrors(henv,hdbc,hstmt);
		TEST_FAILED;
		TEST_RETURN;
	}

	returncode = SQLExecDirect(hstmt,(SQLTCHAR*)ExecDirStr[2], SQL_NTS);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect"))
	{
		LogAllErrors(henv,hdbc,hstmt);
		TEST_FAILED;
		TEST_RETURN;
	}
	TESTCASE_END; // end of setup

	for (i = 0; i < 1; i++)
	{ // begin of 1st for loop 
		_stprintf(Heading,_T("Test 1.%d: Positive functionality of SQLFetch by doing SQLBindcol\n"),i);
		TESTCASE_BEGINW(Heading);
		returncode = SQLExecDirect(hstmt,(SQLTCHAR*)ExecDirStr[3], SQL_NTS);
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect"))
		{
			LogAllErrors(henv,hdbc,hstmt);
			TEST_FAILED;
			TEST_RETURN;
		}

		for (j=0; j<MAX_NUM1; j++)
		{
			CCharOutput1[j] = (TCHAR *)malloc(sizeof(TCHAR)*NAME_LEN);
			*(CCharOutput1[j])=(TCHAR)'\0';
			returncode = SQLBindCol(hstmt,(SWORD)(j+1),CType[i],CCharOutput1[j],NAME_LEN,&OutputLen1[j]);
			if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol"))
			{
				TEST_FAILED;
				LogAllErrors(henv,hdbc,hstmt);
				TEST_RETURN;
			}
		}

		returncode = SQLFetch(hstmt);
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLFetch"))
		{
			TEST_FAILED;
			LogAllErrors(henv,hdbc,hstmt);
		}
		else
		{
			for (j=0; j<MAX_NUM1; j++)
			{
				if (_tcscmp(CCharOutput1[j],CResults[j]) == 0)
				{
					LogMsg(NONE,_T("expect: '%s' and actual: '%s' of column %d are matched\n"),CResults[j],CCharOutput1[j],j+1);
				}	
				else
				{
					TEST_FAILED;	
					LogMsg(ERRMSG,_T("expect: '%s' and actual: '%s' of column %d are not match, at line %d\n"), CResults[j],CCharOutput1[j],j+1,__LINE__);
				}
				free(CCharOutput1[j]);
			} 
		}

		SQLFreeStmt(hstmt,SQL_CLOSE);
		TESTCASE_END;
	} // end of 1st for loop 

//============================================================================================

	TESTCASE_BEGIN("Setup for more SQLFetch tests\n");
	SQLFreeStmt(hstmt,SQL_DROP);
	SQLAllocStmt((SQLHANDLE)hdbc, &hstmt);	
	SQLExecDirect(hstmt,(SQLTCHAR*)ExecDirStr[4],SQL_NTS);
	returncode = SQLExecDirect(hstmt,(SQLTCHAR*)ExecDirStr[2], SQL_NTS);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect"))
	{
		LogAllErrors(henv,hdbc,hstmt);
		TEST_FAILED;
		TEST_RETURN;
	}
	TESTCASE_END;

	for (i = 0; i < 1; i++)
	{
		_stprintf(Heading,_T("Test 2.%d: Positive functionality of SQLFetch by doing SQLGetData\n"),i);
		TESTCASE_BEGINW(Heading);
		returncode = SQLExecDirect(hstmt,(SQLTCHAR*)ExecDirStr[3], SQL_NTS);
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect"))
		{
			LogAllErrors(henv,hdbc,hstmt);
			TEST_FAILED;
			TEST_RETURN;
		}
		returncode = SQLFetch(hstmt);
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLFetch"))
		{
			TEST_FAILED;
			LogAllErrors(henv,hdbc,hstmt);
		}
		else
		{
			for (j=0; j<MAX_NUM1; j++)
			{
				returncode = SQLGetData(hstmt,(SWORD)(j+1),CType[i],CCharOutput2,NAME_LEN,&OutputLen2);
				if(!CHECKRC(SQL_SUCCESS,returncode,"SQLGetData"))
				{
					TEST_FAILED;
					LogAllErrors(henv,hdbc,hstmt);
				}

				if (_tcscmp(CCharOutput2,CResults[j]) == 0)
				{
					LogMsg(NONE,_T("expect: '%s' and actual: '%s' of column %d are matched\n"), CResults[j],CCharOutput2,j+1);
				}	
				else
				{
					TEST_FAILED;	
					LogMsg(ERRMSG,_T("expect: '%s' and actual: '%s' of column %d are not match, at line %d\n"),CResults[j],CCharOutput2,j+1,__LINE__);
				}
			}
		}

		SQLFreeStmt(hstmt,SQL_CLOSE);
		TESTCASE_END;
	} 
	
//============================================================================================

	for (fn = 0; fn < NUM_FETCH_LOOP; fn++)
	{
		_stprintf(Heading,_T("Setup for Fetch %d tests\n"),(ROWS_INSERTED*(fn+1)));
		TESTCASE_BEGINW(Heading);
		SQLFreeStmt(hstmt,SQL_DROP);
		SQLAllocStmt((SQLHANDLE)hdbc, &hstmt);	
		SQLSetConnectOption((SQLHANDLE)hdbc,SQL_ACCESS_MODE,SQL_MODE_READ_WRITE);
		SQLSetConnectOption((SQLHANDLE)hdbc,SQL_TXN_ISOLATION,SQL_TXN_READ_COMMITTED);
		SQLExecDirect(hstmt,(SQLTCHAR*) FetchNStr[0],SQL_NTS); /* cleanup */
		returncode = SQLExecDirect(hstmt,(SQLTCHAR*)FetchNStr[1],SQL_NTS);
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect"))
		{
			LogAllErrors(henv,hdbc,hstmt);
			TEST_FAILED;
			TEST_RETURN;
		}
		for (i = 0; i < (ROWS_INSERTED*(fn+1)); i++)
		{ 
			returncode = SQLExecDirect(hstmt,(SQLTCHAR*)FetchNStr[2], SQL_NTS);
			if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect"))
			{
				LogAllErrors(henv,hdbc,hstmt);
				TEST_FAILED;
				TEST_RETURN;
			}
		}
		TESTCASE_END; // end of setup

		_stprintf(Heading,_T("Test Positive functionality of Fetch %d by doing SQLBindcol\n"),(ROWS_INSERTED*(fn+1)));
		TESTCASE_BEGINW(Heading);
		for (k = 0; k < 2; k++)
		{
			returncode = SQLSetConnectOption((SQLHANDLE)hdbc,SQL_ACCESS_MODE,ConnOption.AccessParam[k]);
			if(!CHECKRC(SQL_SUCCESS,returncode,"SQLSetConnection Access"))
			{
				TEST_FAILED;
				LogAllErrors(henv,hdbc,hstmt);
				TEST_RETURN;
			}
			returncode = SQLSetConnectOption((SQLHANDLE)hdbc,SQL_TXN_ISOLATION,ConnOption.TransactParam[k]);
			if(!CHECKRC(SQL_SUCCESS,returncode,"SQLSetConnection Transact"))
			{
				TEST_FAILED;
				LogAllErrors(henv,hdbc,hstmt);
				TEST_RETURN;
			}
			returncode = SQLSetStmtOption(hstmt,SQL_ROWSET_SIZE,1);
			if(!CHECKRC(SQL_SUCCESS,returncode,"SQLSetStmtOption"))
			{
				TEST_FAILED;
				LogAllErrors(henv,hdbc,hstmt);
				TEST_RETURN;
			}
			returncode = SQLExecDirect(hstmt,(SQLTCHAR*)FetchNStr[3], SQL_NTS);
			if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect"))
			{
				LogAllErrors(henv,hdbc,hstmt);
				TEST_FAILED;
				TEST_RETURN;
			}
			returncode = SQLNumResultCols(hstmt, &col);
			if(!CHECKRC(SQL_SUCCESS,returncode,"SQLNumResultCols"))
			{
				LogAllErrors(henv,hdbc,hstmt);
				TEST_FAILED;
			}
			for (j = 0; j < col; j++)
			{
				CCharOutput1[j] = (TCHAR *)malloc(NAME_LEN);
				*(CCharOutput1[j])=(TCHAR)'\0';
				returncode = SQLBindCol(hstmt,(SWORD)(j+1),SQL_C_TCHAR,CCharOutput1[j],NAME_LEN,&OutputLen1[j]);
				if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol"))
				{
					TEST_FAILED;
					LogAllErrors(henv,hdbc,hstmt);
					TEST_RETURN;
				}
			} // end of 2nd for loop 

			returncode = SQL_SUCCESS;
			_ftime(&fetchstarttime);
			j = 0;
			while (returncode == SQL_SUCCESS)
			{
				returncode = SQLFetch(hstmt);
				if((returncode != SQL_SUCCESS) && (j < col)) // need to make sure we haven't fallen off the end of the table
				{
				   if (returncode == SQL_NO_DATA_FOUND)
				   {
					    if (!FindError(_T("00000"),henv,hdbc,hstmt)) // SQLState should be "00000" when return code is SQL_NO_DATA_FOUND.
						{	
							TEST_FAILED;
							//assert(0);
							LogMsg(NONE,_T("Rows #: %d : array %d suppose to be %d at line %d.\n"),j,k, (ROWS_INSERTED*(fn+1)),__LINE__);
							LogAllErrors(henv,hdbc,hstmt);
						}
				   }     
				   else
				   {
					TEST_FAILED;
					LogAllErrors(henv,hdbc,hstmt);
				   }
				}
				if (returncode == SQL_SUCCESS)
					j++;
			}
			_ftime(&fetchendtime);
			if (j == (ROWS_INSERTED*(fn+1)))
			{
				LogMsg(NONE,_T("Rows inserted Expected: %d and Actual: %d.\n"),(ROWS_INSERTED*(fn+1)),j);
			}	
			else
			{
				TEST_FAILED;	
				LogMsg(ERRMSG,_T("Rows inserted Expected: %d and Actual: %d at line%d.\n"),(ROWS_INSERTED*(fn+1)),j,__LINE__);
			}

			AccessTime[k] = (long)(((fetchendtime.time - fetchstarttime.time) * 1000) + (fetchendtime.millitm - fetchstarttime.millitm));
			for (j = 0; j < col; j++)
			{
				free(CCharOutput1[j]);
			} // end of 3rd for loop 
			SQLFreeStmt(hstmt,SQL_CLOSE);
		}
/*
		if (AccessTime[0] >= 	AccessTime[1])
		{
			LogMsg(NONE,_T("FETCH ONE: %d millisecs and FETCH N: %d millisecs.\n"),AccessTime[0],AccessTime[1]);
		}	
		else
		{
			TEST_FAILED;	
			LogMsg(ERRMSG,_T("FETCH ONE: %d millisecs and FETCH N: %d millisecs.\n"),AccessTime[0],AccessTime[1]);
		}
*/
		LogMsg(NONE,_T("FETCH ONE: %d millisecs and FETCH N: %d millisecs.\n"),AccessTime[0],AccessTime[1]);
		TESTCASE_END;
		SQLSetConnectOption((SQLHANDLE)hdbc,SQL_ACCESS_MODE,SQL_MODE_READ_WRITE);
		SQLSetConnectOption((SQLHANDLE)hdbc,SQL_TXN_ISOLATION,SQL_TXN_READ_COMMITTED);
		SQLExecDirect(hstmt,(SQLTCHAR*) FetchNStr[0],SQL_NTS); /* cleanup */
	}
	SQLExecDirect(hstmt,(SQLTCHAR*) ExecDirStr[0],SQL_NTS); /* cleanup */

//=====================================================================================================

	TESTCASE_BEGIN("Setup for SQLFetch isolation level tests\n");
	SQLFreeStmt(hstmt,SQL_DROP);
	SQLAllocStmt((SQLHANDLE)hdbc, &hstmt);	
	SQLExecDirect(hstmt,(SQLTCHAR*)ExecDirStr[0],SQL_NTS);/*clean up*/
	returncode = SQLExecDirect(hstmt,(SQLTCHAR*)ExecDirStr[1], SQL_NTS);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect"))
	{
		LogAllErrors(henv,hdbc,hstmt);
		TEST_FAILED;
		TEST_RETURN;
	}
	returncode = SQLExecDirect(hstmt,(SQLTCHAR*)ExecDirStr[2], SQL_NTS);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect"))
	{
		LogAllErrors(henv,hdbc,hstmt);
		TEST_FAILED;
		TEST_RETURN;
	}
	TESTCASE_END;

	i = 0; k = 0;
	while (_tcsicmp(iso_level_cqd[k],_T("endloop")) != 0)
	{
		h = 0;
		while (_tcsicmp(access_mode[h],_T("endloop")) != 0) {
			if ((_tcsstr(iso_level_cqd[k],_T("READ_UNCOMMITTED")) != NULL && _tcsstr(access_mode[h],_T("READ WRITE")) != NULL) ||
				(_tcsstr(iso_level_cqd[k],_T("REPEATABLE_READ")) != NULL && _tcsstr(access_mode[h],_T("default")) != NULL) ||
				(_tcsstr(iso_level_cqd[k],_T("SERIALIZABLE")) != NULL && _tcsstr(access_mode[h],_T("default")) != NULL))
			{
				h++;
				continue;
			}

			FullDisconnect(pTestInfo);

			_stprintf(Heading, _T("Setup for SQLFetch with: %s\nAnd access-mode: %s\n"), iso_level_cqd[k], access_mode[h]);
			TESTCASE_BEGINW(Heading);
			if(!FullConnect(pTestInfo))
			{
				LogMsg(ERRMSG,_T("Unable to connect\n"));
				TEST_FAILED;
				TEST_RETURN;
			}

			henv = pTestInfo->henv;
 			hdbc = pTestInfo->hdbc;
 			hstmt = (SQLHANDLE)pTestInfo->hstmt;
		   	
			returncode = SQLAllocStmt((SQLHANDLE)hdbc, &hstmt);	
			if(!CHECKRC(SQL_SUCCESS,returncode,"SQLAllocStmt"))
			{
				LogAllErrors(henv,hdbc,hstmt);
				TEST_FAILED;
				TEST_RETURN;
			}

			returncode = SQLExecDirect(hstmt,(SQLTCHAR*)iso_level_cqd[k],SQL_NTS);
			if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect"))
			{
				LogAllErrors(henv,hdbc,hstmt);
				TEST_FAILED;
				TEST_RETURN;
			}

			if (_tcsicmp(access_mode[h],_T("default")) != 0) {
				returncode = SQLExecDirect(hstmt,(SQLTCHAR*)access_mode[h],SQL_NTS);
				if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect"))
				{
					LogAllErrors(henv,hdbc,hstmt);
					TEST_FAILED;
					TEST_RETURN;
				}
			}

			TESTCASE_END; // end of setup

			_stprintf(Heading,_T("SQLFetch by doing SQLGetData\n"));
			TESTCASE_BEGINW(Heading);
			returncode = SQLExecDirect(hstmt,(SQLTCHAR*)ExecDirStr[3], SQL_NTS);
			if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect"))
			{
				LogAllErrors(henv,hdbc,hstmt);
				TEST_FAILED;
				//TEST_RETURN;
			}
			returncode = SQLFetch(hstmt);
			if(!CHECKRC(SQL_SUCCESS,returncode,"SQLFetch"))
			{
				TEST_FAILED;
				LogAllErrors(henv,hdbc,hstmt);
			}
			else
			{
				for (j=0; j<MAX_NUM1; j++)
				{
					returncode = SQLGetData(hstmt,(SWORD)(j+1),CType[i],CCharOutput2,NAME_LEN,&OutputLen2);
					if(!CHECKRC(SQL_SUCCESS,returncode,"SQLGetData"))
					{
						TEST_FAILED;
						LogAllErrors(henv,hdbc,hstmt);
					}

					if (_tcscmp(CCharOutput2,CResults[j]) == 0)
					{
						LogMsg(NONE,_T("expect: '%s' and actual: '%s' of column %d are matched\n"),CResults[j],CCharOutput2,j+1);
					}	
					else
					{
						TEST_FAILED;	
						LogMsg(ERRMSG,_T("expect: '%s' and actual: '%s' of column %d are not match, at line %d\n"),CResults[j],CCharOutput2,j+1,__LINE__);
					}
				}
			}

			SQLFreeStmt(hstmt,SQL_CLOSE);
			TESTCASE_END;
			h++;
		}

		k++;
	}//End while

	SQLExecDirect(hstmt,(SQLTCHAR*) ExecDirStr[0],SQL_NTS); /* cleanup */
	
//============================================================================================
	TESTCASE_BEGIN("Testcase for Mode_special_1\n");

	returncode = SQLExecDirect(hstmt,sqlstring0,SQL_NTS);

	returncode = SQLExecDirect(hstmt,sqlstring1,SQL_NTS);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect"))
	{
		LogAllErrors(henv,hdbc,hstmt);
		TEST_FAILED;
		TEST_RETURN;
	}
	returncode = SQLExecDirect(hstmt,sqlstring2,SQL_NTS);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect"))
	{
		LogAllErrors(henv,hdbc,hstmt);
		TEST_FAILED;
		TEST_RETURN;
	}

	returncode = SQLPrepare(hstmt,sqlstring3,SQL_NTS);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLPrepare"))
	{
		LogAllErrors(henv,hdbc,hstmt);
		TEST_FAILED;
		TEST_RETURN;
	}

	returncode = SQLBindCol(hstmt,1,SQL_C_TCHAR,CCharOutput2,300,NULL);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol"))
	{
		LogAllErrors(henv,hdbc,hstmt);
		TEST_FAILED;
		TEST_RETURN;
	}

	returncode = SQLExecute(hstmt);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecute"))
	{
		LogAllErrors(henv,hdbc,hstmt);
		TEST_FAILED;
		TEST_RETURN;
	}

	returncode = SQLFetch(hstmt);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLFetch"))
	{
		LogAllErrors(henv,hdbc,hstmt);
		TEST_FAILED;
		TEST_RETURN;
	}

#ifndef _WM
	if (_tcscmp(CCharOutput2,_T("125.2")) == 0)
	{
		LogMsg(NONE,_T("expect: '125.2' and actual: '%s' are matched\n"),CCharOutput2);
	}	
	else
	{
		TEST_FAILED;	
		LogMsg(ERRMSG,_T("expect: '125.2' and actual: '%s' are not match, at line %d\n"),CCharOutput2,__LINE__);
	}
#else
	if (_tcscmp(CCharOutput2,"125.28") == 0)
	{
		LogMsg(NONE,_T("expect: '125.28' and actual: '%s' are matched\n"),CCharOutput2);
	}	
	else
	{
		TEST_FAILED;	
		LogMsg(ERRMSG,_T("expect: '125.28' and actual: '%s' are not match, at line %d\n"),CCharOutput2,__LINE__);
	}
#endif

//============================================================================================
	
	FullDisconnect(pTestInfo);
	LogMsg(SHORTTIMESTAMP+LINEAFTER,_T("End testing API => SQLFetch.\n"));
	free_list(var_list);
	TEST_RETURN;
}
Beispiel #16
0
/*
---------------------------------------------------------
   TestSQLEndTran
---------------------------------------------------------
*/
PassFail TestMXSQLEndTran(TestInfo *pTestInfo)
{                  
	TEST_DECLARE;
	RETCODE			returncode;
	TCHAR			Heading[MAX_STRING_SIZE];
	SQLHANDLE 		henv;
 	SQLHANDLE 		hdbc;
 	SQLHANDLE		hstmt;
	TCHAR			*ExecDirStr[] = 
							{
								//"create table testtransact(c1 TCHAR(20),c2 integer)",
								//"create table testtransact(c1 TCHAR(20),c2 integer) NO PARTITION",
                                // The  NO PARTITION is to help speed up this test on NEO/clustered systems with POS turned on.
								_T("--"),
								_T("--"),
								_T("--"),
								_T("--"),
								_T("--"),
								_T("--")
							};
	UWORD			fType[] = { SQL_ROLLBACK, SQL_COMMIT };
	TCHAR			*TypeDesc[] = { _T("SQL_ROLLBACK"), _T("SQL_COMMIT") };
	TCHAR			*Output;
	SQLLEN			OutputLen; // sushil
	struct
	{
		SWORD	ExeRes[2];
		SWORD	FetchRes[2];
		TCHAR	*DataRes[2];
	} CheckRes[] =	{
						{SQL_ERROR,SQL_SUCCESS,SQL_NO_DATA_FOUND,SQL_NO_DATA_FOUND,_T(""),_T("")},
						{SQL_SUCCESS,SQL_SUCCESS,SQL_NO_DATA_FOUND,SQL_SUCCESS,_T(""),_T("--")},
						{SQL_SUCCESS,SQL_SUCCESS,SQL_SUCCESS,SQL_SUCCESS,_T("--"),_T("--")},
						{SQL_SUCCESS,SQL_SUCCESS,SQL_SUCCESS,SQL_NO_DATA_FOUND,_T("--"),_T("")},
						{SQL_SUCCESS,SQL_ERROR,SQL_NO_DATA_FOUND,SQL_NO_DATA_FOUND,_T(""),_T("")}
					};
	int	i = 0, j = 0, iend = 5, jend = 1, commit_on_off = 0;

//===========================================================================================================
	var_list_t *var_list;
	var_list = load_api_vars(_T("SQLEndTran"), charset_file);
	if (var_list == NULL) return FAILED;

	ExecDirStr[0] = var_mapping(_T("SQLEndTran_ExecDirStr_0"), var_list);
	ExecDirStr[1] = var_mapping(_T("SQLEndTran_ExecDirStr_1"), var_list);
	ExecDirStr[2] = var_mapping(_T("SQLEndTran_ExecDirStr_2"), var_list);
	ExecDirStr[3] = var_mapping(_T("SQLEndTran_ExecDirStr_3"), var_list);
	ExecDirStr[4] = var_mapping(_T("SQLEndTran_ExecDirStr_4"), var_list);
	ExecDirStr[5] = var_mapping(_T("SQLEndTran_ExecDirStr_5"), var_list);

	CheckRes[1].DataRes[1] = var_mapping(_T("SQLEndTran_Insert"), var_list);
	CheckRes[2].DataRes[0] = var_mapping(_T("SQLEndTran_Insert"), var_list);
	CheckRes[2].DataRes[1] = var_mapping(_T("SQLEndTran_Update"), var_list);
	CheckRes[3].DataRes[0] = var_mapping(_T("SQLEndTran_Update"), var_list);

//========================================================================================================

	LogMsg(LINEBEFORE+SHORTTIMESTAMP,_T("Begin testing API => SQLEndTran.\n"));
	TEST_INIT;

	TESTCASE_BEGIN("Initializing SQLEndTran test environment\n");
	if(!FullConnectWithOptions(pTestInfo, CONNECT_ODBC_VERSION_3))
	{
		LogMsg(NONE,_T("Unable to connect\n"));
		TEST_FAILED;
		TEST_RETURN;
	}
	henv = pTestInfo->henv;
 	hdbc = pTestInfo->hdbc;
 	hstmt = (SQLHANDLE)pTestInfo->hstmt;
	returncode = SQLAllocHandle(SQL_HANDLE_STMT, (SQLHANDLE)hdbc, &hstmt);	
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLAllocHandle"))
	{
		LogAllErrorsVer3(henv,hdbc,hstmt);
		FullDisconnect(pTestInfo);
		TEST_FAILED;
		TEST_RETURN;
	}
	//setting CQD to set POS OFF,as some tests fail otherwise. (to be fixed)
	//SQLExecDirect (hstmt,"CONTROL QUERY DEFAULT POS 'OFF'",SQL_NTS);

	for (commit_on_off = 0; commit_on_off < 10; commit_on_off++)
	{
		returncode = SQLSetConnectAttr((SQLHANDLE)hdbc,SQL_AUTOCOMMIT,(void *)SQL_AUTOCOMMIT_ON,0);
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLSetConnectAttr"))
		{
			LogAllErrorsVer3(henv,hdbc,hstmt);
			FullDisconnect(pTestInfo);
			TEST_FAILED;
			TEST_RETURN;
		}
		TESTCASE_END;
		SQLExecDirect(hstmt,(SQLTCHAR*)ExecDirStr[4],SQL_NTS); /* CLEANUP */
		for (i = 0; i <= (iend-1); i++)
		{
			_stprintf(Heading,_T("Test Positive Functionality of SQLEndTran while Autocommit is ON and executing\n"));
			_tcscat(Heading, ExecDirStr[i]);
			_tcscat(Heading, _T("\n"));
			TESTCASE_BEGINW(Heading);
			returncode = SQLExecDirect(hstmt,(SQLTCHAR*)ExecDirStr[i],SQL_NTS);
			if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect"))
			{
				LogAllErrorsVer3(henv,hdbc,hstmt);
				TEST_FAILED;
			}
		}
		SQLExecDirect(hstmt,(SQLTCHAR*)ExecDirStr[4],SQL_NTS); /* CLEANUP */
		returncode = SQLSetConnectAttr((SQLHANDLE)hdbc,SQL_AUTOCOMMIT,(void *)SQL_AUTOCOMMIT_OFF,0);
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLSetConnectAttr"))
		{
			LogAllErrorsVer3(henv,hdbc,hstmt);
			FullDisconnect(pTestInfo);
			TEST_FAILED;
			TEST_RETURN;
		}
		TESTCASE_END;
		
		for (i = 0; i <= (iend-1); i++)
		{
			for (j = 0; j <= jend; j++)
			{
				_stprintf(Heading,_T("Test Positive Functionality of SQLEndTran while Autocommit is OFF and executing\n"));
				_tcscat(Heading, ExecDirStr[i]);
				_tcscat(Heading, _T(" & "));
				_tcscat(Heading, TypeDesc[j]);
				_tcscat(Heading, _T("\n"));
				TESTCASE_BEGINW(Heading);
				
				returncode = SQLExecDirect(hstmt,(SQLTCHAR*)ExecDirStr[i],SQL_NTS);
				if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect"))
				{
					LogAllErrorsVer3(henv,hdbc,hstmt);
					TEST_FAILED;
				}
				else
				{
					returncode=SQLEndTran(SQL_HANDLE_DBC,(SQLHANDLE)hdbc,fType[j]);
					Sleep(2);																// tmf rollback is slower.
					if(!CHECKRC(SQL_SUCCESS,returncode,"SQLTransact"))
					{
						LogAllErrorsVer3(henv,hdbc,hstmt);
						TEST_FAILED;
					}

					returncode = SQLExecDirect(hstmt,(SQLTCHAR*)ExecDirStr[iend],SQL_NTS);
					if(!CHECKRC(CheckRes[i].ExeRes[j],returncode,"SQLExecDirect"))
					{
						LogAllErrorsVer3(henv,hdbc,hstmt);
						TEST_FAILED;
					}
					else
					{
						if (returncode == SQL_SUCCESS || returncode == SQL_SUCCESS_WITH_INFO)
						{
							Output = (TCHAR *)malloc(NAME_LEN);
							returncode=SQLBindCol(hstmt,1,SQL_C_TCHAR,Output,NAME_LEN,&OutputLen);
							if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol"))
							{
								LogAllErrorsVer3(henv,hdbc,hstmt);
								TEST_FAILED;
							}
							else
							{
								returncode = SQLFetch(hstmt);
								if(!CHECKRC(CheckRes[i].FetchRes[j],returncode,"SQLFetch"))
								{
									LogAllErrorsVer3(henv,hdbc,hstmt);
									TEST_FAILED;
								}
								else
								{
									if (returncode != SQL_NO_DATA_FOUND && returncode != SQL_ERROR)
									{
										if (_tcscspn(CheckRes[i].DataRes[j],Output) == 0)
										{
											//LogMsg(NONE,_T("expect: %s and actual: %s are matched\n"),Output,CheckRes[i].DataRes[j]);
										}	
										else
										{
											LogMsg(ERRMSG,_T("expect: %s and actual: %s are not matched at line %d \n"),Output,CheckRes[i].DataRes[j],__LINE__);
											TEST_FAILED;	
										}
									}
								}
								free(Output);
								SQLFreeStmt(hstmt,SQL_CLOSE);
							}
						}
					}
				}
			//SQLFreeStmt(hstmt,SQL_CLOSE);
			TESTCASE_END;
			}/* end i loop */
		//SQLExecDirect(hstmt,(SQLTCHAR*)ExecDirStr[4],SQL_NTS); /* CLEANUP */
		}/* end j loop */
	}

//========================================================================================================

	SQLExecDirect(hstmt,(SQLTCHAR*)ExecDirStr[4],SQL_NTS); /* CLEANUP */
    
	returncode = SQLDisconnect((SQLHANDLE)hdbc);
    if(!CHECKRC(SQL_ERROR,returncode,"SQLDisconnect")) 
	{
		LogAllErrorsVer3(henv,hdbc,hstmt);
		TEST_FAILED;	
	}	
	
	// Free the open transactions.
	returncode=SQLEndTran(SQL_HANDLE_DBC,(SQLHANDLE)hdbc,SQL_ROLLBACK);
	Sleep(2);	

	returncode=FullDisconnect3(pTestInfo);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLFullDisconnect"))
	{
		LogAllErrorsVer3(henv,hdbc,hstmt);
		TEST_FAILED;
	}

	LogMsg(SHORTTIMESTAMP+LINEAFTER,_T("End testing API => SQLEndTran.\n"));
	free_list(var_list);
	TEST_RETURN;
}
Beispiel #17
0
PassFail TestSQLSpecialColumns(TestInfo *pTestInfo, int MX_MP_SPECIFIC)
{                  
	TEST_DECLARE;
 	TCHAR			Heading[MAX_HEADING_SIZE];
 	RETCODE			returncode;
 	SQLHANDLE 		henv;
 	SQLHANDLE 		hdbc;
 	SQLHANDLE		hstmt;
	TCHAR			TQualifier[NAME_LEN],TOwner[NAME_LEN],TName[NAME_LEN];
	UWORD			fColType[NUM_COLTYPE] = {SQL_BEST_ROWID,SQL_ROWVER};
	UWORD			Scope[NUM_SCOPE] = {SQL_SCOPE_CURROW,SQL_SCOPE_TRANSACTION,SQL_SCOPE_SESSION};
	UWORD			Nullable[NUM_NULL] = {SQL_NO_NULLS,SQL_NULLABLE};
	TCHAR			ocname[MAX_COLUMN_NAME],octype[MAX_COLUMN_NAME];
	SWORD			oscope,ocdatatype,ocsca,ocpc;
	SDWORD			ocprec,oclen;		
	SQLLEN			oscopelen,ocnamelen,ocdatatypelen,octypelen,ocpreclen,oclenlen,ocscalen,ocpclen;

	struct
	{
		TCHAR		*ColName;
		SWORD		ColDataType;
		TCHAR		*ColTypeName;
		TCHAR		*ColTypeOutput;
		TCHAR		*ColTypeLen;
		SDWORD		ColPrec;
		SWORD		ColSca;
		SDWORD		ColLen;
	} Columns[] = {
							{_T("--"),SQL_CHAR,_T("char"),_T("CHAR"),_T("(10) CHARACTER SET ISO88591"),10,0,10},
							{_T("--"),SQL_VARCHAR,_T("varchar"),_T("VARCHAR"),_T("(10) CHARACTER SET ISO88591"),10,0,10},
							{_T("--"),SQL_VARCHAR,_T("varchar"),_T("VARCHAR"),_T("(255) CHARACTER SET ISO88591"),255,0,255},
							{_T("--"),SQL_WCHAR,_T("char"),_T("NCHAR"),_T("(10) CHARACTER SET UCS2"),10,0,20},
							{_T("--"),SQL_WVARCHAR,_T("varchar"),_T("NCHAR VARYING"),_T("(10) CHARACTER SET UCS2"),10,0,20},
							{_T("--"),SQL_WVARCHAR,_T("varchar"),_T("NCHAR VARYING"),_T("(255) CHARACTER SET UCS2"),255,0,510},
							{_T("--"),SQL_DECIMAL,_T("decimal"),_T("DECIMAL SIGNED"),_T("(10,5)"),10,5,12},
							{_T("--"),SQL_NUMERIC,_T("numeric"),_T("NUMERIC SIGNED"),_T("(10,5)"),10,5,12},
							{_T("--"),SQL_NUMERIC,_T("numeric"),_T("NUMERIC SIGNED"),_T("(19,0)"),19,0,21},				//Bignum
							{_T("--"),SQL_NUMERIC,_T("numeric"),_T("NUMERIC SIGNED"),_T("(19,6)"),19,6,21},				//Bignum
							{_T("--"),SQL_NUMERIC,_T("numeric"),_T("NUMERIC SIGNED"),_T("(128,0)"),128,0,130},			//Bignum
							{_T("--"),SQL_NUMERIC,_T("numeric"),_T("NUMERIC SIGNED"),_T("(128,128)"),128,128,130},		//Bignum
							{_T("--"),SQL_NUMERIC,_T("numeric"),_T("NUMERIC SIGNED"),_T("(128,64)"),128,64,130},			//Bignum
							{_T("--"),SQL_NUMERIC,_T("numeric"),_T("NUMERIC UNSIGNED"),_T("(10,5) unsigned"),10,5,12},		//Bignum
							{_T("--"),SQL_NUMERIC,_T("numeric"),_T("NUMERIC UNSIGNED"),_T("(18,5) unsigned"),18,5,20},		//Bignum
							{_T("--"),SQL_NUMERIC,_T("numeric"),_T("NUMERIC UNSIGNED"),_T("(30,10) unsigned"),30,10,32},	//Bignum
							{_T("--"),SQL_SMALLINT,_T("smallint"),_T("SMALLINT SIGNED"),_T(""),5,0,2},
							{_T("--"),SQL_INTEGER,_T("integer"),_T("INTEGER SIGNED"),_T(""),10,0,4},
							{_T("--"),SQL_BIGINT,_T("bigint"),_T("BIGINT SIGNED"),_T(""),19,0,20},
							{_T("--"),SQL_DATE,_T("date"),_T("DATE"),_T(""),10,0,6},
							{_T("--"),SQL_TIME,_T("time"),_T("TIME"),_T(""),8,0,6},
							{_T("--"),SQL_TIMESTAMP,_T("TIMESTAMP"),_T("timestamp"),_T(""),26,6,16},
							{_T("--"),SQL_BIT,_T("bit"),_T("BIT"),_T(""),1,1,0},
							{_T("--"),SQL_TINYINT,_T("tinyint"),_T("TINYINT"),_T(""),3,0,2},
							{_T("--"),SQL_BINARY,_T("binary"),_T("BINARY"),_T("(10)"),10,0,10},
							{_T("--"),SQL_VARBINARY,_T("varbinary"),_T("VARBINARY"),_T("(10)"),10,0,10},
							{_T("--"),SQL_WCHAR,_T("char"),_T("NCHAR"),_T("(10) CHARACTER SET UTF8"),10,0,20},
							{_T("--"),SQL_WVARCHAR,_T("varchar"),_T("NCHAR VARYING"),_T("(10) CHARACTER SET UTF8"),10,0,20},
							{_T("--"),SQL_WVARCHAR,_T("varchar"),_T("NCHAR VARYING"),_T("(255) CHARACTER SET UTF8"),255,0,510},
							{_T("--"),0,_T("endloop"),_T(""),0,0,0,0}
						};

	TCHAR	*TableStr[4];
	TCHAR	ColStr[MAX_NOS_SIZE], KeyStr[MAX_NOS_SIZE], CreateTbl[MAX_NOS_SIZE],END_LOOP[10];
	int		i = 0, k = 0,ct = 0, s = 0, t = 0, n = 0, psc = 1;
    BOOL    found = FALSE;
	//TCHAR *charNameUCS2 = _T("NCHAR");
	//TCHAR *varcharNameUCS2 = _T("NCHAR VARYING");

//===========================================================================================================
	var_list_t *var_list;
	var_list = load_api_vars(_T("SQLSpecialColumns"), charset_file);
	if (var_list == NULL) return FAILED;

	//print_list(var_list);
	Columns[0].ColName = var_mapping(_T("SQLSpecialColumns_Columns_1"), var_list);
	Columns[1].ColName = var_mapping(_T("SQLSpecialColumns_Columns_2"), var_list);
	Columns[2].ColName = var_mapping(_T("SQLSpecialColumns_Columns_3"), var_list);
	Columns[3].ColName = var_mapping(_T("SQLSpecialColumns_Columns_4"), var_list);
	Columns[4].ColName = var_mapping(_T("SQLSpecialColumns_Columns_5"), var_list);
	Columns[5].ColName = var_mapping(_T("SQLSpecialColumns_Columns_6"), var_list);
	Columns[6].ColName = var_mapping(_T("SQLSpecialColumns_Columns_7"), var_list);
	Columns[7].ColName = var_mapping(_T("SQLSpecialColumns_Columns_8"), var_list);
	Columns[8].ColName = var_mapping(_T("SQLSpecialColumns_Columns_9"), var_list);
	Columns[9].ColName = var_mapping(_T("SQLSpecialColumns_Columns_10"), var_list);
	Columns[10].ColName = var_mapping(_T("SQLSpecialColumns_Columns_11"), var_list);
	Columns[11].ColName = var_mapping(_T("SQLSpecialColumns_Columns_12"), var_list);
	Columns[12].ColName = var_mapping(_T("SQLSpecialColumns_Columns_13"), var_list);
	Columns[13].ColName = var_mapping(_T("SQLSpecialColumns_Columns_14"), var_list);
	Columns[14].ColName = var_mapping(_T("SQLSpecialColumns_Columns_15"), var_list);
	Columns[15].ColName = var_mapping(_T("SQLSpecialColumns_Columns_16"), var_list);
	Columns[16].ColName = var_mapping(_T("SQLSpecialColumns_Columns_17"), var_list);
	Columns[17].ColName = var_mapping(_T("SQLSpecialColumns_Columns_18"), var_list);
	Columns[18].ColName = var_mapping(_T("SQLSpecialColumns_Columns_19"), var_list);
	Columns[19].ColName = var_mapping(_T("SQLSpecialColumns_Columns_20"), var_list);
	Columns[20].ColName = var_mapping(_T("SQLSpecialColumns_Columns_21"), var_list);
	Columns[21].ColName = var_mapping(_T("SQLSpecialColumns_Columns_22"), var_list);
	Columns[22].ColName = var_mapping(_T("SQLSpecialColumns_Columns_23"), var_list);
	Columns[23].ColName = var_mapping(_T("SQLSpecialColumns_Columns_24"), var_list);
	Columns[24].ColName = var_mapping(_T("SQLSpecialColumns_Columns_25"), var_list);
	Columns[25].ColName = var_mapping(_T("SQLSpecialColumns_Columns_26"), var_list);
	Columns[26].ColName = var_mapping(_T("SQLSpecialColumns_Columns_27"), var_list);
	Columns[27].ColName = var_mapping(_T("SQLSpecialColumns_Columns_28"), var_list);
	Columns[28].ColName = var_mapping(_T("SQLSpecialColumns_Columns_29"), var_list);

	TableStr[0] = var_mapping(_T("SQLSpecialColumns_TableStr_1"), var_list);
	TableStr[1] = var_mapping(_T("SQLSpecialColumns_TableStr_2"), var_list);
	TableStr[2] = var_mapping(_T("SQLSpecialColumns_TableStr_3"), var_list);
	TableStr[3] = var_mapping(_T("SQLSpecialColumns_TableStr_4"), var_list);

//=========================================================================================

	//if(isUCS2) {
	//	LogMsg(NONE,_T("Setup for UCS2 mode testing: ColPrec has to be doubled\n"));

	//	i = 0;
	//	while(_tcsicmp(Columns[i].ColTypeName,_T("endloop")) != 0) {
	//		if (Columns[i].ColDataType == SQL_WCHAR){
	//			Columns[i].ColDataType = SQL_WCHAR;
	//			Columns[i].ColTypeOutput = charNameUCS2;
	//			//Columns[i].ColPrec *= 2;  --> This is in character, no need to double
	//			Columns[i].ColLen *= 2;
	//		}
	//		else if (Columns[i].ColDataType == SQL_WVARCHAR) {
	//			Columns[i].ColDataType = SQL_WVARCHAR;
	//			Columns[i].ColTypeOutput = varcharNameUCS2;
	//			//Columns[i].ColPrec *= 2;  --> This is in character, no need to double
	//			Columns[i].ColLen *= 2;
	//		}
	//		else if (Columns[i].ColDataType == SQL_WLONGVARCHAR)	{
	//			Columns[i].ColDataType = SQL_WLONGVARCHAR;
	//			Columns[i].ColTypeOutput = varcharNameUCS2;
	//			//Columns[i].ColPrec *= 2;  --> This is in character, no need to double
	//			Columns[i].ColLen *= 2;
	//		}
	//		i++;
	//	}
	//	i = 0;
	//}

//=========================================================================================

	if (MX_MP_SPECIFIC == MX_SPECIFIC)
		LogMsg(LINEBEFORE+SHORTTIMESTAMP,_T("Begin testing API => MX Specific SQLSpecialColumns.\n"));
	else
		LogMsg(LINEBEFORE+SHORTTIMESTAMP,_T("Begin testing API => MP Specific SQLSpecialColumns.\n"));
	
	TEST_INIT;
	TESTCASE_BEGIN("Setup for SQLSpecialColumns tests\n");

	if(!FullConnect(pTestInfo)){
		LogMsg(NONE,_T("Unable to connect\n"));
		TEST_FAILED;
		TEST_RETURN;
		}

	henv = pTestInfo->henv;
 	hdbc = pTestInfo->hdbc;
 	hstmt = (SQLHANDLE)pTestInfo->hstmt;
   	
	returncode = SQLAllocStmt((SQLHANDLE)hdbc, &hstmt);	
  	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLAllocStmt")){
		LogAllErrors(henv,hdbc,hstmt);
		TEST_FAILED;
		TEST_RETURN;
		}
	TESTCASE_END;

	_tcscpy(ColStr,_T(""));
	_tcscpy(KeyStr,_T(""));
	_tcscpy(END_LOOP,_T(""));
	_tcscpy(TName,TableStr[2]);

	if (MX_MP_SPECIFIC == MX_SPECIFIC)
	{
		_tcscpy(TQualifier,pTestInfo->Catalog);
		_tcscpy(TOwner,pTestInfo->Schema);
		_tcscpy(END_LOOP,_T("bit"));
	}
	else
	{
		_tcscpy(TQualifier,_T(""));
		_tcscpy(TOwner,pTestInfo->UserID);
		_tcscpy(END_LOOP,_T("endloop"));
	}

	while (_tcsicmp(Columns[i].ColTypeName,END_LOOP) != 0)
	{
		SQLExecDirect(hstmt,(SQLTCHAR*) (SQLTCHAR *)TableStr[1],SQL_NTS); // cleanup
		if (i > 0)
		{
			_tcscat(ColStr,_T(","));
			_tcscat(KeyStr,_T(","));
		}
		_tcscat(ColStr,Columns[i].ColName);
		_tcscat(ColStr,_T(" "));
		_tcscat(ColStr,Columns[i].ColTypeName);
		_tcscat(ColStr,Columns[i].ColTypeLen);
		_tcscat(ColStr,_T(" not null"));
		_tcscat(KeyStr,Columns[i].ColName);
		_tcscpy(CreateTbl,_T(""));
		_tcscat(CreateTbl,TableStr[0]);
		_tcscat(CreateTbl,_T("("));
		_tcscat(CreateTbl,ColStr);
		_tcscat(CreateTbl,_T(", primary key("));
		_tcscat(CreateTbl,KeyStr);
		_tcscat(CreateTbl,_T("))"));

		_stprintf(Heading,_T("Test Positive Functionality of SQLSpecialColumns for this table:\n"));
		_tcscat(Heading,CreateTbl);
		_tcscat(Heading,_T("\n"));
		TESTCASE_BEGINW(Heading);
		returncode = SQLExecDirect(hstmt,(SQLTCHAR*)CreateTbl,SQL_NTS);
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect")){
			TEST_FAILED;
			LogAllErrors(henv,hdbc,hstmt);
		}
		else{
			if (_tcslen(TQualifier) > 0)
				returncode = SQLSpecialColumns(hstmt,fColType[ct],(SQLTCHAR*)TQualifier,(SWORD)_tcslen(TQualifier),(SQLTCHAR*)TOwner,(SWORD)_tcslen(TOwner),(SQLTCHAR*)TName,(SWORD)_tcslen(TName),Scope[s],Nullable[n]);
			else
				returncode = SQLSpecialColumns(hstmt,fColType[ct],NULL,0,(SQLTCHAR*)TOwner,(SWORD)_tcslen(TOwner),(SQLTCHAR*)TName,(SWORD)_tcslen(TName),Scope[s],Nullable[n]);
			if(!CHECKRC(SQL_SUCCESS,returncode,"SQLSpecialColumns")){
				TEST_FAILED;
				LogAllErrors(henv,hdbc,hstmt);
				}
			else{
				oscope = 0;
				_tcscpy(ocname,_T(""));
				ocdatatype = 0;
				_tcscpy(octype,_T(""));
				ocprec = 0;
				oclen = 0;
				ocsca = 0;
				ocpc = 0;
				SQLBindCol(hstmt,1,SQL_C_SHORT,&oscope,0,&oscopelen);
			    SQLBindCol(hstmt,2,SQL_C_TCHAR,ocname,MAX_COLUMN_NAME,&ocnamelen);
				SQLBindCol(hstmt,3,SQL_C_SHORT,&ocdatatype,0,&ocdatatypelen);
				SQLBindCol(hstmt,4,SQL_C_TCHAR,octype,MAX_COLUMN_NAME,&octypelen);
				SQLBindCol(hstmt,5,SQL_C_LONG,&ocprec,0,&ocpreclen);
				SQLBindCol(hstmt,6,SQL_C_LONG,&oclen,0,&oclenlen);
				SQLBindCol(hstmt,7,SQL_C_SHORT,&ocsca,0,&ocscalen);
				SQLBindCol(hstmt,8,SQL_C_SHORT,&ocpc,0,&ocpclen);

				k = 0;
				while (returncode == SQL_SUCCESS){
					returncode = SQLFetch(hstmt);
					if((returncode!=SQL_NO_DATA_FOUND)
							&&(!CHECKRC(SQL_SUCCESS,returncode,"SQLFetch"))){
						TEST_FAILED;
						LogAllErrors(henv,hdbc,hstmt);
						}
					else{
						if (returncode == SQL_SUCCESS){
							if (MX_MP_SPECIFIC == MX_SPECIFIC)
							{
								psc = SQL_PC_NOT_PSEUDO;
							}
							else
							{
								psc = 1;
							}
							LogMsg(NONE,_T("Comparing results for SQLSpecialColumns\n"));
                            t = 0;
                            found = FALSE;
                            while(_tcscmp(Columns[t].ColTypeName,_T("endloop"))!=0) {
                                if(cwcscmp(ocname, Columns[t].ColName,TRUE) == 0) {
							        if ((oscope == Scope[s]) 
								        && (ocdatatype == Columns[t].ColDataType) 
								        && (_tcsicmp(octype,Columns[t].ColTypeOutput) == 0) 
								        && (ocprec == Columns[t].ColPrec) 
								        && (oclen == Columns[t].ColLen) 
								        && (ocsca == Columns[t].ColSca) 
								        && (ocpc == (SWORD)psc)){
								        /*
								        LogMsg(NONE,_T("Scope expect: %d and actual: %d are matched\n"),Scope[s],oscope);
								        LogMsg(NONE,_T("colname expect: %s and actual: %s are matched\n"),Columns[t].ColName,ocname);
								        LogMsg(NONE,_T("ColDataType expect: %d and actual: %d are matched\n"),Columns[t].ColDataType,ocdatatype);
								        LogMsg(NONE,_T("ColTypeOutput expect: %s and actual: %s are matched\n"),Columns[t].ColTypeOutput,octype);
								        LogMsg(NONE,_T("ColPrec expect: %d and actual: %d are matched\n"),Columns[t].ColPrec,ocprec);
								        LogMsg(NONE,_T("ColLen expect: %d and actual: %d are matched\n"),Columns[t].ColLen,oclen);
								        LogMsg(NONE,_T("ColScale expect: %d and actual: %d are matched\n"),Columns[t].ColSca,ocsca);
								        LogMsg(NONE,_T("ColPseudoCol expect: %d and actual: %d are matched\n\n"),(SWORD)psc,ocpc);
								        */
							        } else {
							            TEST_FAILED;	
							            if (oscope != Scope[s]) 
								            LogMsg(ERRMSG,_T("Scope expect: %d and actual: %d are not matched\n"),Scope[t],oscope);
							            if (ocdatatype != Columns[t].ColDataType) 
								            LogMsg(ERRMSG,_T("ColDataType expect: %d and actual: %d are not matched\n"),Columns[t].ColDataType,ocdatatype);
							            if (_tcsicmp(octype,Columns[t].ColTypeOutput) != 0) 
								            LogMsg(ERRMSG,_T("ColTypeName expect: %s and actual: %s are not matched\n"),Columns[t].ColTypeOutput,octype);
							            if (ocprec != Columns[t].ColPrec) 
								            LogMsg(ERRMSG,_T("ColPrec expect: %d and actual: %d are not matched\n"),Columns[t].ColPrec,ocprec);
							            if (oclen != Columns[t].ColLen) 
								            LogMsg(ERRMSG,_T("ColLen expect: %d and actual: %d are not matched\n"),Columns[t].ColLen,oclen);
							            if (ocsca != Columns[t].ColSca) 
								            LogMsg(ERRMSG,_T("ColScale expect: %d and actual: %d are not matched\n"),Columns[t].ColSca,ocsca);
							            if (ocpc != (SWORD)psc)
								            LogMsg(ERRMSG,_T("ColPseudoCol expect: %d and actual: %d are not matched\n\n"),(SWORD)psc,ocpc);
						            }
                                    found = TRUE;
                                    break;
                                } else {
                                    t++;
                                }
                            }
                            if(!found) {
                                TEST_FAILED;
                                LogMsg(ERRMSG,_T("Unexpected returned data: %s\n"), ocname);
                            }
						}
                    }
					if (returncode == SQL_SUCCESS)
						k++;
					} // end while
					if(k == 0)
					{
						TEST_FAILED;
						LogMsg(ERRMSG,_T("No Data Found => Atleast one row should be fetched\n"));
					}
				}
			SQLFreeStmt(hstmt,SQL_UNBIND);
			SQLFreeStmt(hstmt,SQL_CLOSE);
			}
			SQLExecDirect(hstmt,(SQLTCHAR*) (SQLTCHAR *)TableStr[1],SQL_NTS);
		i++;
		TESTCASE_END;
		}  // end while

	//========================================================================================================

	_stprintf(Heading,_T("SQLSpecialColumns: Negative test with NULL handle\n"));
	TESTCASE_BEGINW(Heading);

	hstmt = (SQLHANDLE)NULL;
	_tcscpy(TQualifier,_T(""));
	_tcscpy(TOwner,pTestInfo->UserID);
	_tcscpy(TName,TableStr[3]);
	i = 0;

	returncode = SQLSpecialColumns(hstmt,fColType[i],(SQLTCHAR*)TQualifier,(SWORD)_tcslen(TQualifier),(SQLTCHAR*)TOwner,(SWORD)_tcslen(TOwner),(SQLTCHAR*)TName,(SWORD)_tcslen(TName),Scope[i],Nullable[i]);
	if(!CHECKRC(SQL_INVALID_HANDLE,returncode,"SQLSpecialColumns"))
	{
		TEST_FAILED;
		LogAllErrors(henv,hdbc,hstmt);
	}
	TESTCASE_END;

	//========================================================================================================

	FullDisconnect(pTestInfo);
	LogMsg(SHORTTIMESTAMP+LINEAFTER,_T("End testing API => SQLSpecialColumns.\n"));
	free_list(var_list);
	TEST_RETURN;
}
Beispiel #18
0
/*
---------------------------------------------------------
   TestSQLDescribeCol for MP Specific
---------------------------------------------------------
*/
PassFail TestMXSQLDescribeCol(TestInfo *pTestInfo)
{                  
	TEST_DECLARE;
 	TCHAR			Heading[MAX_STRING_SIZE];
	RETCODE			returncode;
	SQLHANDLE 		henv, hdbc, hstmt;
	UWORD			icol;
	SWORD			numcol, st, cs, cnull, cl, colsize = 2;
	SQLULEN         cp; 
	TCHAR			cn[COLNAME_LEN];
	TCHAR			*colname[COL_LEN];
	TCHAR			*ExecDirStr[12];
	TCHAR			*colVal[2];

#ifndef _WM 
	#ifdef UNICODE
	SWORD			SQLType[] = {SQL_WCHAR,SQL_WVARCHAR,SQL_DECIMAL,SQL_NUMERIC,SQL_SMALLINT,SQL_INTEGER,
									SQL_REAL,SQL_DOUBLE,SQL_DOUBLE,SQL_DATE,SQL_TIME,SQL_TIMESTAMP,SQL_WVARCHAR,SQL_BIGINT,
									SQL_NUMERIC,SQL_NUMERIC,SQL_NUMERIC,SQL_NUMERIC,SQL_NUMERIC,SQL_NUMERIC,SQL_NUMERIC,
									SQL_WCHAR,SQL_WVARCHAR,SQL_WVARCHAR,SQL_CHAR,SQL_VARCHAR,SQL_WVARCHAR};
    SQLULEN			ColPrec[] = {254,254,18,18,5,10,7,15,15,10,8,26,2000,19,19,19,128,128,10,18,30,254,254,2000,1016,1016,2000};

	SWORD			ColScale[]= {0,0,6,6,0,0,0,0,0,0,0,6,0,0,0,6,0,128,5,5,10,0,0,0,0,0,0};
	#else
	SWORD			SQLType[] = {SQL_CHAR,SQL_VARCHAR,SQL_DECIMAL,SQL_NUMERIC,SQL_SMALLINT,SQL_INTEGER,
									SQL_REAL,SQL_DOUBLE,SQL_DOUBLE,SQL_DATE,SQL_TIME,SQL_TIMESTAMP,SQL_VARCHAR,SQL_BIGINT,
									SQL_WCHAR,SQL_WVARCHAR,SQL_WVARCHAR,
									SQL_NUMERIC,SQL_NUMERIC,SQL_NUMERIC,SQL_NUMERIC,SQL_NUMERIC,SQL_NUMERIC,SQL_NUMERIC	};
    SQLULEN			ColPrec[] = {254,254,18,18,5,10,7,15,15,10,8,26,2000,19,254,127,2000,19,19,128,128,10,18,30};

	SWORD			ColScale[]= {0,  0,  6, 6, 0,0, 0,0, 0, 0, 0,6, 0,   0, 0,  0,  0,   0, 6, 0,  128,5, 5, 10};
	#endif
#else
    SWORD			SQLType[] = {SQL_CHAR,SQL_VARCHAR,SQL_DECIMAL,SQL_NUMERIC,SQL_SMALLINT,SQL_INTEGER,
									SQL_REAL,SQL_DOUBLE,SQL_DOUBLE,SQL_CHAR,SQL_TIME,SQL_TIMESTAMP,SQL_LONGVARCHAR,SQL_BIGINT,
									SQL_WCHAR,SQL_WVARCHAR,SQL_WLONGVARCHAR,
									SQL_NUMERIC,SQL_NUMERIC,SQL_NUMERIC,SQL_NUMERIC,SQL_NUMERIC,SQL_NUMERIC,SQL_NUMERIC};
    SQLULEN			ColPrec[] = {254,127,18,18,5,10,7,15,15,8,8,26,2000,19,254,127,2000,19,19,128,128,10,18,30};

	SWORD			ColScale[]= {0,0,6,6,0,0,0,0,0,0,0,6,0,0,0,6,0,128,5,5,10,0,0,0,0,0,0};
#endif
	

	TCHAR			TempType1[50],TempType2[50];
	SWORD			ColNullable[] = {SQL_NULLABLE,SQL_NO_NULLS,SQL_NULLABLE};

	TCHAR			*TestCase[] = {
					_T("before preparing stmt "),
					_T("before preparing & executing stmt "),
					_T("before preparing, executing & fetching stmt "),
					_T("before execdirect stmt "),
					_T("before execdirect & fetching stmt "),
					_T("before preparing param stmt "),
					_T("before preparing & binding stmt "),
					_T("before preparing, binding & executing stmt "),
					_T("before preparing, binding, executing & fetching stmt ")
					};

	int				lend = 9, iend = 3;
	SQLUSMALLINT	i = 0, l = 0;
	SQLLEN			cbIn = SQL_NTS;

//===========================================================================================================
	var_list_t *var_list;
	var_list = load_api_vars(_T("SQLDescribeColumns"), charset_file);
	if (var_list == NULL) return FAILED;

	//print_list(var_list);
	colname[0] = var_mapping(_T("SQLDescribeColumns_colname_1"), var_list);
	colname[1] = var_mapping(_T("SQLDescribeColumns_colname_2"), var_list);
	colname[2] = var_mapping(_T("SQLDescribeColumns_colname_3"), var_list);
	colname[3] = var_mapping(_T("SQLDescribeColumns_colname_4"), var_list);
	colname[4] = var_mapping(_T("SQLDescribeColumns_colname_5"), var_list);
	colname[5] = var_mapping(_T("SQLDescribeColumns_colname_6"), var_list);
	colname[6] = var_mapping(_T("SQLDescribeColumns_colname_7"), var_list);
	colname[7] = var_mapping(_T("SQLDescribeColumns_colname_8"), var_list);
	colname[8] = var_mapping(_T("SQLDescribeColumns_colname_9"), var_list);
	colname[9] = var_mapping(_T("SQLDescribeColumns_colname_10"), var_list);
	colname[10] = var_mapping(_T("SQLDescribeColumns_colname_11"), var_list);
	colname[11] = var_mapping(_T("SQLDescribeColumns_colname_12"), var_list);
	colname[12] = var_mapping(_T("SQLDescribeColumns_colname_13"), var_list);
	colname[13] = var_mapping(_T("SQLDescribeColumns_colname_14"), var_list);
	colname[14] = var_mapping(_T("SQLDescribeColumns_colname_15"), var_list);
	colname[15] = var_mapping(_T("SQLDescribeColumns_colname_16"), var_list);
	colname[16] = var_mapping(_T("SQLDescribeColumns_colname_17"), var_list);
	colname[17] = var_mapping(_T("SQLDescribeColumns_colname_18"), var_list);
	colname[18] = var_mapping(_T("SQLDescribeColumns_colname_19"), var_list);
	colname[19] = var_mapping(_T("SQLDescribeColumns_colname_20"), var_list);
	colname[20] = var_mapping(_T("SQLDescribeColumns_colname_21"), var_list);
	colname[21] = var_mapping(_T("SQLDescribeColumns_colname_22"), var_list);
	colname[22] = var_mapping(_T("SQLDescribeColumns_colname_23"), var_list);
	colname[23] = var_mapping(_T("SQLDescribeColumns_colname_24"), var_list);

#ifdef UNICODE 
	colname[24] = var_mapping(_T("SQLDescribeColumns_colname_25"), var_list);
	colname[25] = var_mapping(_T("SQLDescribeColumns_colname_26"), var_list);
	colname[26] = var_mapping(_T("SQLDescribeColumns_colname_27"), var_list);
#endif

	ExecDirStr[0] = var_mapping(_T("SQLDescribeColumns_ExecDirStr_1"), var_list);
	ExecDirStr[1] = var_mapping(_T("SQLDescribeColumns_ExecDirStr_2"), var_list);
	ExecDirStr[2] = var_mapping(_T("SQLDescribeColumns_ExecDirStr_3"), var_list);
	ExecDirStr[3] = var_mapping(_T("SQLDescribeColumns_ExecDirStr_4"), var_list);
	ExecDirStr[4] = var_mapping(_T("SQLDescribeColumns_ExecDirStr_5"), var_list);
	ExecDirStr[5] = var_mapping(_T("SQLDescribeColumns_ExecDirStr_6"), var_list);
	ExecDirStr[6] = var_mapping(_T("SQLDescribeColumns_ExecDirStr_7"), var_list);
	ExecDirStr[7] = var_mapping(_T("SQLDescribeColumns_ExecDirStr_8"), var_list);
	ExecDirStr[8] = var_mapping(_T("SQLDescribeColumns_ExecDirStr_9"), var_list);
	ExecDirStr[9] = var_mapping(_T("SQLDescribeColumns_ExecDirStr_10"), var_list);
	ExecDirStr[10] = var_mapping(_T("SQLDescribeColumns_ExecDirStr_11"), var_list);
	ExecDirStr[11] = var_mapping(_T("SQLDescribeColumns_ExecDirStr_12"), var_list);

	colVal[0] = var_mapping(_T("SQLDescribeColumns_colVal_1"), var_list);
	colVal[1] = var_mapping(_T("SQLDescribeColumns_colVal_2"), var_list);
//===========================================================================================================

	//if(isUCS2) {
	//	LogMsg(NONE,_T("Setup for UCS2 mode testing: ColPrec has to be doubled\n"));

	//	l = sizeof(SQLType)/sizeof(SQLType[0]);
	//	while(i < l) {
	//		if(SQLType[i] == SQL_WCHAR) {
	//			SQLType[i] = SQL_WCHAR;
	//			//ColPrec[i] *= 2;  --> This is in character, so no need to double
	//		}
	//		else if (SQLType[i] == SQL_WVARCHAR) {
	//			SQLType[i] = SQL_WVARCHAR;
	//			//ColPrec[i] *= 2;  --> This is in character, so no need to double
	//		}
	//		else if (SQLType[i] == SQL_WLONGVARCHAR)	{
	//			SQLType[i] = SQL_WLONGVARCHAR;
	//			//ColPrec[i] *= 2;  --> This is in character, so no need to double
	//		}
	//		else {
	//		}
	//		i++;
	//	}
	//	i = 0;
	//	l = 0;
	//}

//===========================================================================================================

	LogMsg(LINEBEFORE+SHORTTIMESTAMP,_T("Begin testing API => MX Specific SQLDescribeColumns.\n"));
	TEST_INIT;
	   
	TESTCASE_BEGIN("Setup for SQLDescribCol tests\n");

	if(!FullConnect(pTestInfo))
	{
		LogMsg(NONE,_T("Unable to connect\n"));
		TEST_FAILED;
		TEST_RETURN;
	}
	henv = pTestInfo->henv;
 	hdbc = pTestInfo->hdbc;
 	hstmt = (SQLHANDLE)pTestInfo->hstmt;
	returncode = SQLAllocStmt((SQLHANDLE)hdbc, &hstmt);	
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLAllocStmt"))
	{
		LogAllErrors(henv,hdbc,hstmt);
		TEST_FAILED;
		TEST_RETURN;
	}
	TESTCASE_END;  // end of setup
	for (l = 0; l < lend; l++)
	{
		for (i = 0; i < iend; i++)
		{
			//==================================================================================
			_stprintf(Heading,_T("SQLDescribeCol: Test #%d.%d\n"),l,i);
			TESTCASE_BEGINW(Heading);
			if ((i != (iend-1)) && (l < 5))
			{
				SQLExecDirect(hstmt,(SQLTCHAR*)ExecDirStr[i],SQL_NTS); /* cleanup */
				returncode = SQLExecDirect(hstmt,(SQLTCHAR*)ExecDirStr[i+iend],SQL_NTS); /* create table */
				LogMsg(NONE,_T("%s\n"), ExecDirStr[i+iend]);
				if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect"))
				{
					LogAllErrors(henv,hdbc,hstmt);
					TEST_FAILED;
				}
				else
				{
					returncode = SQLExecDirect(hstmt,(SQLTCHAR*)ExecDirStr[i+iend+iend],SQL_NTS); /* insert into table */
					if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect"))
					{
						LogAllErrors(henv,hdbc,hstmt);
						TEST_FAILED;
					}
					else
					{
						LogMsg(NONE,_T("SQLDescribeCol: %s\n"),TestCase[l]);
						LogMsg(NONE,_T("     %s\n"),ExecDirStr[i+iend+iend+iend]);
						switch( l )
						{
							case 0:
								returncode = SQLPrepare(hstmt,(SQLTCHAR*)ExecDirStr[i+iend+iend+iend], SQL_NTS);
								if(!CHECKRC(SQL_SUCCESS,returncode,"SQLPrepare"))
								{
									LogAllErrors(henv,hdbc,hstmt);
									TEST_FAILED;
								}
								break;
							case 1 :
								returncode = SQLPrepare(hstmt,(SQLTCHAR*)ExecDirStr[i+iend+iend+iend], SQL_NTS);
								if(!CHECKRC(SQL_SUCCESS,returncode,"SQLPrepare"))
								{
									LogAllErrors(henv,hdbc,hstmt);
									TEST_FAILED;
								}
								else
								{
									returncode = SQLExecute(hstmt);
									if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecute"))
									{
										LogAllErrors(henv,hdbc,hstmt);
										TEST_FAILED;
									}
								}
								break;
							case 2 :
								returncode = SQLPrepare(hstmt,(SQLTCHAR*)ExecDirStr[i+iend+iend+iend], SQL_NTS);
								if(!CHECKRC(SQL_SUCCESS,returncode,"SQLPrepare"))
								{
									LogAllErrors(henv,hdbc,hstmt);
									TEST_FAILED;
								}
								else
								{
									returncode = SQLExecute(hstmt);
									if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecute"))
									{
										LogAllErrors(henv,hdbc,hstmt);
										TEST_FAILED;
									}
									else
									{
										returncode = SQLFetch(hstmt);
										if(!CHECKRC(SQL_SUCCESS,returncode,"SQLFetch"))
										{
											LogAllErrors(henv,hdbc,hstmt);
											TEST_FAILED;
										}
									}
								}
								break;
							case 3 :
								returncode = SQLExecDirect(hstmt,(SQLTCHAR*)ExecDirStr[i+iend+iend+iend], SQL_NTS);
								if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect"))
								{
									LogAllErrors(henv,hdbc,hstmt);
									TEST_FAILED;
								}
								break;
							case 4 :
								returncode = SQLExecDirect(hstmt,(SQLTCHAR*)ExecDirStr[i+iend+iend+iend], SQL_NTS);
								if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect"))
								{
									LogAllErrors(henv,hdbc,hstmt);
									TEST_FAILED;
								}
								else
								{
									returncode = SQLFetch(hstmt);
									if(!CHECKRC(SQL_SUCCESS,returncode,"SQLFetch"))
									{
										LogAllErrors(henv,hdbc,hstmt);
										TEST_FAILED;
									}
								}
								break;
						}
						if (returncode == SQL_SUCCESS)
						{
							returncode=SQLNumResultCols(hstmt, &numcol);
							if(!CHECKRC(SQL_SUCCESS,returncode,"SQLNumResultCols"))
							{
								LogAllErrors(henv,hdbc,hstmt);
								TEST_FAILED;
							}
							for (icol = 1; icol <= numcol; icol++)
							{
								LogMsg(LINEBEFORE,_T("SQLDescribeCol: checking Column #%d\n"),icol);
								returncode = SQLDescribeCol(hstmt,icol,(SQLTCHAR*)cn,COLNAME_LEN,&cl,&st,&cp,&cs,&cnull);
								if(!CHECKRC(SQL_SUCCESS,returncode,"SQLDescribeCol"))
								{
									TEST_FAILED;
									LogAllErrors(henv,hdbc,hstmt);
								}
								colsize=_tcslen(colname[icol-1]);
								if(isCharSet == TRUE)
									colsize -= 2;
								if ((cwcscmp(cn,colname[icol-1],FALSE) == 0) 
									 && (cl == colsize) 
									 && (st == SQLType[icol-1]) 
									 && (cp == ColPrec[icol-1]) 
									 && (cs == ColScale[icol-1]) 
									 && (cnull == ColNullable[i]))
								{
									LogMsg(NONE,_T("colname expect: %s and actual: %s are matched\n"),colname[icol-1],cn);
									LogMsg(NONE,_T("ColNameLen expect: %d and actual: %d are matched\n"),colsize,cl);
									LogMsg(NONE,_T("SQLType expect: %s and actual: %s are matched\n"),
									SQLTypeToChar(SQLType[icol-1],TempType1),SQLTypeToChar(st,TempType2));
									LogMsg(NONE,_T("ColPrec expect: %d and actual: %d are matched\n"),ColPrec[icol-1],cp);
									LogMsg(NONE,_T("ColScale expect: %d and actual: %d are matched\n"),ColScale[icol-1],cs);
									LogMsg(NONE,_T("ColNullable expect: %s and actual: %s are matched\n\n"),
									SQLNullToChar(ColNullable[i],TempType1),SQLNullToChar(cnull,TempType2));
								}
								else
								{
									TEST_FAILED;	
									if (cwcscmp(cn,colname[icol-1],FALSE) != 0)
										LogMsg(ERRMSG,_T("colname expect: %s and actual: %s are not matched line %d\n"),colname[icol-1],cn,__LINE__);
									if (cl != colsize)
										LogMsg(ERRMSG,_T("ColNameLen expect: %d and actual: %d are not matched line %d\n"),colsize,cl,__LINE__);
									if (st != SQLType[icol-1])
										LogMsg(ERRMSG,_T("SQLType expect: %s and actual: %s are not matched line %d\n"),
											SQLTypeToChar(SQLType[icol-1],TempType1),SQLTypeToChar(st,TempType2),__LINE__);
									if (cp != ColPrec[icol-1])
										LogMsg(ERRMSG,_T("ColPrec expect: %d and actual: %d are not matched line %d\n"),ColPrec[icol-1],cp,__LINE__);
									if (cs != ColScale[icol-1])
										LogMsg(ERRMSG,_T("ColScale expect: %d and actual: %d are not matched line %d\n"),ColScale[icol-1],cs,__LINE__);
									if (cnull != ColNullable[i])
										LogMsg(ERRMSG,_T("ColNullable expect: %s and actual: %s are not matched line %d\n\n"),
											SQLNullToChar(ColNullable[i],TempType1),SQLNullToChar(cnull,TempType2),__LINE__);
								}
							} /* end icol loop */
						}
						else
						{
							TEST_FAILED;
							LogAllErrors(henv,hdbc,hstmt);
						}
						SQLFreeStmt(hstmt,SQL_CLOSE);
						SQLExecDirect(hstmt,(SQLTCHAR*) ExecDirStr[i],SQL_NTS); /* cleanup */
					}
				}
			}
			else if ((i == (iend-1)) && (l >= 5))
			{
				SQLExecDirect(hstmt,(SQLTCHAR*)ExecDirStr[i],SQL_NTS); /* cleanup */ 
				returncode = SQLExecDirect(hstmt,(SQLTCHAR*)ExecDirStr[i+iend],SQL_NTS); /* create table */
				LogMsg(NONE,_T("%s\n"), ExecDirStr[i+iend]);
				if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect"))
				{
					LogAllErrors(henv,hdbc,hstmt);
					TEST_FAILED;
				}
				else
				{
					returncode = SQLExecDirect(hstmt,(SQLTCHAR*)ExecDirStr[i+iend+iend],SQL_NTS); /* insert into table */
					if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect"))
					{
						LogAllErrors(henv,hdbc,hstmt);
						TEST_FAILED;
					}
					else
					{
						LogMsg(NONE,_T("SQLDescribeCol: %s\n"),TestCase[l]);
						LogMsg(NONE,_T("     %s\n"),ExecDirStr[i+iend+iend+iend]);
						switch( l ) 
						{
							case 5 :
								returncode = SQLPrepare(hstmt,(SQLTCHAR*)ExecDirStr[i+iend+iend+iend], SQL_NTS);
								if(!CHECKRC(SQL_SUCCESS,returncode,"SQLPrepare"))
								{
									LogAllErrors(henv,hdbc,hstmt);
									TEST_FAILED;
								}
								break;
							case 6 :
								returncode = SQLPrepare(hstmt,(SQLTCHAR*)ExecDirStr[i+iend+iend+iend], SQL_NTS);
								if(!CHECKRC(SQL_SUCCESS,returncode,"SQLPrepare"))
								{
									LogAllErrors(henv,hdbc,hstmt);
									TEST_FAILED;
								}
								else
								{
									returncode = SQLBindParameter(hstmt,1,SQL_PARAM_INPUT,SQL_C_TCHAR,SQL_WCHAR,2000,0,(SQLPOINTER)colVal[0],300,&cbIn);
									if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindParameter"))
									{
										LogAllErrors(henv,hdbc,hstmt);
										TEST_FAILED;
									}
									returncode = SQLBindParameter(hstmt,2,SQL_PARAM_INPUT,SQL_C_TCHAR,SQL_WCHAR,2000,0,(SQLPOINTER)colVal[1],300,&cbIn);
									if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindParameter"))
									{
										LogAllErrors(henv,hdbc,hstmt);
										TEST_FAILED;
									}
								}
								break;
							case 7 :
								returncode = SQLPrepare(hstmt,(SQLTCHAR*)ExecDirStr[i+iend+iend+iend], SQL_NTS);
								if(!CHECKRC(SQL_SUCCESS,returncode,"SQLPrepare"))
								{
									LogAllErrors(henv,hdbc,hstmt);
									TEST_FAILED;
								}
								else
								{
									returncode = SQLBindParameter(hstmt,1,SQL_PARAM_INPUT,SQL_C_TCHAR,SQL_WCHAR,2000,0,(SQLPOINTER)colVal[0],300,&cbIn);
									if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindParameter"))
									{
										LogAllErrors(henv,hdbc,hstmt);
										TEST_FAILED;
									}
									returncode = SQLBindParameter(hstmt,2,SQL_PARAM_INPUT,SQL_C_TCHAR,SQL_WCHAR,2000,0,(SQLPOINTER)colVal[1],300,&cbIn);
									if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindParameter"))
									{
										LogAllErrors(henv,hdbc,hstmt);
										TEST_FAILED;
									}
									returncode = SQLExecute(hstmt);
									if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecute"))
									{
										LogAllErrors(henv,hdbc,hstmt);
										TEST_FAILED;
									}
								}
								break;
							  case 8 :
								returncode = SQLPrepare(hstmt,(SQLTCHAR*)ExecDirStr[i+iend+iend+iend], SQL_NTS);
								if(!CHECKRC(SQL_SUCCESS,returncode,"SQLPrepare"))
								{
									LogAllErrors(henv,hdbc,hstmt);
									TEST_FAILED;
								}
								else
								{
									returncode = SQLBindParameter(hstmt,1,SQL_PARAM_INPUT,SQL_C_TCHAR,SQL_WCHAR,2000,0,(SQLPOINTER)colVal[0],300,&cbIn);
									if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindParameter"))
									{
										LogAllErrors(henv,hdbc,hstmt);
										TEST_FAILED;
									}
									returncode = SQLBindParameter(hstmt,2,SQL_PARAM_INPUT,SQL_C_TCHAR,SQL_WCHAR,2000,0,(SQLPOINTER)colVal[1],300,&cbIn);
									if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindParameter"))
									{
										LogAllErrors(henv,hdbc,hstmt);
										TEST_FAILED;
									}
									returncode = SQLExecute(hstmt);
									if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecute"))
									{
										LogAllErrors(henv,hdbc,hstmt);
										TEST_FAILED;
									}
									else
									{
										returncode = SQLFetch(hstmt);
										if(!CHECKRC(SQL_SUCCESS,returncode,"SQLFetch"))
										{
											LogAllErrors(henv,hdbc,hstmt);
											TEST_FAILED;
										}
									}
								}
								break;
						}
						if (returncode == SQL_SUCCESS)
						{
							SQLNumResultCols(hstmt, &numcol);
							if(!CHECKRC(SQL_SUCCESS,returncode,"SQLNumResultCols"))
							{
								LogAllErrors(henv,hdbc,hstmt);
								TEST_FAILED;
							}
							for (icol = 1; icol <= numcol; icol++)
							{
								LogMsg(LINEBEFORE,_T("SQLDescribeCol: checking Column #%d\n"),icol);
								returncode = SQLDescribeCol(hstmt,icol,(SQLTCHAR*)cn,COLNAME_LEN,&cl,&st,&cp,&cs,&cnull);
								if(!CHECKRC(SQL_SUCCESS,returncode,"SQLDescribeCol"))
								{
									TEST_FAILED;
									LogAllErrors(henv,hdbc,hstmt);
								}
								colsize=_tcslen(colname[icol-1]);
								if(isCharSet == TRUE)
									colsize -= 2;
								if ((cwcscmp(cn,colname[icol-1],FALSE) == 0) 
									 && (cl == colsize) 
									 && (st == SQLType[icol-1]) 
									 && (cp == ColPrec[icol-1]) 
									 && (cs == ColScale[icol-1]) 
									 && (cnull == ColNullable[i]))
								{
									LogMsg(NONE,_T("colname expect: %s and actual: %s are matched\n"),colname[icol-1],cn);
									LogMsg(NONE,_T("ColNameLen expect: %d and actual: %d are matched\n"),colsize,cl);
									LogMsg(NONE,_T("SQLType expect: %s and actual: %s are matched\n"),
										SQLTypeToChar(SQLType[icol-1],TempType1),SQLTypeToChar(st,TempType2));
									LogMsg(NONE,_T("ColPrec expect: %d and actual: %d are matched\n"),ColPrec[icol-1],cp);
									LogMsg(NONE,_T("ColScale expect: %d and actual: %d are matched\n"),ColScale[icol-1],cs);
									LogMsg(NONE,_T("ColNullable expect: %s and actual: %s are matched\n\n"),
										SQLNullToChar(ColNullable[i],TempType1),SQLNullToChar(cnull,TempType2));
								}
								else
								{
									TEST_FAILED;	
									if (cwcscmp(cn,colname[icol-1],FALSE) != 0)
										LogMsg(ERRMSG,_T("colname expect: %s and actual: %s are not matched at line %d\n"),colname[icol-1],cn,__LINE__);
									if (cl != colsize)
										LogMsg(ERRMSG,_T("ColNameLen expect: %d and actual: %d are not matched at line %d\n"),colsize,cl,__LINE__);
									if (st != SQLType[icol-1])
										LogMsg(ERRMSG,_T("SQLType expect: %s and actual: %s are not matched at line %d\n"),
											SQLTypeToChar(SQLType[icol-1],TempType1),SQLTypeToChar(st,TempType2),__LINE__);
									if (cp != ColPrec[icol-1])
										LogMsg(ERRMSG,_T("ColPrec expect: %d and actual: %d are not matched at line %d\n"),ColPrec[icol-1],cp,__LINE__);
									if (cs != ColScale[icol-1])
										LogMsg(ERRMSG,_T("ColScale expect: %d and actual: %d are not matched at line %d\n"),ColScale[icol-1],cs,__LINE__);
									if (cnull != ColNullable[i])
										LogMsg(ERRMSG,_T("ColNullable expect: %s and actual: %s are not matched at line %d\n\n"),
											SQLNullToChar(ColNullable[i],TempType1),SQLNullToChar(cnull,TempType2),__LINE__);
								}
							}
						}
					}
					SQLFreeStmt(hstmt,SQL_CLOSE);
					SQLExecDirect(hstmt,(SQLTCHAR*) ExecDirStr[i],SQL_NTS); 
				}
			}
			TESTCASE_END;
		} /* iend loop */
	} /* lend loop */
	FullDisconnect(pTestInfo);
	LogMsg(SHORTTIMESTAMP+LINEAFTER,_T("End testing API => MX Specific SQLDescribeColumns.\n"));
	free_list(var_list);
	TEST_RETURN;
}
Beispiel #19
0
PassFail TestQueryID (TestInfo *pTestInfo)
{
	TEST_DECLARE;
 	char			Heading[MAX_STRING_SIZE];
 	RETCODE			returncode;
 	SQLHANDLE 		henv, henv2;
 	SQLHANDLE 		hdbc, hdbc2 = (SQLHANDLE)NULL;
 	SQLHANDLE		hstmt, hstmt2;

	int				loop = 0;
	//char			preparedStmt[1024];
	char			infoStatsStmt[ 1024 ];
	SQLCHAR			cursorName[ 1024 ];
	CHAR			jobid[SQL_MAX_SESSIONNAME_LEN];
	CHAR			queryID[256];
	SQLINTEGER		jobidlen;
	SQLLEN			queryIDPtr;
	CHAR			tempStr[256];
                              
	char *droptab   =  "DROP TABLE JOBID cascade";
  	char *createtab =  "CREATE TABLE JOBID (C int) NO PARTITION";
  	char *inserttab =  "INSERT INTO JOBID VALUES (10)";
  	char *selecttab =  "SELECT * FROM JOBID";

	struct
	{
		RETCODE		returncode;
		CHAR		*jobID;
		CHAR		*jobIDExpected;
	} jobIDMatrix[] = {
        { SQL_SUCCESS, "1"                                                  , "1"},
        { SQL_SUCCESS, "11"                                                  , "11"},
		{ SQL_SUCCESS, ""                                                   , "" },
		{ SQL_SUCCESS, "H"                                                  , "H" },
		{ SQL_SUCCESS, "hh"                                                  , "hh" },
		{ SQL_SUCCESS, "0"                                                  , "0" },
		{ SQL_SUCCESS, "_"                                                  , "_" },
		{ SQL_SUCCESS, "________________________"                           , "________________________" },
		{ SQL_SUCCESS, "odbcqa"                                             , "odbcqa" },
		{ SQL_SUCCESS, "odbcqa00"                                           , "odbcqa00" },
		{ SQL_SUCCESS, "00odbcqa"                                           , "00odbcqa" },
		{ SQL_SUCCESS, "0123_HELLOKITTY"                                    , "0123_HELLOKITTY" },
		{ SQL_SUCCESS, "_Hello_Kitty_123"                                   , "_Hello_Kitty_123" },
		{ SQL_SUCCESS, "Hello_Kitty_Went_To_The_"							, "Hello_Kitty_Went_To_The_" },
		{ SQL_SUCCESS, "Hello_Kitty_Went_To_The_"							, "Hello_Kitty_Went_To_The_" },
		{ SQL_SUCCESS, "1234567890_1234567890"								, "1234567890_1234567890" },
		{ SQL_SUCCESS, "123456789012345678901234"                           , "123456789012345678901234" },
		{ SQL_SUCCESS, "123456789012345678901234"                           , "123456789012345678901234" },
		{ SQL_SUCCESS, "1234567890123456789012345"                          , "123456789012345678901234" },
		{ SQL_SUCCESS, "Hello_Kitty_Went_To_The_Store_To_Buy"				, "Hello_Kitty_Went_To_The_" },
		{ SQL_SUCCESS_WITH_INFO, " "										, "" },
		{ SQL_SUCCESS_WITH_INFO, " HelloKitty"                              , "" },
		{ SQL_SUCCESS_WITH_INFO, "Hello Kitty"                              , "" },
		{ SQL_SUCCESS_WITH_INFO, "HelloKitty "                              , "" },
		{ SQL_SUCCESS_WITH_INFO, "1 2"						                , "" },
		{ SQL_SUCCESS_WITH_INFO, "12345.67890.123456789012"                 , "" },
		{ SQL_SUCCESS_WITH_INFO, "Hello$Kitty"                              , "" },
		{ SQL_SUCCESS_WITH_INFO, "\"HelloKitty\""							, "" },
		{ SQL_SUCCESS_WITH_INFO, "'HelloKitty'"								, "" },
		{ SQL_SUCCESS_WITH_INFO, "\" \""                                    , "" },
		{ SQL_SUCCESS_WITH_INFO, "\"\""                                     , "" },
		{ SQL_SUCCESS_WITH_INFO, "\"#@*()-_=+[]{}|:;'<>,.?\""               , "" },
		{ -101				   , ""                                         , "" }
	};

	//struct
	//{
	//	RETCODE		rtc;
	//	CHAR		*queryID;
	//	CHAR		*queryIDExpected;
	//} queryIDMatrix[] = {
	//	{ SQL_SUCCESS, "HELLOKITTY"	                                        , "HELLOKITTY" },
	//	{ SQL_SUCCESS, "H"                                                  , "H" },
	//	{ SQL_SUCCESS, "HELLOKITTYWENTTOTHESTORETOBUYDRI"                   , "HELLOKITTYWENTTOTHESTORETOBUYDRI" },
	//	{ SQL_SUCCESS, "HELLOKITTYWENTTOTHESTORETOBUYDRINKSFORTHEPARTY"     , "HELLOKITTYWENTTOTHESTORETOBUYDRI" },
	//	{ SQL_SUCCESS, "HelloKitty"                                         , "HELLOKITTY" },
	//	{ SQL_SUCCESS, "h"                                                  , "H" },
	//	{ SQL_SUCCESS, "HelloKittyWentToTheStoreToBuyDri"                   , "HELLOKITTYWENTTOTHESTORETOBUYDRI" },
	//	{ SQL_SUCCESS, "HelloKittyWentToTheStoreToBuyDrinksForTheParty"     , "HELLOKITTYWENTTOTHESTORETOBUYDRI" },
	//	{ SQL_SUCCESS, "H_1"                                                , "H_1" },
	//	{ SQL_SUCCESS, "HELLO_KITTY_1234"                                   , "HELLO_KITTY_1234" },
	//	{ SQL_SUCCESS, "HELLO_KITTY_1234_ABCDEFGHIJKLMNO"                   , "HELLO_KITTY_1234_ABCDEFGHIJKLMNO" },
	//	{ SQL_SUCCESS, "HELLO_KITTY_1234_ABCDEFGHIJKLMNOPQRSTUVWXYZ"        , "HELLO_KITTY_1234_ABCDEFGHIJKLMNO" },
	//	{ SQL_SUCCESS, "Hello_Kitty_1234"                                   , "HELLO_KITTY_1234" },
	//	{ SQL_SUCCESS, "Hello_Kitty_1234_abcdefghijklmno"                   , "HELLO_KITTY_1234_ABCDEFGHIJKLMNO" },
	//	{ SQL_SUCCESS, "Hello_Kitty_1234_abcdefghijklmnopqrstuvwxyz"        , "HELLO_KITTY_1234_ABCDEFGHIJKLMNO" },
	//	{ SQL_SUCCESS, "\"HELLOKITTY\""                                     , "HELLOKITTY" },
	//	{ SQL_SUCCESS, "\"H\""                                              , "H" },
	//	{ SQL_SUCCESS, "\"HELLOKITTYWENTTOTHESTORETOBUYDRI\""               , "HELLOKITTYWENTTOTHESTORETOBUYDRI" },
	//	{ SQL_SUCCESS, "\"HELLOKITTYWENTTOTHESTORETOBUYDRINKSFORTHEPARTY\"" , "HELLOKITTYWENTTOTHESTORETOBUYDRI" },
	//	{ SQL_SUCCESS, "\"HelloKitty\""                                     , "HelloKitty" },
	//	{ SQL_SUCCESS, "\"h\""                                              , "h" },
	//	{ SQL_SUCCESS, "\"HelloKittyWentToTheStoreToBuyDri\""               , "HelloKittyWentToTheStoreToBuyDri" },
	//	{ SQL_SUCCESS, "\"HelloKittyWentToTheStoreToBuyDrinksForTheParty\"" , "HelloKittyWentToTheStoreToBuyDri" },
	//	{ SQL_SUCCESS, "\"H_1\""                                            , "H_1" },
	//	{ SQL_SUCCESS, "\"HELLO_KITTY_1234\""                               , "HELLO_KITTY_1234" },
	//	{ SQL_SUCCESS, "\"HELLO_KITTY_1234_ABCDEFGHIJKLMNO\""               , "HELLO_KITTY_1234_ABCDEFGHIJKLMNO" },
	//	{ SQL_SUCCESS, "\"HELLO_KITTY_1234_ABCDEFGHIJKLMNOPQRSTUVWXYZ\""    , "HELLO_KITTY_1234_ABCDEFGHIJKLMNO" },
	//	{ SQL_SUCCESS, "\"Hello_Kitty_1234\""                               , "Hello_Kitty_1234" },
	//	{ SQL_SUCCESS, "\"Hello_Kitty_1234_abcdefghijklmno\""               , "Hello_Kitty_1234_abcdefghijklmno" },
	//	{ SQL_SUCCESS, "\"Hello_Kitty_1234_abcdefghijklmnopqrstuvwxyz\""    , "Hello_Kitty_1234_abcdefghijklmno" },
	//	{ SQL_SUCCESS, "\"Hello Kitty\""                                    , "Hello Kitty" },
	//	{ SQL_SUCCESS, "\"Hello Kitty says \"\"MEOW!\"\"\""                 , "Hello Kitty says \"MEOW\"" },
	//	{ SQL_SUCCESS, "\"Hello Kitty's Pruse\""                            , "Hello Kitty's Purse" },
	//	{ SQL_SUCCESS, "\"CREATE\""                                         , "CREATE" },
	//	{ SQL_SUCCESS, "\"SELECT * FROM T1\""								, "SELECT * FROM T1" },
	//	{ SQL_ERROR  , ""                                                   , "" },
	//	{ SQL_ERROR  , "	"                                               , "" },
	//	{ SQL_ERROR  , "1HelloKitty"                                        , "" },
	//	{ SQL_ERROR  , "_A"                                                 , "" },
	//	{ SQL_ERROR  , "Hello Kitty"                                        , "" },
	//	{ SQL_ERROR  , "Hello$Kitty"                                        , "" },
	//	{ SQL_ERROR  , "\"\\HelloKitty\""                                   , "" },
	//	{ SQL_ERROR  , "\"$HelloKitty\""                                    , "" },
	//	{ SQL_ERROR  , "\" \""                                              , "" },
	//	{ SQL_ERROR  , "\"\""                                               , "" },
	//	{ SQL_ERROR  , "\"@*()-_=+[]{}|:;'<>,.?\""                          , "" },
	//	{ SQL_ERROR  , "CREATE"												, "" },
	//	{ -101       , ""                                                   , "" }
	//};

	//struct
	//{
	//	char*	sqlStmt;
	//} sqlPrepareMatrix[] = {
	//	{ "CREATE CATALOG STMNT" },
	//	{ "CREATE SCHEMA STMNT.TEST" },
	//	{ "CREATE TABLE T2 ( C1 INTEGER NOT NULL NOT DROPPABLE, C2 INTEGER, PRIMARY KEY( C1 ) )" },
	//	{ "CREATE INDEX T2_INDEX ON T2 ( C1 ) NO POPULATE" },
	//	{ "CREATE PROCEDURE T2_PROC (IN IN1 TIME) EXTERNAL NAME 'Procs.N4210' EXTERNAL PATH '/usr/spjqa/Testware/Class' LANGUAGE JAVA PARAMETER STYLE JAVA NO SQL NO ISOLATE" },
	//	{ "CREATE VIEW T2_VIEW AS SELECT C1 FROM T2" },
	//	{ "INSERT INTO T2 VALUES ( 1 , 1) " },
	//	{ "SELECT C1 FROM T2" },
	//	{ "UPDATE T2 SET C2 = 2 WHERE C1 = 1" },
	//	{ "DELETE FROM T2" },
	//	{ "ALTER INDEX T2_INDEX ON T2 ( C2 ) NO POPULATE" },
	//	{ "ALTER TABLE T2 ( C1 INTEGER NOT NULL NOT DROPPABLE, C2 INTEGER NOT NULL, PRIMARY KEY( C1 ) )" },
	//	{ "ALTER TRIGGER" },
	//	{ "DROP SCHEMA STMT.TEST" },
	//	{ "DROP CATALOG STMT" },
	//	{ "DROP INDEX T2_INDEX" },
	//	{ "DROP VIEW T2_VIEW" },
	//	{ "DROP PROCEDURE T2_PROC" },
	//	{ "DROP TABLE T2" },
	//	{ "STOP" }
	//};

//======================================================================================================

	LogMsg(LINEBEFORE+SHORTTIMESTAMP,"Begin testing API => JobID | QueryID | QueryID.cpp\n");

	TEST_INIT;

	TESTCASE_BEGIN("Setup for JobID tests\n");

	if(!FullConnectWithOptions(pTestInfo, CONNECT_ODBC_VERSION_3))
	{
		LogMsg(NONE,"Unable to connect as ODBC3.0 application.\n");
		TEST_FAILED;
		TEST_RETURN;
	}

	henv = pTestInfo->henv;
 	hdbc = pTestInfo->hdbc;
 	hstmt = (SQLHANDLE)pTestInfo->hstmt;

	returncode = SQLAllocStmt((SQLHANDLE)hdbc, &hstmt);	
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLAllocStmt"))
	{
		LogAllErrors(henv,hdbc,hstmt);
		TEST_FAILED;
		TEST_RETURN;
	}

	returncode = SQLExecDirect(hstmt, (SQLCHAR*)droptab,SQL_NTS);

	returncode = SQLExecDirect(hstmt, (SQLCHAR*)createtab,SQL_NTS);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect"))
	{
		LogAllErrors(henv,hdbc,hstmt);
		TEST_FAILED;
		TEST_RETURN;
	}

	returncode = SQLExecDirect(hstmt, (SQLCHAR*)inserttab,SQL_NTS);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect"))
	{
		LogAllErrors(henv,hdbc,hstmt);
		TEST_FAILED;
		TEST_RETURN;
	}

	FullDisconnect(pTestInfo);
	TESTCASE_END;

//======================================================================================================
	sprintf(Heading,"Test positive functionality of SessionName, single connection\n");
	TESTCASE_BEGIN( Heading);

	// Allocate Environment Handle
	returncode = SQLAllocEnv(&henv);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLAllocEnv")) {
		LogAllErrors(henv,hdbc,hstmt);
		TEST_FAILED;
		TEST_RETURN;
	}

	returncode = SQLSetEnvAttr(henv, SQL_ATTR_ODBC_VERSION, (SQLPOINTER) SQL_OV_ODBC3, 0);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLSetEnvAttr"))
	{
		LogAllErrors(henv,hdbc,hstmt);
		SQLFreeEnv(henv);
		TEST_FAILED;
		TEST_RETURN;
	}

	// Allocate Connection handle
	returncode = SQLAllocConnect(henv,&hdbc);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLAllocConnect")) {
		LogAllErrors(henv,hdbc,hstmt);
		SQLFreeEnv(henv);
		TEST_FAILED;
		TEST_RETURN;
	}
	TESTCASE_END;
	
	loop = 0;
	while( jobIDMatrix[ loop ].returncode != -101 )
	{
		sprintf(Heading,"Test #%d: Testing for jobID: %s\n", loop, jobIDMatrix[ loop ].jobID);
		TESTCASE_BEGIN( Heading);

		returncode = SQLSetConnectAttr(hdbc, (SQLINTEGER)SQL_ATTR_SESSIONNAME,(SQLCHAR*) jobIDMatrix[ loop ].jobID, SQL_NTS);
		if (jobIDMatrix[ loop ].returncode == SQL_SUCCESS) {
			if(!CHECKRC(SQL_SUCCESS,returncode,"SQLSetConnectAttr")) {
				LogAllErrors(henv,hdbc,hstmt);
				TEST_FAILED;
				loop++;
				continue;
			}

		}
		else {
#ifdef unixcli
			if(returncode != SQL_ERROR) {
#else
			if(!CHECKRC(SQL_SUCCESS,returncode,"SQLSetConnectAttr")) {
#endif
				LogAllErrors(henv,hdbc,hstmt);
				TEST_FAILED;
				loop++;
				continue;
			}
		}
		returncode = SQLGetConnectAttr(hdbc, (SQLINTEGER)SQL_ATTR_SESSIONNAME, jobid, SQL_MAX_SESSIONNAME_LEN, &jobidlen);
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLGetConnectAttr")) {
			LogAllErrors(henv,hdbc,hstmt);
			TEST_FAILED;
			loop++;
			continue;
		}
		if (jobIDMatrix[ loop ].returncode == SQL_SUCCESS) {
			if (strcmp(jobIDMatrix[ loop ].jobIDExpected, jobid) == 0) {
				LogMsg(NONE, "JobIDs are matched. Expected: \"%s\", Actual: \"%s\" for SQLGetConnectAttr\n", jobIDMatrix[ loop ].jobIDExpected, jobid);
				TESTCASE_END;
			}
			else {
				LogMsg(ERRMSG, "JobIDs are not matched. Expected: \"%s\", Actual: \"%s\", at line=%d for SQLGetConnectAttr\n", jobIDMatrix[ loop ].jobIDExpected, jobid, __LINE__);
				TEST_FAILED;
			}
		}
		else {
#ifdef unixcli
			if (strcmp(jobIDMatrix[ loop ].jobIDExpected, jobid) == 0) {
#else
			if (strcmp(jobIDMatrix[ loop ].jobID, jobid) == 0) {
#endif
				LogMsg(NONE, "JobIDs are matched. Expected: \"%s\", Actual: \"%s\" for SQLGetConnectAttr\n", jobIDMatrix[ loop ].jobID, jobid);
				TESTCASE_END;
			}
			else {
				LogMsg(ERRMSG, "JobIDs are not matched. Expected: \"%s\", Actual: \"%s\", at line=%d for SQLGetConnectAttr\n", jobIDMatrix[ loop ].jobID, jobid, __LINE__);
				TEST_FAILED;
			}
		}

		returncode = SQLConnect(hdbc,
							   (SQLCHAR*)pTestInfo->DataSource,(SWORD)strlen(pTestInfo->DataSource),
							   (SQLCHAR*)pTestInfo->UserID,(SWORD)strlen(pTestInfo->UserID),
							   (SQLCHAR*)pTestInfo->Password,(SWORD)strlen(pTestInfo->Password)
							   );	
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLConnect")) {
			LogAllErrors(henv,hdbc,hstmt);
			SQLFreeConnect(hdbc);
			SQLFreeEnv(henv);
			TEST_FAILED;
			TEST_RETURN;
		}

#ifndef unixcli
		if (jobIDMatrix[ loop ].returncode ==  SQL_SUCCESS_WITH_INFO) {
			if (returncode != jobIDMatrix[ loop ].returncode) {
				LogMsg(ERRMSG, "The retcode has to be SQL_SUCCESS_WITH_INFO, with the error message \"Driver's SQLSetConnectAttr failed.\" in it, at line=%d\n", __LINE__);
				SQLFreeConnect(hdbc);
				SQLFreeEnv(henv);
				TEST_FAILED;
				TEST_RETURN;
			}
//			LogAllErrors(henv,hdbc,NULL);
			if (!FindError("IM006",henv,hdbc,NULL)) {
				LogMsg(ERRMSG, "Couldn't find state error IM006, with the error message \"Driver's SQLSetConnectAttr failed.\", at line=%d\n", __LINE__);
				SQLFreeConnect(hdbc);
				SQLFreeEnv(henv);
				TEST_FAILED;
				TEST_RETURN;
			}
		}
#endif

		returncode = SQLAllocStmt(hdbc,&hstmt);
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLAllocStmt")) {
			LogAllErrors(henv,hdbc,hstmt);
			SQLFreeConnect(hdbc);
			SQLFreeEnv(henv);
			TEST_FAILED;
			TEST_RETURN;
		}

		returncode = SQLAllocStmt(hdbc,&hstmt2);
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLAllocStmt")) {
			LogAllErrors(henv,hdbc,hstmt);
			SQLFreeConnect(hdbc);
			SQLFreeEnv(henv);
			TEST_FAILED;
			TEST_RETURN;
		}

		returncode = SQLPrepare( hstmt, (SQLCHAR *)selecttab, SQL_NTS );
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLPrepare")) {
			LogAllErrors(henv,hdbc,hstmt);
			SQLFreeConnect(hdbc);
			SQLFreeEnv(henv);
			TEST_FAILED;
			TEST_RETURN;
		}

		returncode = SQLGetCursorName(hstmt, cursorName, sizeof(cursorName), NULL );
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLPrepare")) {
			LogAllErrors(henv,hdbc,hstmt);
			SQLFreeConnect(hdbc);
			SQLFreeEnv(henv);
			TEST_FAILED;
			TEST_RETURN;
		}

		//Get queryID
		sprintf( infoStatsStmt, "INFOSTATS %s", (char*)cursorName );
		returncode = SQLBindCol( hstmt2, 1, SQL_C_CHAR, &queryID, 256, &queryIDPtr );
 		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol")) {
			LogAllErrors(henv,hdbc,hstmt2);
			SQLFreeConnect(hdbc);
			SQLFreeEnv(henv);
			TEST_FAILED;
			TEST_RETURN;
		}

		returncode = SQLExecDirect( hstmt2, (SQLCHAR *)infoStatsStmt, SQL_NTS );
 		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol")) {
			LogAllErrors(henv,hdbc,hstmt2);
			SQLFreeConnect(hdbc);
			SQLFreeEnv(henv);
			TEST_FAILED;
			TEST_RETURN;
		}

		returncode = SQLFetch( hstmt2 );
 		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol")) {
			LogAllErrors(henv,hdbc,hstmt2);
			SQLFreeConnect(hdbc);
			SQLFreeEnv(henv);
			TEST_FAILED;
			TEST_RETURN;
		}

		LogMsg(NONE, "queryID: \"%s\"\n", queryID);
		SQLFreeStmt(hstmt2,SQL_CLOSE);
		SQLFreeStmt(hstmt2,SQL_UNBIND);

		//Get Jobid
		if(isCharSet || isUCS2)
			sprintf( infoStatsStmt, "SELECT queryid_extract( _ISO88591'%s',_ISO88591'SESSIONNAME') FROM JOBID", (char*)queryID );
		else
			sprintf( infoStatsStmt, "SELECT queryid_extract('%s','SESSIONNAME') FROM JOBID", (char*)queryID );

		returncode = SQLBindCol( hstmt2, 1, SQL_C_CHAR, &queryID, 256, &queryIDPtr );
 		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol")) {
			LogAllErrors(henv,hdbc,hstmt2);
			SQLFreeConnect(hdbc);
			SQLFreeEnv(henv);
			TEST_FAILED;
			TEST_RETURN;
		}

		returncode = SQLExecDirect( hstmt2, (SQLCHAR *)infoStatsStmt, SQL_NTS );
 		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol")) {
			LogAllErrors(henv,hdbc,hstmt2);
			SQLFreeConnect(hdbc);
			SQLFreeEnv(henv);
			TEST_FAILED;
			TEST_RETURN;
		}

		returncode = SQLFetch( hstmt2 );
 		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol")) {
			LogAllErrors(henv,hdbc,hstmt2);
			SQLFreeConnect(hdbc);
			SQLFreeEnv(henv);
			TEST_FAILED;
			TEST_RETURN;
		}

		LogMsg(NONE, "JobID: \"%s\"\n", queryID);
		if (strcmp(jobIDMatrix[ loop ].jobIDExpected, queryID) == 0) {
			LogMsg(NONE, "JobIDs are matched. Expected: \"%s\", Actual: \"%s\" for after queryid_extract\n", jobIDMatrix[ loop ].jobIDExpected, queryID);
			TESTCASE_END;
		}
		else {
			LogMsg(ERRMSG, "JobIDs are not matched. Expected: \"%s\", Actual: \"%s\", at line=%d for after queryid_extract\n", jobIDMatrix[ loop ].jobIDExpected, queryID, __LINE__);
			TEST_FAILED;
		}

		SQLFreeStmt(hstmt,SQL_CLOSE);
		SQLFreeStmt(hstmt,SQL_UNBIND);
		SQLFreeStmt(hstmt2,SQL_CLOSE);
		SQLFreeStmt(hstmt2,SQL_UNBIND);

		returncode = SQLDisconnect(hdbc);
		if (returncode != SQL_SUCCESS)
		{
			LogAllErrors(henv,hdbc,hstmt);
			SQLDisconnect(hdbc);
			SQLFreeConnect(hdbc);
			SQLFreeEnv(henv);
		}
   		loop++;
	}

	returncode = SQLFreeConnect(hdbc);
	if (returncode != SQL_SUCCESS)
	{
		LogAllErrors(henv,hdbc,hstmt);
		SQLDisconnect(hdbc);
		SQLFreeConnect(hdbc);
		SQLFreeEnv(henv);
	}

	returncode = SQLFreeEnv(henv);
	if (returncode != SQL_SUCCESS)
	{
		LogAllErrors(henv,hdbc,hstmt);
		SQLDisconnect(hdbc);
		SQLFreeConnect(hdbc);
		SQLFreeEnv(henv);
	}

//======================================================================================================
	sprintf(Heading,"Test positive functionality of SessionName, mutiple connection using the same session name\n");
	TESTCASE_BEGIN( Heading);

	// Allocate Environment Handle
	returncode = SQLAllocEnv(&henv);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLAllocEnv")) {
		LogAllErrors(henv,hdbc,hstmt);
		TEST_FAILED;
		TEST_RETURN;
	}
	returncode = SQLAllocEnv(&henv2);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLAllocEnv2")) {
		LogAllErrors(henv2,hdbc2,hstmt2);
		TEST_FAILED;
		TEST_RETURN;
	}

	returncode = SQLSetEnvAttr(henv, SQL_ATTR_ODBC_VERSION, (SQLPOINTER) SQL_OV_ODBC3, 0);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLSetEnvAttr"))
	{
		LogAllErrors(henv,hdbc,hstmt);
		SQLFreeEnv(henv);
		TEST_FAILED;
		TEST_RETURN;
	}
	returncode = SQLSetEnvAttr(henv2, SQL_ATTR_ODBC_VERSION, (SQLPOINTER) SQL_OV_ODBC3, 0);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLSetEnvAttr2"))
	{
		LogAllErrors(henv2,hdbc2,hstmt2);
		SQLFreeEnv(henv2);
		TEST_FAILED;
		TEST_RETURN;
	}

	// Allocate Connection handle
	returncode = SQLAllocConnect(henv,&hdbc);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLAllocConnect")) {
		LogAllErrors(henv,hdbc,hstmt);
		SQLFreeEnv(henv);
		TEST_FAILED;
		TEST_RETURN;
	}
	returncode = SQLAllocConnect(henv2,&hdbc2);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLAllocConnect2")) {
		LogAllErrors(henv2,hdbc2,hstmt2);
		SQLFreeEnv(henv2);
		TEST_FAILED;
		TEST_RETURN;
	}
	TESTCASE_END;
	

	strcpy(tempStr,"123456789012345678901234");
	sprintf(Heading,"Testing for jobID: %s\n", tempStr);
	TESTCASE_BEGIN( Heading);

	returncode = SQLSetConnectAttr(hdbc, (SQLINTEGER)SQL_ATTR_SESSIONNAME,(SQLCHAR*) tempStr, SQL_NTS);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLGetConnectAttr")) {
		LogAllErrors(henv,hdbc,hstmt);
		TEST_FAILED;
		TEST_RETURN;
	}
	returncode = SQLSetConnectAttr(hdbc2, (SQLINTEGER)SQL_ATTR_SESSIONNAME,(SQLCHAR*) tempStr, SQL_NTS);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLGetConnectAttr2")) {
		LogAllErrors(henv2,hdbc2,hstmt2);
		TEST_FAILED;
		TEST_RETURN;
	}

	returncode = SQLGetConnectAttr(hdbc, (SQLINTEGER)SQL_ATTR_SESSIONNAME, jobid, SQL_MAX_SESSIONNAME_LEN, &jobidlen);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLGetConnectAttr")) {
		LogAllErrors(henv,hdbc,hstmt);
		TEST_FAILED;
	}
	if (strcmp(tempStr, jobid) == 0) {
		LogMsg(NONE, "JobID1 are matched. Expected: \"%s\", Actual: \"%s\" for hdbc\n", tempStr, jobid);
	}
	else {
		LogMsg(ERRMSG, "JobID1 are not matched. Expected: \"%s\", Actual: \"%s\", at line=%d for hdbc\n", tempStr, jobid, __LINE__);
		TEST_FAILED;
		TEST_RETURN;
	}

	returncode = SQLGetConnectAttr(hdbc2, (SQLINTEGER)SQL_ATTR_SESSIONNAME, jobid, SQL_MAX_SESSIONNAME_LEN, &jobidlen);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLGetConnectAttr2")) {
		LogAllErrors(henv2,hdbc2,hstmt2);
		TEST_FAILED;
		TEST_RETURN;
	}
	if (strcmp(tempStr, jobid) == 0) {
		LogMsg(NONE, "JobID2 are matched. Expected: \"%s\", Actual: \"%s\" for hdbc2\n", tempStr, jobid);
	}
	else {
		LogMsg(ERRMSG, "JobID2 are not matched. Expected: \"%s\", Actual: \"%s\", at line=%d for hdbc2\n", tempStr, jobid, __LINE__);
		TEST_FAILED;
		TEST_RETURN;
	}

	returncode = SQLConnect(hdbc,
						   (SQLCHAR*)pTestInfo->DataSource,(SWORD)strlen(pTestInfo->DataSource),
						   (SQLCHAR*)pTestInfo->UserID,(SWORD)strlen(pTestInfo->UserID),
						   (SQLCHAR*)pTestInfo->Password,(SWORD)strlen(pTestInfo->Password)
						   );	
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLConnect")) {
		LogAllErrors(henv,hdbc,hstmt);
		SQLFreeConnect(hdbc);
		SQLFreeEnv(henv);
		TEST_FAILED;
		TEST_RETURN;
	}
	returncode = SQLConnect(hdbc2,
						   (SQLCHAR*)pTestInfo->DataSource,(SWORD)strlen(pTestInfo->DataSource),
						   (SQLCHAR*)pTestInfo->UserID,(SWORD)strlen(pTestInfo->UserID),
						   (SQLCHAR*)pTestInfo->Password,(SWORD)strlen(pTestInfo->Password)
						   );	
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLConnect2")) {
		LogAllErrors(henv2,hdbc2,hstmt2);
		SQLFreeConnect(hdbc2);
		SQLFreeEnv(henv2);
		TEST_FAILED;
		TEST_RETURN;
	}

	for (loop=0; loop<2; loop++) {
		if (loop == 0) {
			returncode = SQLAllocStmt(hdbc,&hstmt);
			if(!CHECKRC(SQL_SUCCESS,returncode,"SQLAllocStmt")) {
				LogAllErrors(henv,hdbc,hstmt);
				SQLFreeConnect(hdbc);
				SQLFreeEnv(henv);
				TEST_FAILED;
				TEST_RETURN;
			}
			returncode = SQLAllocStmt(hdbc,&hstmt2);
			if(!CHECKRC(SQL_SUCCESS,returncode,"SQLAllocStmt3")) {
				LogAllErrors(henv,hdbc,hstmt2);
				SQLFreeConnect(hdbc);
				SQLFreeEnv(henv);
				TEST_FAILED;
				TEST_RETURN;
			}
		}
		else {
			returncode = SQLAllocStmt(hdbc2,&hstmt);
			if(!CHECKRC(SQL_SUCCESS,returncode,"SQLAllocStmt")) {
				LogAllErrors(henv2,hdbc2,hstmt);
				SQLFreeConnect(hdbc2);
				SQLFreeEnv(henv2);
				TEST_FAILED;
				TEST_RETURN;
			}
			returncode = SQLAllocStmt(hdbc2,&hstmt2);
			if(!CHECKRC(SQL_SUCCESS,returncode,"SQLAllocStmt3")) {
				LogAllErrors(henv2,hdbc2,hstmt2);
				SQLFreeConnect(hdbc2);
				SQLFreeEnv(henv2);
				TEST_FAILED;
				TEST_RETURN;
			}
		}

		returncode = SQLPrepare( hstmt, (SQLCHAR *)selecttab, SQL_NTS );
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLPrepare")) {
			LogAllErrors(henv,hdbc,hstmt);
			SQLFreeConnect(hdbc);
			SQLFreeEnv(henv);
			TEST_FAILED;
			TEST_RETURN;
		}

		returncode = SQLGetCursorName(hstmt, cursorName, sizeof(cursorName), NULL );
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLPrepare")) {
			LogAllErrors(henv,hdbc,hstmt);
			SQLFreeConnect(hdbc);
			SQLFreeEnv(henv);
			TEST_FAILED;
			TEST_RETURN;
		}

		//Get queryID
		sprintf( infoStatsStmt, "INFOSTATS %s", (char*)cursorName );
		returncode = SQLBindCol( hstmt2, 1, SQL_C_CHAR, &queryID, 256, &queryIDPtr );
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol")) {
			LogAllErrors(henv,hdbc,hstmt2);
			SQLFreeConnect(hdbc);
			SQLFreeEnv(henv);
			TEST_FAILED;
			TEST_RETURN;
		}

		returncode = SQLExecDirect( hstmt2, (SQLCHAR *)infoStatsStmt, SQL_NTS );
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol")) {
			LogAllErrors(henv,hdbc,hstmt2);
			SQLFreeConnect(hdbc);
			SQLFreeEnv(henv);
			TEST_FAILED;
			TEST_RETURN;
		}

		returncode = SQLFetch( hstmt2 );
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol")) {
			LogAllErrors(henv,hdbc,hstmt2);
			SQLFreeConnect(hdbc);
			SQLFreeEnv(henv);
			TEST_FAILED;
			TEST_RETURN;
		}

		LogMsg(NONE, "queryID%d: \"%s\"\n", loop, queryID);
		SQLFreeStmt(hstmt2,SQL_CLOSE);
		SQLFreeStmt(hstmt2,SQL_UNBIND);

		//Get Jobid
		if(isCharSet || isUCS2)
			sprintf( infoStatsStmt, "SELECT queryid_extract( _ISO88591'%s', _ISO88591'SESSIONNAME') FROM JOBID", (char*)queryID );
		else
			sprintf( infoStatsStmt, "SELECT queryid_extract('%s','SESSIONNAME') FROM JOBID", (char*)queryID );

		returncode = SQLBindCol( hstmt2, 1, SQL_C_CHAR, &queryID, 256, &queryIDPtr );
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol")) {
			LogAllErrors(henv,hdbc,hstmt2);
			SQLFreeConnect(hdbc);
			SQLFreeEnv(henv);
			TEST_FAILED;
			TEST_RETURN;
		}

		returncode = SQLExecDirect( hstmt2, (SQLCHAR *)infoStatsStmt, SQL_NTS );
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol")) {
			LogAllErrors(henv,hdbc,hstmt2);
			SQLFreeConnect(hdbc);
			SQLFreeEnv(henv);
			TEST_FAILED;
			TEST_RETURN;
		}

		returncode = SQLFetch( hstmt2 );
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol")) {
			LogAllErrors(henv,hdbc,hstmt2);
			SQLFreeConnect(hdbc);
			SQLFreeEnv(henv);
			TEST_FAILED;
			TEST_RETURN;
		}

		LogMsg(NONE, "JobID%d: \"%s\"\n", loop, queryID);
		if (strcmp(tempStr, queryID) == 0) {
			LogMsg(NONE, "JobID%d are matched. Expected: \"%s\", Actual: \"%s\" for after queryid_extract\n", loop, tempStr, queryID);
			TESTCASE_END;
		}
		else {
			LogMsg(ERRMSG, "JobID%d are not matched. Expected: \"%s\", Actual: \"%s\", at line=%d for after queryid_extract\n", loop, tempStr, queryID, __LINE__);
			TEST_FAILED;
		}

		SQLFreeStmt(hstmt,SQL_CLOSE);
		SQLFreeStmt(hstmt,SQL_UNBIND);
		SQLFreeStmt(hstmt2,SQL_CLOSE);
		SQLFreeStmt(hstmt2,SQL_UNBIND);
	}

	returncode = SQLDisconnect(hdbc);
	if (returncode != SQL_SUCCESS)
	{
		LogAllErrors(henv,hdbc,hstmt);
		SQLDisconnect(hdbc);
		SQLFreeConnect(hdbc);
		SQLFreeEnv(henv);
	}
	returncode = SQLDisconnect(hdbc2);
	if (returncode != SQL_SUCCESS)
	{
		LogAllErrors(henv2,hdbc2,hstmt2);
		SQLDisconnect(hdbc2);
		SQLFreeConnect(hdbc2);
		SQLFreeEnv(henv2);
	}

	returncode = SQLFreeConnect(hdbc);
	if (returncode != SQL_SUCCESS)
	{
		LogAllErrors(henv,hdbc,hstmt);
		SQLDisconnect(hdbc);
		SQLFreeConnect(hdbc);
		SQLFreeEnv(henv);
	}
	returncode = SQLFreeConnect(hdbc2);
	if (returncode != SQL_SUCCESS)
	{
		LogAllErrors(henv2,hdbc2,hstmt2);
		SQLDisconnect(hdbc2);
		SQLFreeConnect(hdbc2);
		SQLFreeEnv(henv2);
	}

	returncode = SQLFreeEnv(henv);
	if (returncode != SQL_SUCCESS)
	{
		LogAllErrors(henv,hdbc,hstmt);
		SQLDisconnect(hdbc);
		SQLFreeConnect(hdbc);
		SQLFreeEnv(henv);
	}
	returncode = SQLFreeEnv(henv2);
	if (returncode != SQL_SUCCESS)
	{
		LogAllErrors(henv2,hdbc2,hstmt2);
		SQLDisconnect(hdbc2);
		SQLFreeConnect(hdbc2);
		SQLFreeEnv(henv2);
	}

	//=========================================================================================

	//FullDisconnect(pTestInfo);
	LogMsg(SHORTTIMESTAMP+LINEAFTER,"End testing API => JobID.\n");
	TEST_RETURN;
}
Beispiel #20
0
PassFail TestSQLAllocEnv(TestInfo *pTestInfo)

{ 
	
	TEST_DECLARE;
  RETCODE returncode;
  SQLHANDLE henv;
  SQLHANDLE OldHenv;
  SQLHANDLE BadHenv;       
   
	LogMsg(LINEBEFORE+SHORTTIMESTAMP,_T("Begin testing API => SQLAllocEnvirnoment.\n"));

	TEST_INIT;
	   
  TESTCASE_BEGIN("Test basic functionality of SQLAllocEnv\n");
  henv=(SQLHANDLE)NULL;
  returncode = SQLAllocEnv(&henv);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLAllocEnv"))
	{
      /* Fatal error, no use running the remaining tests so, return */
		TEST_FAILED;
		TEST_RETURN;
  }
  TESTCASE_END;
   
  TESTCASE_BEGIN("Test non-NULL handle value\n");
  OldHenv=henv;
  returncode=SQLAllocEnv(&henv);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLAllocEnv"))
	{
     SQLFreeEnv(OldHenv);
     LogMsg(ENDLINE,_T("Using a valid, non-NULL handle caused an error.\n"));
    /* Fatal error, no use running the remaining tests so, return */
    TEST_FAILED;
		TEST_RETURN;
  }
  TESTCASE_END;
   
  TESTCASE_BEGIN("Negative test: Invalid handle pointer\n");
  BadHenv=(SQLHANDLE)NULL;
  returncode=SQLAllocEnv((SQLHANDLE *)BadHenv);
	if(!CHECKRC(SQL_ERROR,returncode,"SQLAllocEnv"))
	{
	   LogMsg(ENDLINE,_T("Invalid handle pointer works, it shouldn't.\n"));
	   TEST_FAILED;
	}
  TESTCASE_END;

  TESTCASE_BEGIN("Test basic functionality of SQLFreeEnv\n");
  returncode=SQLFreeEnv(OldHenv);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLFreeEnv"))
	{
    LogAllErrors(OldHenv,(SQLHANDLE)NULL,(SQLHANDLE)NULL);
		TEST_FAILED;
	}
      
  returncode=SQLFreeEnv(henv);   
  if(!CHECKRC(SQL_SUCCESS,returncode,"SQLFreeEnv"))
	{
    LogAllErrors(henv,(SQLHANDLE)NULL,(SQLHANDLE)NULL);
	  TEST_FAILED;
	}
  TESTCASE_END;
   
/*	// this is a bug in driver manager we cannot free already freed   
	TESTCASE_BEGIN("Negative test: free an already freed handle\n");
	returncode=SQLFreeEnv(henv);   
	if(!CHECKRC(SQL_INVALID_HANDLE,returncode,"SQLFreeEnv"))
	{
		LogMsg(ENDLINE,"Invalid handle didn't produce proper error.");
    TEST_FAILED
	}

	TESTCASE_END;
*/

	LogMsg(SHORTTIMESTAMP+LINEBEFORE+LINEAFTER,_T("End testing API => SQLAllocEnvirnoment.\n"));
  TEST_RETURN;

}
Beispiel #21
0
/*
------------------------------------------------------------------
   TestSQLGetTypeInfo: Tests SQLGetTypeInfo                      
------------------------------------------------------------------
*/
PassFail TestSQLGetTypeInfoR18(TestInfo *pTestInfo)
{   
	TEST_DECLARE;
	char				Heading[MAX_STRING_SIZE];
  RETCODE			returncode;
  SQLHANDLE 			henv;
  SQLHANDLE 			hdbc;
  SQLHANDLE			hstmt;				  
  char				TempBuf[MAX_STRING_SIZE];	
  int				j = 0,END_LOOP;

	struct
	{
		char		*TYPE_NAME;
		SWORD		DATA_TYPE;
		SDWORD		PRECISION;
		char		*LITERAL_PREFIX;
		char		*LITERAL_SUFFIX;
		char		*CREATE_PARAMS;
		SWORD		NULLABLE;
		SWORD		CASE_SENSITIVE;
		SWORD		SEARCHABLE;
		SWORD		UNSIGNED_ATTRIBUTE;
		SWORD		MONEY;
		SWORD		AUTO_INCREMENT;
		char		*LOCAL_TYPE_NAME;
		SWORD		MINIMUM_SCALE;
		SWORD		MAXIMUM_SCALE;
	}	TypeInfo[] = 
		{//TYPENAME,DATATYPE,PREC,LITPRE,LITSUF,PARAM,NULL,CASE,SRCH,ATTR,MON,INC,LOC,MIN,MAX
			{"",SQL_ALL_TYPES,0,"","","",0,0,0,0,0,0,"",0,0},	// this is for get all types
			{"CHAR", SQL_CHAR, 254, "'", "'", "max length", SQL_NULLABLE, 1, SQL_SEARCHABLE, 0, 0, 0, "CHARACTER", 0, 0},
			{"VARCHAR", SQL_VARCHAR, 254, "'", "'", "max length", SQL_NULLABLE, 1, SQL_SEARCHABLE, 0, 0, 0, "VARCHAR", 0, 0},
			{"DECIMAL", SQL_DECIMAL, 18, "", "", "precision,scale", SQL_NULLABLE, 0, SQL_ALL_EXCEPT_LIKE, 0, 0, 0, "DECIMAL", 0, 18},
			{"NUMERIC", SQL_NUMERIC, 128, "", "", "precision,scale", SQL_NULLABLE, 0, SQL_ALL_EXCEPT_LIKE, 0, 0, 0, "NUMERIC", 0, 128},
			{"SMALLINT", SQL_SMALLINT, 5, "", "", "", SQL_NULLABLE, 0, SQL_ALL_EXCEPT_LIKE, 0, 0, 0, "SMALLINT", 0, 0},
			{"INTEGER", SQL_INTEGER, 10, "", "", "", SQL_NULLABLE, 0, SQL_ALL_EXCEPT_LIKE, 0, 0, 0, "INTEGER", 0, 0},
			{"REAL", SQL_REAL, 7, "", "", "", SQL_NULLABLE, 0, SQL_ALL_EXCEPT_LIKE, 0, 0, 0, "REAL", 0, 0},
			{"FLOAT", SQL_FLOAT, 15, "", "", "", SQL_NULLABLE, 0, SQL_ALL_EXCEPT_LIKE, 0, 0, 0, "FLOAT", 0, 0},
			{"DOUBLE PRECISION", SQL_DOUBLE, 15, "", "", "", SQL_NULLABLE, 0, SQL_ALL_EXCEPT_LIKE, 0, 0, 0, "DOUBLE", 0, 0},
//			{"DATE", SQL_DATE,  10,  "{d '",  "'}","", SQL_NULLABLE, 0, SQL_ALL_EXCEPT_LIKE, 0, 0, 0, "DATE", 0, 0},
//			{"TIME", SQL_TIME, 8, "{t '", "'}", "", SQL_NULLABLE, 0, SQL_ALL_EXCEPT_LIKE, 0, 0, 0, "TIME", 0, 0},
//			{"TIMESTAMP", SQL_TIMESTAMP, 23, "{ts '", "'}", "", SQL_NULLABLE, 0, SQL_ALL_EXCEPT_LIKE, 0, 0, 0, "TIMESTAMP", 0, 6},
			{"DATE", SQL_TYPE_DATE,  10,  "{d '",  "'}","", SQL_NULLABLE, 0, SQL_ALL_EXCEPT_LIKE, 0, 0, 0, "DATE", 0, 0},
			{"TIME", SQL_TYPE_TIME, 8, "{t '", "'}", "", SQL_NULLABLE, 0, SQL_ALL_EXCEPT_LIKE, 0, 0, 0, "TIME", 0, 0},
			{"TIMESTAMP", SQL_TYPE_TIMESTAMP, 26, "{ts '", "'}", "", SQL_NULLABLE, 0, SQL_ALL_EXCEPT_LIKE, 0, 0, 0, "TIMESTAMP", 0, 6},
			{"BIGINT", SQL_BIGINT, 19, "", "", "", SQL_NULLABLE, 0, SQL_ALL_EXCEPT_LIKE, 0, 0, 0, "LARGEINT", 0, 0},
			{"LONG VARCHAR", SQL_LONGVARCHAR, 4018, "'", "'", "", SQL_NULLABLE, 1, SQL_SEARCHABLE, 0, 0, 0, "LONG VARCHAR", 0, 0},
//			{"BINARY", SQL_BINARY, 4059, "'", "'", "max length", 1, 0, 0, 0, 0, 0, "", 0, 0},
//			{"VARBINARY", -3, 4059, "'", "'", "max length", 1, 0, 0, 0, 0, 0, "", 0, 0},
//			{"LONG VARBINARY", -4, 4059, "'", "'", "max length", 1, 0, 0, 0, 0, 0, "", 0, 0},
//			{"TINYINT", -6, 3, "", "", "", 1, 0, SQL_ALL_EXCEPT_LIKE, 1, 0, 0, "", 0, 0},
//			{"BIT", -7, 1, "", "", "", 1, 0, SQL_UNSEARCHABLE, 0, 0, 0, "", 0, 0},
			{"INTERVAL", SQL_INTERVAL_YEAR, 0, "{INTERVAL '", "' YEAR}", "", SQL_NULLABLE, 0, SQL_ALL_EXCEPT_LIKE, 0, 0, 0, "INTERVAL", 0, 0},
			{"INTERVAL", SQL_INTERVAL_MONTH, 0, "{INTERVAL '", "' MONTH}", "", SQL_NULLABLE, 0, SQL_ALL_EXCEPT_LIKE, 0, 0, 0, "INTERVAL", 0, 0},
			{"INTERVAL", SQL_INTERVAL_DAY, 0, "{INTERVAL '", "' DAY}", "", SQL_NULLABLE, 0, SQL_ALL_EXCEPT_LIKE, 0, 0, 0, "INTERVAL", 0, 0},
			{"INTERVAL", SQL_INTERVAL_HOUR, 0, "{INTERVAL '", "' HOUR}", "", SQL_NULLABLE, 0, SQL_ALL_EXCEPT_LIKE, 0, 0, 0, "INTERVAL", 0, 0},
			{"INTERVAL", SQL_INTERVAL_MINUTE, 0, "{INTERVAL '", "' MINUTE}", "", SQL_NULLABLE, 0, SQL_ALL_EXCEPT_LIKE, 0, 0, 0, "INTERVAL", 0, 0},
			{"INTERVAL", SQL_INTERVAL_SECOND, 0, "{INTERVAL '", "' SECOND}", "", SQL_NULLABLE, 0, SQL_ALL_EXCEPT_LIKE, 0, 0, 0, "INTERVAL", 0, 0},
			{"INTERVAL", SQL_INTERVAL_YEAR_TO_MONTH, 0, "{INTERVAL '", "' YEAR TO MONTH}", "", SQL_NULLABLE, 0, SQL_ALL_EXCEPT_LIKE, 0, 0, 0, "INTERVAL", 0, 0},
			{"INTERVAL", SQL_INTERVAL_DAY_TO_HOUR, 0, "{INTERVAL '", "' DAY TO HOUR}", "", SQL_NULLABLE, 0, SQL_ALL_EXCEPT_LIKE, 0, 0, 0, "INTERVAL", 0, 0},
			{"INTERVAL", SQL_INTERVAL_DAY_TO_MINUTE, 0, "{INTERVAL '", "' DAY TO MINUTE}", "", SQL_NULLABLE, 0, SQL_ALL_EXCEPT_LIKE, 0, 0, 0, "INTERVAL", 0, 0},
			{"INTERVAL", SQL_INTERVAL_DAY_TO_SECOND, 0, "{INTERVAL '", "' DAY TO SECOND}", "", SQL_NULLABLE, 0, SQL_ALL_EXCEPT_LIKE, 0, 0, 0, "INTERVAL", 0, 0},
			{"INTERVAL", SQL_INTERVAL_HOUR_TO_MINUTE, 0, "{INTERVAL '", "' HOUR TO MINUTE}", "", SQL_NULLABLE, 0, SQL_ALL_EXCEPT_LIKE, 0, 0, 0, "INTERVAL", 0, 0},
			{"INTERVAL", SQL_INTERVAL_HOUR_TO_SECOND, 0, "{INTERVAL '", "' HOUR TO SECOND}", "", SQL_NULLABLE, 0, SQL_ALL_EXCEPT_LIKE, 0, 0, 0, "INTERVAL", 0, 0},
			{"INTERVAL", SQL_INTERVAL_MINUTE_TO_SECOND, 0, "{INTERVAL '", "' MINUTE TO SECOND}", "", SQL_NULLABLE, 0, SQL_ALL_EXCEPT_LIKE, 0, 0, 0, "INTERVAL", 0, 0},
			{"",999,}	
	};



		char		oTYPE_NAME[TYPE_LEN];
		SWORD		oDATA_TYPE, fSqlType1;
		SDWORD		oPRECISION;
		char		oLITERAL_PREFIX[TYPE_LEN];
		char		oLITERAL_SUFFIX[TYPE_LEN];
		char		oCREATE_PARAMS[TYPE_LEN];
		SWORD		oNULLABLE;
		SWORD		oCASE_SENSITIVE;
		SWORD		oSEARCHABLE;
		SWORD		oUNSIGNED_ATTRIBUTE;
		SWORD		oMONEY;
		SWORD		oAUTO_INCREMENT;
		char		oLOCAL_TYPE_NAME[TYPE_LEN];
		SWORD		oMINIMUM_SCALE;
		SWORD		oMAXIMUM_SCALE;

		SQLLEN	oTYPE_NAMElen;	
		SQLLEN	oDATA_TYPElen;
		SQLLEN	oPRECISIONlen;
		SQLLEN	oLITERAL_PREFIXlen;
		SQLLEN	oLITERAL_SUFFIXlen;
		SQLLEN	oCREATE_PARAMSlen;
		SQLLEN	oNULLABLElen;
		SQLLEN	oCASE_SENSITIVElen;
		SQLLEN	oSEARCHABLElen;
		SQLLEN	oUNSIGNED_ATTRIBUTElen;
		SQLLEN	oMONEYlen;
		SQLLEN	oAUTO_INCREMENTlen;
		SQLLEN	oLOCAL_TYPE_NAMElen;
		SQLLEN	oMINIMUM_SCALElen;
		SQLLEN	oMAXIMUM_SCALElen;

   	/* Set up some local variables to save on typing in longer ones */
    /* This previously was R1.8 */
//================Modified for Longvarchar Changes===========================================================
if(!pTestInfo->bLongOn)
{
	char *TYPE_NAME = "VARCHAR";
	SWORD DATA_TYPE = SQL_VARCHAR;
    SDWORD	PRECISION = 32000;
	char *CREATE_PARAMS = "max length";
	char *LOCAL_TYPE_NAME = "VARCHAR";


	TypeInfo[1].PRECISION = PRECISION;
	TypeInfo[2].PRECISION = PRECISION;

	TypeInfo[14].TYPE_NAME = TYPE_NAME;
	TypeInfo[14].DATA_TYPE = DATA_TYPE;
	TypeInfo[14].PRECISION = PRECISION;
	TypeInfo[14].CREATE_PARAMS = CREATE_PARAMS;
	TypeInfo[14].LOCAL_TYPE_NAME = LOCAL_TYPE_NAME;
}

//================Modified for Longvarhcar Changes===========================================================

	LogMsg(LINEBEFORE+SHORTTIMESTAMP,"Begin testing API =>SQLGetTypeInfo30 | SQLGetTypeInfo3 | gettypeiR18.c\n");

	TEST_INIT;
	TESTCASE_BEGIN("Setup for SQLGetTypeInfo tests for ODBC 3.0\n");

	if(!FullConnectWithOptions(pTestInfo, CONNECT_ODBC_VERSION_3))
	{
		LogMsg(NONE,"Unable to connect\n");
		TEST_FAILED;
		TEST_RETURN;
	}

  	/* Set up some local variables to save on typing in longer ones */
	henv = pTestInfo->henv;
	hdbc = pTestInfo->hdbc;
 	hstmt = (SQLHANDLE)pTestInfo->hstmt;
   	
	returncode = SQLAllocHandle(SQL_HANDLE_STMT, (SQLHANDLE)hdbc, &hstmt);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLAllocHandle")){
		LogAllErrorsVer3(henv,hdbc,hstmt);
		TEST_FAILED;
		TEST_RETURN;
	}
	
	TESTCASE_END; // end of setup

//=========================================================================================
					 
/*	if (MX_MP_SPECIFIC == MX_SPECIFIC)
		END_LOOP = SQL_BINARY;
	else if (MX_MP_SPECIFIC == MP_SPECIFIC)
		END_LOOP = 999;
	else
	{
		LogMsg(ERRMSG,"gettypeinfo test failed.\n");
		TEST_RETURN;
	}
*/	
	END_LOOP = 999;
	j = 0;
	while (TypeInfo[j].DATA_TYPE != END_LOOP) 
	{
		sprintf(Heading,"Test Positive functionality of SQLGetTypeInfo for data type: %s\n",
									SQLTypeToChar(TypeInfo[j].DATA_TYPE,TempBuf));
		TESTCASE_BEGIN(Heading);

		returncode = SQLGetTypeInfo(hstmt,TypeInfo[j].DATA_TYPE);
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLGetTypeInfo"))
		{
			TEST_FAILED;
			LogAllErrors(henv,hdbc,hstmt);
		}
		else
		{
			if (TypeInfo[j].DATA_TYPE != 0) 
			{ 
				strcpy(oTYPE_NAME,"");
				oDATA_TYPE = 0; 
				oPRECISION = 0;
				strcpy(oLITERAL_PREFIX,"");
				strcpy(oLITERAL_SUFFIX,"");
				strcpy(oCREATE_PARAMS,"");
				oNULLABLE = 0;
				oCASE_SENSITIVE = 0;
				oSEARCHABLE = 0;
				oUNSIGNED_ATTRIBUTE = 0;
				oMONEY = 0;
				oAUTO_INCREMENT = 0;
				strcpy(oLOCAL_TYPE_NAME,"");
				oMINIMUM_SCALE = 0;
				oMAXIMUM_SCALE = 0;
				returncode = SQLBindCol(hstmt,1,SQL_C_CHAR,oTYPE_NAME,TYPE_LEN,&oTYPE_NAMElen);
				if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol"))
				{
						LogAllErrors(henv,hdbc,hstmt);
						TEST_FAILED;
				}
				returncode = SQLBindCol(hstmt,2,SQL_C_SHORT,&oDATA_TYPE,0,&oDATA_TYPElen);
				if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol"))
				{
						LogAllErrors(henv,hdbc,hstmt);
						TEST_FAILED;
				}
				returncode = SQLBindCol(hstmt,3,SQL_C_LONG,&oPRECISION,0,&oPRECISIONlen);
				if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol"))
				{
						LogAllErrors(henv,hdbc,hstmt);
						TEST_FAILED;
				}
				returncode = SQLBindCol(hstmt,4,SQL_C_CHAR,oLITERAL_PREFIX,TYPE_LEN,&oLITERAL_PREFIXlen);
				if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol"))
				{
						LogAllErrors(henv,hdbc,hstmt);
						TEST_FAILED;
				}
				returncode = SQLBindCol(hstmt,5,SQL_C_CHAR,oLITERAL_SUFFIX,TYPE_LEN,&oLITERAL_SUFFIXlen);
				if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol"))
				{
						LogAllErrors(henv,hdbc,hstmt);
						TEST_FAILED;
				}
				returncode = SQLBindCol(hstmt,6,SQL_C_CHAR,oCREATE_PARAMS,TYPE_LEN,&oCREATE_PARAMSlen);
				if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol"))
				{
						LogAllErrors(henv,hdbc,hstmt);
						TEST_FAILED;
				}
				returncode = SQLBindCol(hstmt,7,SQL_C_SHORT,&oNULLABLE,0,&oNULLABLElen);
				if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol"))
				{
						LogAllErrors(henv,hdbc,hstmt);
						TEST_FAILED;
				}
				returncode = SQLBindCol(hstmt,8,SQL_C_SHORT,&oCASE_SENSITIVE,0,&oCASE_SENSITIVElen);
				if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol"))
				{
						LogAllErrors(henv,hdbc,hstmt);
						TEST_FAILED;
				}
				returncode = SQLBindCol(hstmt,9,SQL_C_SHORT,&oSEARCHABLE,0,&oSEARCHABLElen);
				if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol"))
				{
						LogAllErrors(henv,hdbc,hstmt);
						TEST_FAILED;
				}
				returncode = SQLBindCol(hstmt,10,SQL_C_SHORT,&oUNSIGNED_ATTRIBUTE,0,&oUNSIGNED_ATTRIBUTElen);
				if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol"))
				{
						LogAllErrors(henv,hdbc,hstmt);
						TEST_FAILED;
				}
				returncode = SQLBindCol(hstmt,11,SQL_C_SHORT,&oMONEY,0,&oMONEYlen);
				if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol"))
				{
						LogAllErrors(henv,hdbc,hstmt);
						TEST_FAILED;
				}
				returncode = SQLBindCol(hstmt,12,SQL_C_SHORT,&oAUTO_INCREMENT,0,&oAUTO_INCREMENTlen);
				if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol"))
				{
						LogAllErrors(henv,hdbc,hstmt);
						TEST_FAILED;
				}
				returncode = SQLBindCol(hstmt,13,SQL_C_CHAR,oLOCAL_TYPE_NAME,TYPE_LEN,&oLOCAL_TYPE_NAMElen);
				if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol"))
				{
						LogAllErrors(henv,hdbc,hstmt);
						TEST_FAILED;
				}
				returncode = SQLBindCol(hstmt,14,SQL_C_SHORT,&oMINIMUM_SCALE,0,&oMINIMUM_SCALElen);
				if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol"))
				{
						LogAllErrors(henv,hdbc,hstmt);
						TEST_FAILED;
				}
				returncode = SQLBindCol(hstmt,15,SQL_C_SHORT,&oMAXIMUM_SCALE,0,&oMAXIMUM_SCALElen);
				if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol"))
				{
						LogAllErrors(henv,hdbc,hstmt);
						TEST_FAILED;
				}
				returncode = SQLFetch(hstmt);
				if(!CHECKRC(SQL_SUCCESS,returncode,"SQLFetch"))
				{
					TEST_FAILED;
					LogAllErrors(henv,hdbc,hstmt);
				}
				else
				{
					LogMsg(NONE,"Comparing results\n");
					if ((_stricmp(TypeInfo[j].TYPE_NAME,oTYPE_NAME) == 0)
							&& (TypeInfo[j].DATA_TYPE == oDATA_TYPE)
							&& (TypeInfo[j].PRECISION == oPRECISION)
							&& (_stricmp(TypeInfo[j].LITERAL_PREFIX,oLITERAL_PREFIX) == 0)
							&& (_stricmp(TypeInfo[j].LITERAL_SUFFIX,oLITERAL_SUFFIX) == 0)
							&& (_stricmp(TypeInfo[j].CREATE_PARAMS,oCREATE_PARAMS) == 0)
							&& (TypeInfo[j].NULLABLE == oNULLABLE)
							&& (TypeInfo[j].CASE_SENSITIVE == oCASE_SENSITIVE)
							&& (TypeInfo[j].SEARCHABLE == oSEARCHABLE)
							&& (TypeInfo[j].UNSIGNED_ATTRIBUTE == oUNSIGNED_ATTRIBUTE)
							&& (TypeInfo[j].MONEY == oMONEY)
							&& (TypeInfo[j].AUTO_INCREMENT == oAUTO_INCREMENT)
							&& (_stricmp(TypeInfo[j].LOCAL_TYPE_NAME,oLOCAL_TYPE_NAME) == 0)
							&& (TypeInfo[j].MINIMUM_SCALE == oMINIMUM_SCALE)
							&& (TypeInfo[j].MAXIMUM_SCALE == oMAXIMUM_SCALE))
					{
						//LogMsg(NONE,"Data Type Name actual: %s and expected: %s are matched\n",oTYPE_NAME,TypeInfo[j].TYPE_NAME);
						//LogMsg(NONE,"Data Type actual: %d and expected: %d are matched\n",oDATA_TYPE,TypeInfo[j].DATA_TYPE);
						//LogMsg(NONE,"Precision actual: %d and expected: %d are matched\n",oPRECISION,TypeInfo[j].PRECISION);
						//LogMsg(NONE,"Literal Prefix actual: %s and expected: %s are matched\n",oLITERAL_PREFIX,TypeInfo[j].LITERAL_PREFIX);
						//LogMsg(NONE,"Literal Suffix actual: %s and expected: %s are matched\n",oLITERAL_SUFFIX,TypeInfo[j].LITERAL_SUFFIX);
						//LogMsg(NONE,"Create Params actual: %s and expected: %s are matched\n",oCREATE_PARAMS,TypeInfo[j].CREATE_PARAMS);
						//LogMsg(NONE,"Nullable actual: %d and expected: %d are matched\n",oNULLABLE,TypeInfo[j].NULLABLE);
						//LogMsg(NONE,"Case sensitive actual: %d and expected: %d are matched\n",oCASE_SENSITIVE,TypeInfo[j].CASE_SENSITIVE);
						//LogMsg(NONE,"Searchable actual: %d and expected: %d are matched\n",oSEARCHABLE,TypeInfo[j].SEARCHABLE);
						//LogMsg(NONE,"Unsigned attribute actual: %d and expected: %d are matched\n",oUNSIGNED_ATTRIBUTE,TypeInfo[j].UNSIGNED_ATTRIBUTE);
						//LogMsg(NONE,"Money actual: %d and expected: %d are matched\n",oMONEY,TypeInfo[j].MONEY);
						//LogMsg(NONE,"Auto Increment actual: %d and expected: %d are matched\n",oAUTO_INCREMENT,TypeInfo[j].AUTO_INCREMENT);
						//LogMsg(NONE,"Local Type name actual: %s and expected: %s are matched\n",oLOCAL_TYPE_NAME,TypeInfo[j].LOCAL_TYPE_NAME);
						//LogMsg(NONE,"Minimum Scale actual: %d and expected: %d are matched\n",oMINIMUM_SCALE,TypeInfo[j].MINIMUM_SCALE);
						//LogMsg(NONE,"Maximum Scale actual: %d and expected: %d are matched\n",oMAXIMUM_SCALE,TypeInfo[j].MAXIMUM_SCALE);
					}	
					else
					{
						TEST_FAILED;	
						if (_stricmp(TypeInfo[j].TYPE_NAME,oTYPE_NAME) != 0)
							LogMsg(ERRMSG,"Data Type Name actual: %s and expected: %s are not matched\n",oTYPE_NAME,TypeInfo[j].TYPE_NAME);
						if (TypeInfo[j].DATA_TYPE != oDATA_TYPE)
							LogMsg(ERRMSG,"Data Type actual: %d and expected: %d are not matched\n",oDATA_TYPE,TypeInfo[j].DATA_TYPE);
						if (TypeInfo[j].PRECISION != oPRECISION)
							LogMsg(ERRMSG,"Precision actual: %d and expected: %d are not matched\n",oPRECISION,TypeInfo[j].PRECISION);
						if (_stricmp(TypeInfo[j].LITERAL_PREFIX,oLITERAL_PREFIX) != 0)
							LogMsg(ERRMSG,"Literal Prefix actual: %s and expected: %s are not matched\n",oLITERAL_PREFIX,TypeInfo[j].LITERAL_PREFIX);
						if (_stricmp(TypeInfo[j].LITERAL_SUFFIX,oLITERAL_SUFFIX) != 0)
							LogMsg(ERRMSG,"Literal Suffix actual: %s and expected: %s are not matched\n",oLITERAL_SUFFIX,TypeInfo[j].LITERAL_SUFFIX);
						if (_stricmp(TypeInfo[j].CREATE_PARAMS,oCREATE_PARAMS) != 0)
							LogMsg(ERRMSG,"Create Params actual: %s and expected: %s are not matched\n",oCREATE_PARAMS,TypeInfo[j].CREATE_PARAMS);
						if (TypeInfo[j].NULLABLE != oNULLABLE)
							LogMsg(ERRMSG,"Nullable actual: %d and expected: %d are not matched\n",oNULLABLE,TypeInfo[j].NULLABLE);
						if (TypeInfo[j].CASE_SENSITIVE != oCASE_SENSITIVE)
							LogMsg(ERRMSG,"Case sensitive actual: %d and expected: %d are not matched\n",oCASE_SENSITIVE,TypeInfo[j].CASE_SENSITIVE);
						if (TypeInfo[j].SEARCHABLE != oSEARCHABLE)
							LogMsg(ERRMSG,"Searchable actual: %d and expected: %d are not matched\n",oSEARCHABLE,TypeInfo[j].SEARCHABLE);
						if (TypeInfo[j].UNSIGNED_ATTRIBUTE != oUNSIGNED_ATTRIBUTE)
							LogMsg(ERRMSG,"Unsigned attribute actual: %d and expected: %d are not matched\n",oUNSIGNED_ATTRIBUTE,TypeInfo[j].UNSIGNED_ATTRIBUTE);
						if (TypeInfo[j].MONEY != oMONEY)
							LogMsg(ERRMSG,"Money actual: %d and expected: %d are not matched\n",oMONEY,TypeInfo[j].MONEY);
						if (TypeInfo[j].AUTO_INCREMENT != oAUTO_INCREMENT)
							LogMsg(ERRMSG,"Auto Increment actual: %d and expected: %d are not matched\n",oAUTO_INCREMENT,TypeInfo[j].AUTO_INCREMENT);
						if (_stricmp(TypeInfo[j].LOCAL_TYPE_NAME,oLOCAL_TYPE_NAME) != 0)
							LogMsg(ERRMSG,"Local Type name actual: %s and expected: %s are not matched\n",oLOCAL_TYPE_NAME,TypeInfo[j].LOCAL_TYPE_NAME);
						if (TypeInfo[j].MINIMUM_SCALE != oMINIMUM_SCALE)
							LogMsg(ERRMSG,"Minimum Scale actual: %d and expected: %d are not matched\n",oMINIMUM_SCALE,TypeInfo[j].MINIMUM_SCALE);
						if (TypeInfo[j].MAXIMUM_SCALE != oMAXIMUM_SCALE)
							LogMsg(ERRMSG,"Maximum Scale actual: %d and expected: %d are not matched\n",oMAXIMUM_SCALE,TypeInfo[j].MAXIMUM_SCALE);
					}
				} 					
			}
		}
		TESTCASE_END;
		SQLFreeStmt(hstmt,SQL_CLOSE);	// This is a bug this should be after the inner for loop.
		j++;
	} 															
	
//==========================================================================================
	
	TESTCASE_BEGIN("SQLGetTypeInfo: Negative test for invalid data type\n");

	fSqlType1 = 50;
	returncode = SQLGetTypeInfo(hstmt,fSqlType1);
	if(!CHECKRC(SQL_ERROR,returncode,"SQLGetTypeInfo"))
	{
		TEST_FAILED;
		LogAllErrors(henv,hdbc,hstmt);
	}
	TESTCASE_END;

//=========================================================================================

	sprintf(Heading,"SQLGetTypeInfo: Negative test with invalid handle\n");
	TESTCASE_BEGIN(Heading);

	hstmt = (SQLHANDLE)NULL;
	fSqlType1 = 1;
	returncode = SQLGetTypeInfo(hstmt,fSqlType1);
	if(!CHECKRC(SQL_INVALID_HANDLE,returncode,"SQLGetTypeInfo"))
	{
		TEST_FAILED;
		LogAllErrors(henv,hdbc,hstmt);
	}
	TESTCASE_END;

//=========================================================================================

	FullDisconnect3(pTestInfo);
	LogMsg(SHORTTIMESTAMP+LINEAFTER,"End testing API => SQLGetTypeInfo.\n");
	TEST_RETURN;
}
Beispiel #22
0
/*
---------------------------------------------------------
   TestSQLNumResultsCol
---------------------------------------------------------
*/
PassFail TestSQLNumResultCols(TestInfo *pTestInfo)
{                  
	TEST_DECLARE;
  	TCHAR			Heading[MAX_STRING_SIZE];
	RETCODE			returncode;
	SQLHANDLE 		henv;
 	SQLHANDLE 		hdbc;
 	SQLHANDLE		hstmt;
	SWORD			col;
	TCHAR			*ExecDirStr[] = {_T("--"),_T("--"),_T("--"),_T("--"),_T("--"),_T("--"),_T("--"),_T("--"),_T("--"),_T("--"),_T("--"),_T("--"),_T("--"),_T("--"),_T("--"),_T("--"),_T("--"),_T("--"),_T("--"),_T("--")};
	TCHAR			*TestCase[] = {
						_T("after preparing stmt "),
						_T("after preparing & executing stmt "),
						_T("after preparing, executing & fetching stmt "),
						_T("after execdirect stmt "),
						_T("after execdirect & fetching stmt "),
						_T("after preparing param stmt "),
						_T("after preparing & binding stmt "),
						_T("after preparing, binding & executing stmt "),
						_T("after preparing, binding, executing & fetching stmt ")
					};
	int				lend = 9, iend = 5;
	SQLUSMALLINT	i = 0, l = 0;
	int				expcol[] = {1,2,6,9,2};
	SQLLEN			cbIn = SQL_NTS;

//===========================================================================================================
	var_list_t *var_list;
	var_list = load_api_vars(_T("SQLNumResultCols"), charset_file);
	if (var_list == NULL) return FAILED;

	ExecDirStr[0] = var_mapping(_T("SQLNumResultCols_ExecDirStr_0"), var_list);
	ExecDirStr[1] = var_mapping(_T("SQLNumResultCols_ExecDirStr_1"), var_list);
	ExecDirStr[2] = var_mapping(_T("SQLNumResultCols_ExecDirStr_2"), var_list);
	ExecDirStr[3] = var_mapping(_T("SQLNumResultCols_ExecDirStr_3"), var_list);
	ExecDirStr[4] = var_mapping(_T("SQLNumResultCols_ExecDirStr_4"), var_list);
	ExecDirStr[5] = var_mapping(_T("SQLNumResultCols_ExecDirStr_5"), var_list);
	ExecDirStr[6] = var_mapping(_T("SQLNumResultCols_ExecDirStr_6"), var_list);
	ExecDirStr[7] = var_mapping(_T("SQLNumResultCols_ExecDirStr_7"), var_list);
	ExecDirStr[8] = var_mapping(_T("SQLNumResultCols_ExecDirStr_8"), var_list);
	ExecDirStr[9] = var_mapping(_T("SQLNumResultCols_ExecDirStr_9"), var_list);
	ExecDirStr[10] = var_mapping(_T("SQLNumResultCols_ExecDirStr_10"), var_list);
	ExecDirStr[11] = var_mapping(_T("SQLNumResultCols_ExecDirStr_11"), var_list);
	ExecDirStr[12] = var_mapping(_T("SQLNumResultCols_ExecDirStr_12"), var_list);
	ExecDirStr[13] = var_mapping(_T("SQLNumResultCols_ExecDirStr_13"), var_list);
	ExecDirStr[14] = var_mapping(_T("SQLNumResultCols_ExecDirStr_14"), var_list);
	ExecDirStr[15] = var_mapping(_T("SQLNumResultCols_ExecDirStr_15"), var_list);
	ExecDirStr[16] = var_mapping(_T("SQLNumResultCols_ExecDirStr_16"), var_list);
	ExecDirStr[17] = var_mapping(_T("SQLNumResultCols_ExecDirStr_17"), var_list);
	ExecDirStr[18] = var_mapping(_T("SQLNumResultCols_ExecDirStr_18"), var_list);
	ExecDirStr[19] = var_mapping(_T("SQLNumResultCols_ExecDirStr_19"), var_list);

//===========================================================================================================

	LogMsg(LINEBEFORE+SHORTTIMESTAMP,_T("Begin testing API =>SQLNumResultcols.\n"));

	TEST_INIT;
	   
	TESTCASE_BEGIN("Setup for SQLNumResultCols tests\n");

	if(!FullConnect(pTestInfo)){
		LogMsg(NONE,_T("Unable to connect\n"));
		TEST_FAILED;
		TEST_RETURN;
		}

	henv = pTestInfo->henv;
 	hdbc = pTestInfo->hdbc;
 	hstmt = (SQLHANDLE)pTestInfo->hstmt;
   	
	returncode = SQLAllocStmt((SQLHANDLE)hdbc, &hstmt);	
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLAllocStmt")){
		LogAllErrors(henv,hdbc,hstmt);
		TEST_FAILED;
		TEST_RETURN;
		}
	TESTCASE_END; // end of setup

	for (l = 0; l < lend; l++){
		for (i = 0; i < iend; i++){
			//==================================================================================
			_stprintf(Heading,_T("Test Positive Functionality of SQLNumResultCols "));
			_tcscat(Heading, TestCase[l]);
			_tcscat(Heading, ExecDirStr[i+iend+iend+iend]);
			_tcscat(Heading, _T("\n"));
			TESTCASE_BEGINW(Heading);
			if ((i != (iend-1)) && (l < 5)){
				SQLExecDirect(hstmt,(SQLTCHAR*)ExecDirStr[i],SQL_NTS); /* cleanup */
				returncode = SQLExecDirect(hstmt,(SQLTCHAR*)ExecDirStr[i+iend],SQL_NTS); /* create table */
				if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect")){
					LogAllErrors(henv,hdbc,hstmt);
					TEST_FAILED;
					}
				else{
					returncode = SQLExecDirect(hstmt,(SQLTCHAR*)ExecDirStr[i+iend+iend],SQL_NTS); /* insert into table */
					if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect")){
						LogAllErrors(henv,hdbc,hstmt);
						TEST_FAILED;
						}
					else{
						switch( l ) {
							case 0:
								returncode = SQLPrepare(hstmt,(SQLTCHAR*)ExecDirStr[i+iend+iend+iend], SQL_NTS);
								if(!CHECKRC(SQL_SUCCESS,returncode,"SQLPrepare")){
									LogAllErrors(henv,hdbc,hstmt);
									TEST_FAILED;
									}
								break;
							case 1 :
								returncode = SQLPrepare(hstmt,(SQLTCHAR*)ExecDirStr[i+iend+iend+iend], SQL_NTS);
								if(!CHECKRC(SQL_SUCCESS,returncode,"SQLPrepare")){
									LogAllErrors(henv,hdbc,hstmt);
									TEST_FAILED;
									}
								else{
									returncode = SQLExecute(hstmt);
									if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecute")){
										LogAllErrors(henv,hdbc,hstmt);
										TEST_FAILED;
										}
									}
								break;
							case 2 :
								returncode = SQLPrepare(hstmt,(SQLTCHAR*)ExecDirStr[i+iend+iend+iend], SQL_NTS);
								if(!CHECKRC(SQL_SUCCESS,returncode,"SQLPrepare")){
									LogAllErrors(henv,hdbc,hstmt);
									TEST_FAILED;
									}
								else{
									returncode = SQLExecute(hstmt);
									if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecute")){
										LogAllErrors(henv,hdbc,hstmt);
										TEST_FAILED;
										}
									else{
										returncode = SQLFetch(hstmt);
										if(!CHECKRC(SQL_SUCCESS,returncode,"SQLFetch")){
											LogAllErrors(henv,hdbc,hstmt);
											TEST_FAILED;
											}
										}
									}
								break;
							case 3 :
								returncode = SQLExecDirect(hstmt,(SQLTCHAR*)ExecDirStr[i+iend+iend+iend], SQL_NTS);
								if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect")){
									LogAllErrors(henv,hdbc,hstmt);
									TEST_FAILED;
									}
								break;
							case 4 :
								returncode = SQLExecDirect(hstmt,(SQLTCHAR*)ExecDirStr[i+iend+iend+iend], SQL_NTS);
								if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect")){
									LogAllErrors(henv,hdbc,hstmt);
									TEST_FAILED;
									}
								else{
									returncode = SQLFetch(hstmt);
									if(!CHECKRC(SQL_SUCCESS,returncode,"SQLFetch")){
										LogAllErrors(henv,hdbc,hstmt);
										TEST_FAILED;
										}
									}
								break;
							}
						if (returncode == SQL_SUCCESS){
							returncode = SQLNumResultCols(hstmt, &col);
							if(!CHECKRC(SQL_SUCCESS,returncode,"SQLNumResultCols")){
								LogAllErrors(henv,hdbc,hstmt);
								TEST_FAILED;
								}
							if (col == expcol[i])
								{
									LogMsg(NONE,_T("expect: %d and actual: %d are matched\n"),expcol[i], col);
								}	
							else
								{
									TEST_FAILED;	
									LogMsg(NONE,_T("expect: %d and actual: %d are not matched\n"),expcol[i], col);
								}
							}
							SQLFreeStmt(hstmt,SQL_CLOSE);
							SQLExecDirect(hstmt,(SQLTCHAR*) ExecDirStr[i],SQL_NTS); /* cleanup */
						}
					}
				}
			else if ((i == (iend-1)) && (l >= 5)){
				SQLExecDirect(hstmt,(SQLTCHAR*)ExecDirStr[i],SQL_NTS); /* cleanup */
				returncode = SQLExecDirect(hstmt,(SQLTCHAR*)ExecDirStr[i+iend],SQL_NTS); /* create table */
				if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect")){
					LogAllErrors(henv,hdbc,hstmt);
					TEST_FAILED;
					}
				else{
					returncode = SQLExecDirect(hstmt,(SQLTCHAR*)ExecDirStr[i+iend+iend],SQL_NTS); /* insert into table */
					if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect")){
						LogAllErrors(henv,hdbc,hstmt);
						TEST_FAILED;
						}
					else{
						switch( l ){
							case 5 :
								returncode = SQLPrepare(hstmt,(SQLTCHAR*)ExecDirStr[i+iend+iend+iend], SQL_NTS);
								if(!CHECKRC(SQL_SUCCESS,returncode,"SQLPrepare")){
									LogAllErrors(henv,hdbc,hstmt);
									TEST_FAILED;
									}
								break;
							case 6 :
								returncode = SQLPrepare(hstmt,(SQLTCHAR*)ExecDirStr[i+iend+iend+iend], SQL_NTS);
								if(!CHECKRC(SQL_SUCCESS,returncode,"SQLPrepare")){
									LogAllErrors(henv,hdbc,hstmt);
									TEST_FAILED;
									}
								else{
									returncode = SQLBindParameter(hstmt,1,SQL_PARAM_INPUT,SQL_C_TCHAR,SQL_INTEGER,0,0,(SQLPOINTER)_T("10"),300,&cbIn);
									if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindparameter")){
										LogAllErrors(henv,hdbc,hstmt);
										TEST_FAILED;
										}
									else{
										returncode = SQLBindParameter(hstmt,2,SQL_PARAM_INPUT,SQL_C_TCHAR,SQL_INTEGER,0,0,(SQLPOINTER)_T("20"),300,&cbIn);
										if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindParameter")){
											LogAllErrors(henv,hdbc,hstmt);
											TEST_FAILED;
											}
										}
									}
								break;
							case 7 :
								returncode = SQLPrepare(hstmt,(SQLTCHAR*)ExecDirStr[i+iend+iend+iend], SQL_NTS);
								if(!CHECKRC(SQL_SUCCESS,returncode,"SQLPrepare")){
									LogAllErrors(henv,hdbc,hstmt);
									TEST_FAILED;
									}
								else{
									returncode = SQLBindParameter(hstmt,1,SQL_PARAM_INPUT,SQL_C_TCHAR,SQL_INTEGER,0,0,(SQLPOINTER)_T("10"),300,&cbIn);
									if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindparameter")){
										LogAllErrors(henv,hdbc,hstmt);
										TEST_FAILED;
										}
									else{
										returncode = SQLBindParameter(hstmt,2,SQL_PARAM_INPUT,SQL_C_TCHAR,SQL_INTEGER,0,0,(SQLPOINTER)_T("20"),300,&cbIn);
										if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindParameter")){
											LogAllErrors(henv,hdbc,hstmt);
											TEST_FAILED;
											}
										else{
											returncode = SQLExecute(hstmt);
											if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecute")){
												LogAllErrors(henv,hdbc,hstmt);
												TEST_FAILED;
												}
											}
										}
									}
								break;
						    case 8 :
								returncode = SQLPrepare(hstmt,(SQLTCHAR*)ExecDirStr[i+iend+iend+iend], SQL_NTS);
								if(!CHECKRC(SQL_SUCCESS,returncode,"SQLPrepare")){
									LogAllErrors(henv,hdbc,hstmt);
									TEST_FAILED;
									}
								else{
									returncode = SQLBindParameter(hstmt,1,SQL_PARAM_INPUT,SQL_C_TCHAR,SQL_INTEGER,0,0,(SQLPOINTER)_T("10"),300,&cbIn);
									if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindparameter")){
										LogAllErrors(henv,hdbc,hstmt);
										TEST_FAILED;
										}
									else{
										returncode = SQLBindParameter(hstmt,2,SQL_PARAM_INPUT,SQL_C_TCHAR,SQL_INTEGER,0,0,(SQLPOINTER)_T("20"),300,&cbIn);
										if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindParameter")){
											LogAllErrors(henv,hdbc,hstmt);
											TEST_FAILED;
											}
										else{
											returncode = SQLExecute(hstmt);
											if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecute")){
												LogAllErrors(henv,hdbc,hstmt);
												TEST_FAILED;
												}
											else{
												returncode = SQLFetch(hstmt);
												if(!CHECKRC(SQL_SUCCESS,returncode,"SQLFetch")){
													LogAllErrors(henv,hdbc,hstmt);
													TEST_FAILED;
													}
												}
											}
										}
									}
								break;
							}
						if (returncode == SQL_SUCCESS){
								returncode = SQLNumResultCols(hstmt, &col);
								if(!CHECKRC(SQL_SUCCESS,returncode,"SQLNumResultCols"))
								{
									TEST_FAILED;
									LogAllErrors(henv,hdbc,hstmt);
								}
								if (col == expcol[i])
								{
									LogMsg(NONE,_T("expect: %d and actual: %d are matched\n"),expcol[i], col);
								}	
								else
								{
									TEST_FAILED;	
									LogMsg(NONE,_T("expect: %d and actual: %d are not matched\n"),expcol[i], col);
								}
							}
							SQLFreeStmt(hstmt,SQL_CLOSE);
							SQLExecDirect(hstmt,(SQLTCHAR*) ExecDirStr[i],SQL_NTS); /* cleanup */
						}
					}
				}
			TESTCASE_END;
			} /* iend loop */
		} /* lend loop */
	FullDisconnect(pTestInfo);
	LogMsg(SHORTTIMESTAMP+LINEAFTER,_T("End testing API => SQLNumResultcols.\n"));
	free_list(var_list);
	TEST_RETURN;
}
Beispiel #23
0
/*
---------------------------------------------------------
   TestSQLGetDescRec
---------------------------------------------------------
*/
PassFail TestMXSQLGetDescRec(TestInfo *pTestInfo)
{   
	TEST_DECLARE;
	RETCODE				returncode;
	SQLHANDLE 			henv;
	SQLHANDLE 			hdbc;
	SQLHANDLE			hstmt, hstmt1;
	
	//Common input params to the apis
	SQLHDESC			hIrd, hImArd, hImIrd, hImApd, hImIpd, hExArd, hExApd;
	SWORD				RecNumber = 0;

	//SQLGetDescRec: params
	SQLHDESC			getDescRecHandle;				//input
	SWORD				getDescRecNumber;				//input
	TCHAR				getDescName[MAXLEN];		 
	SWORD				getNameMaxLength;				//input; MAXLEN = 100 : defined in Common.h
	SWORD				getDescNameActualLength;
	SQLSMALLINT			getDescType;
	SWORD				getDescIntervalCode;
	SQLLEN				getDescOctectLength; 
	SWORD				getDescPrecision;
	SWORD				getDescScale;
	SWORD				getDescNullable;

	//SQLSetDescRec: params
	SQLHDESC			setDescRecHandle;
	SQLSMALLINT			setDescRecNumber;
	SQLSMALLINT			setDescType;
	SQLSMALLINT			setDescIntervalCode;
	SQLINTEGER			setDescOctetLength;
	SQLSMALLINT			setDescPrecision;
	SQLSMALLINT			setDescScale;
	SQLPOINTER			setDescDataPtr;
	SQLLEN				setDescOctectLengthPtr; 
	SQLLEN				setDescIndicatorPtr; 

	TCHAR				setDescName[1];
	
	SQLINTEGER			setDescNullable = SQL_NULL_DATA;
	short int			i;

	// Template for a Descriptor record
	typedef struct {
	  //	TCHAR				DescName[MAXLEN];
	TCHAR				*DescName;
	short int			DescType;
	short int			DescDatetimeIntervalCode;
	short int			DescOctetLength;
	short int			DescPrecision;
	short int			DescScale;
	void*				DescDataPtr;
	short int			DescOctectLengthPtr;
	short int			DescIndicatorPtr;
	short int			DescNullable;
	}DescRec;

	DescRec TestDataAPD[DATA_ARR_LEN] = 
	{
	//APD
	//	DescName		Type				DatetimeIntervalCode	DescOctetLength		Precision	DescScale	DescDataPtr		OctectLengthPtr		IndicatorPtr				DescNullable
		{_T(""),			SQL_C_DEFAULT,				0,						0,				0,			0,			NULL,			0,				SQL_NULL_DATA,			SQL_NULLABLE_UNKNOWN },
		{_T(""),			SQL_C_TCHAR,					0,						80,				0,			0,			NULL,			0,				SQL_NULL_DATA,			SQL_NULLABLE_UNKNOWN },
		{_T(""),			SQL_C_TCHAR,					0,						300,			0,			0,			NULL,		SQL_NTS,			SQL_NULL_DATA,			SQL_NULLABLE_UNKNOWN },
		{_T(""),			SQL_C_NUMERIC,				0,						0,				0,			0,			NULL,		SQL_DATA_AT_EXEC,	SQL_NULL_DATA,			SQL_NULLABLE_UNKNOWN },
		{_T(""),			SQL_C_TYPE_TIMESTAMP,	SQL_CODE_TIMESTAMP,			0,				6,			1,			NULL,			0,				SQL_NULL_DATA,			SQL_NULLABLE_UNKNOWN },
		{_T(""),			SQL_C_INTERVAL_SECOND,	SQL_CODE_SECOND,			0,				2,			0,			NULL,			0,				SQL_NULL_DATA,			SQL_NULLABLE_UNKNOWN }
	};

	DescRec TestDataARD[DATA_ARR_LEN] =
	{
	//ARD
	//	DescName		Type				DatetimeIntervalCode	DescOctetLength		Precision	DescScale	DescDataPtr		OctectLengthPtr		IndicatorPtr				DescNullable
		{_T(""),			SQL_C_DEFAULT,				0,						0,				0,			0,			NULL,			0,				SQL_NULL_DATA,			SQL_NULLABLE_UNKNOWN },
		{_T(""),			SQL_C_TCHAR,					0,						80,				0,			0,			NULL,			0,				SQL_NULL_DATA,			SQL_NULLABLE_UNKNOWN },
		{_T(""),			SQL_C_TCHAR,					0,						300,			0,			0,			NULL,		SQL_NTS,			SQL_NULL_DATA,			SQL_NULLABLE_UNKNOWN },
		{_T(""),			SQL_C_NUMERIC,				0,						0,				0,			0,			NULL,		SQL_DATA_AT_EXEC,	SQL_NULL_DATA,			SQL_NULLABLE_UNKNOWN },
		{_T(""),			SQL_C_TYPE_TIMESTAMP,	SQL_CODE_TIMESTAMP,			0,				6,			1,			NULL,			0,				SQL_NULL_DATA,			SQL_NULLABLE_UNKNOWN },
		{_T(""),			SQL_C_INTERVAL_SECOND,	SQL_CODE_SECOND,			0,				2,			0,			NULL,			0,				SQL_NULL_DATA,			SQL_NULLABLE_UNKNOWN }
	};

	DescRec TestDataIPD[DATA_ARR_LEN] =
	{
	//IPD
	//	DescName		Type				DatetimeIntervalCode	DescOctetLength		Precision	DescScale	DescDataPtr		OctectLengthPtr		IndicatorPtr				DescNullable
		{_T(""),			SQL_C_DEFAULT,				0,						0,				0,			0,			0,				0,					0,					SQL_NULLABLE_UNKNOWN },
		{_T(""),			SQL_TCHAR,					0,						80,				0,			0,			NULL,			0,				SQL_NULL_DATA,			SQL_NULLABLE_UNKNOWN },
		{_T(""),			SQL_TCHAR,					0,						300,			0,			0,			NULL,		SQL_NTS,			SQL_NULL_DATA,			SQL_NULLABLE_UNKNOWN },
		{_T(""),			SQL_NUMERIC,				0,						0,				0,			0,			NULL,		SQL_DATA_AT_EXEC,	SQL_NULL_DATA,			SQL_NULLABLE_UNKNOWN },
		{_T(""),			SQL_TYPE_TIMESTAMP,		SQL_CODE_TIMESTAMP,			0,				6,			1,			0,				0,				SQL_NULL_DATA,			SQL_NULLABLE_UNKNOWN },
		{_T(""),			SQL_INTERVAL_SECOND,	SQL_CODE_SECOND,			0,				2,			0,			NULL,			0,				SQL_NULL_DATA,			SQL_NULLABLE_UNKNOWN }
	};

	DescRec TestDataIRD[DATA_ARR_LEN] =
	{
	//IRD can only be read
	//	DescName		Type				DatetimeIntervalCode	DescOctetLength		Precision	DescScale	DescDataPtr		OctectLengthPtr		IndicatorPtr				DescNullable
		{_T(""),			SQL_C_DEFAULT,				0,						0,				0,			0,			NULL,			0,				SQL_NULL_DATA,			SQL_NULLABLE_UNKNOWN },
		{_T(""),			SQL_C_TCHAR,					0,						80,				0,			0,			NULL,			0,				SQL_NULL_DATA,			SQL_NULLABLE_UNKNOWN },
		{_T(""),			SQL_C_TCHAR,					0,						300,			0,			0,			NULL,		SQL_NTS,			SQL_NULL_DATA,			SQL_NULLABLE_UNKNOWN },
		{_T(""),			SQL_C_NUMERIC,				0,						0,				0,			0,			NULL,		SQL_DATA_AT_EXEC,	SQL_NULL_DATA,			SQL_NULLABLE_UNKNOWN },
		{_T(""),			SQL_C_TIMESTAMP,		SQL_CODE_TIMESTAMP,			0,				6,			1,			NULL,			0,				SQL_NULL_DATA,			SQL_NULLABLE_UNKNOWN },
		{_T(""),			SQL_C_INTERVAL_SECOND,	SQL_CODE_SECOND,			0,				2,			0,			NULL,			0,				SQL_NULL_DATA,			SQL_NULLABLE_UNKNOWN }
	};
	_tcscpy(setDescName, _T(""));
// ================================================================================================================
//		begin common test setup 
//==================================================================================================================
	LogMsg(LINEBEFORE+SHORTTIMESTAMP,_T("Begin testing API => SQLSetDescRec and SQLGetDescRec.\n"));
	TEST_INIT;

	if(!FullConnectWithOptions(pTestInfo, CONNECT_ODBC_VERSION_3))
	{
		LogMsg(NONE,_T("Unable to connect\n"));
		TEST_FAILED;
		TEST_RETURN;
	}
	
	henv = pTestInfo->henv;
 	hdbc = pTestInfo->hdbc;

	returncode = SQLAllocHandle(SQL_HANDLE_STMT, (SQLHANDLE)hdbc, &hstmt);	
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLAllocHandle"))
	{
		LogAllErrorsVer3(henv,hdbc,hstmt);
		FullDisconnect(pTestInfo);
		TEST_FAILED;
		TEST_RETURN;
	}

	//Explicit APD
	//allocate an Explicit APD desc
	returncode = SQLAllocHandle(SQL_HANDLE_DESC, (SQLHANDLE)hdbc, &hExApd);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLAllocHandle to get explicit APD"))
	{
		LogAllErrorsVer3(henv,hdbc,hstmt);
		FullDisconnect(pTestInfo);
		TEST_FAILED;
		TEST_RETURN;
	}	

	//Explicit ARD
	returncode = SQLAllocHandle(SQL_HANDLE_DESC, (SQLHANDLE)hdbc, &hExArd);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLAllocHandle to get explicit ARD"))
	{
		LogAllErrorsVer3(henv,hdbc,hstmt);
		FullDisconnect(pTestInfo);
		TEST_FAILED;
		TEST_RETURN;
	}

//===============================================================================================================
//			Begin Testing:Positive Test for Implicit APD 
//===============================================================================================================	
	//Get Implicit APD handle
	returncode = SQLGetStmtAttr(hstmt, SQL_ATTR_APP_PARAM_DESC, &hImApd, 0, NULL);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLGetStmtAttr: get APD"))
	{
		LogAllErrorsVer3(henv,hdbc,hstmt);
		LogMsg(ERRMSG,_T("Cannot allocate descriptor: Aborting Implicit APD tests.\n"));
		TEST_FAILED;
		goto ExAPDtests;		// transfers control to the next set of tests
	}

	for (i = 0;i < DATA_ARR_LEN; i++)		// i = index to TestDataAPD
	{
		TESTCASE_BEGIN("Test the positive functionality of SQLSetDescRec and SQLGetDescRec for Implicit APD.\n");


		//set multiple Fields
		RecNumber = i + 1;		//increment the recnumber and thus set the next rec (change SQL_DESC_COUNT)
		
		setDescRecHandle		= hImApd ;
		setDescRecNumber		= RecNumber;
		setDescType				= TestDataAPD[i].DescType; 
		setDescIntervalCode		= TestDataAPD[i].DescDatetimeIntervalCode;
		setDescOctetLength		= TestDataAPD[i].DescOctetLength;	
		setDescPrecision		= TestDataAPD[i].DescPrecision;	
		setDescScale			= TestDataAPD[i].DescScale;	
		setDescDataPtr			= TestDataAPD[i].DescDataPtr;			
		setDescOctectLengthPtr	= TestDataAPD[i].DescOctectLengthPtr;			
		setDescIndicatorPtr		= TestDataAPD[i].DescIndicatorPtr;	

		/*LogMsg(NONE,_T("SQLSetDescRec(handle,%d,%d,%d,%d,%d,%d,%s,%d,%d)\n"),
											setDescRecNumber, 
											setDescType, 
											setDescIntervalCode, 
											setDescOctetLength , 
											setDescPrecision, 
											setDescScale, 
											setDescDataPtr,
											setDescOctectLengthPtr, 
											setDescIndicatorPtr);  */

		returncode = SQLSetDescRec(setDescRecHandle, setDescRecNumber, setDescType, setDescIntervalCode, setDescOctetLength , setDescPrecision, setDescScale, setDescDataPtr,&setDescOctectLengthPtr, &setDescIndicatorPtr);
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLSetDescRec "))
		{
			LogAllErrorsVer3(henv,hdbc,hstmt);
			LogMsg(ERRMSG,_T("SQLSetDescRec: positive tests for Implicit APD: TestDataAPD['%d'].\n"),i);
			//FullDisconnect(pTestInfo);
			TEST_FAILED;
			//TEST_RETURN;
			continue;
		}
		
		//Get the Implicit APD Descriptor 
		//LogMsg(SHORTTIMESTAMP,"SQLGetDescRec: test for Implicit APD.\n");
		LogMsg(NONE,_T("SQLSetDescRec / SQLGetDescRec: positive tests for Implicit APD.\n"));


		getDescRecHandle		= hImApd;					
		getDescRecNumber		= RecNumber;				
		getNameMaxLength		= MAXLEN;
		_tcscpy(getDescName	,_T(""));	//initialize
		setDescNullable			= TestDataAPD[i].DescNullable;

		returncode = SQLGetDescRec(getDescRecHandle, getDescRecNumber, (SQLTCHAR*)getDescName, getNameMaxLength, &getDescNameActualLength, &getDescType, &getDescIntervalCode, &getDescOctectLength, &getDescPrecision, &getDescScale, &getDescNullable);
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLGetDescRec"))
		{
			LogAllErrorsVer3(henv,hdbc,hstmt);
			LogMsg(ERRMSG,_T("SQLGetDescRec: positive tests for Implicit APD: TestDataAPD['%d'].\n"),i);
			//FullDisconnect(pTestInfo);
			TEST_FAILED;
			//TEST_RETURN;
			continue;
		}

		//begin checking  APD values ----------
		
		//check  SQL_DESC_NAME
		if (!(_tcscmp(getDescName, setDescName)))
		{
			LogMsg(NONE,_T("SQL_DESC_NAME value returned is '%s'\n"),getDescName);
		}
		else
		{
			TEST_FAILED;					
			LogMsg(ERRMSG, _T("expect SQL_DESC_NAME: '%s' and actual: '%s' are not matched\n"), setDescName,getDescName);
		}
		
		//check SQL_DESC_TYPE
		if (getDescType == setDescType)
		{
			LogMsg(NONE,_T("SQL_DESC_TYPE value returned is '%d'\n"),getDescType);
		}
		else
		{
			TEST_FAILED;					
			LogMsg(ERRMSG, _T("expect SQL_DESC_TYPE: '%d' and actual: '%d' are not matched\n"), setDescType, getDescType);
		}

		//check SQL_DESC_DATETIME_INTERVAL_CODE
		if (getDescIntervalCode == setDescIntervalCode)
		{
			LogMsg(NONE,_T("SQL_DESC_DATETIME_INTERVAL_CODE value returned is '%d'\n"),getDescIntervalCode);
		}
		else
		{
			TEST_FAILED;					
			LogMsg(ERRMSG, _T("expect SQL_DESC_DATETIME_INTERVAL_CODE: '%d' and actual: '%d' are not matched\n"), setDescIntervalCode, getDescIntervalCode);
		}
		//check SQL_DESC_OCTECT_LENGTH
		if (getDescOctectLength == setDescOctetLength)
		{
			LogMsg(NONE,_T("SQL_DESC_OCTECT_LENGTH value returned is '%d'\n"),getDescOctectLength);
		}
		else
		{
			TEST_FAILED;					
			LogMsg(ERRMSG, _T("expect SQL_DESC_OCTECT_LENGTH: '%d' and actual: '%d' are not matched\n"), setDescOctetLength,getDescOctectLength);
		}

		//check SQL_DESC_PRECISION
		if (getDescPrecision == setDescPrecision)
		{
			LogMsg(NONE,_T("SQL_DESC_PRECISION value returned is '%d'\n"),getDescPrecision);
		}
		else
		{
			TEST_FAILED;					
			LogMsg(ERRMSG, _T("expect SQL_DESC_PRECISION: '%d' and actual: '%d' are not matched\n"), setDescPrecision,getDescPrecision);
		}

		//check SQL_DESC_SCALE
		if (getDescScale == setDescScale)
		{
			LogMsg(NONE,_T("SQL_DESC_SCALE value returned is '%d'\n"),getDescScale);
		}
		else
		{
			TEST_FAILED;					
			LogMsg(ERRMSG, _T("expect SQL_DESC_SCALE: '%d' and actual: '%d' are not matched\n"), setDescScale,getDescScale);
		}

		//check SQL_DESCNULLABLE
		if (getDescNullable == setDescNullable)
		{
			LogMsg(NONE,_T("SQL_DESC_NULLABLE value returned is '%d'\n"),getDescNullable);
		}
		else
		{
			TEST_FAILED;					
			LogMsg(ERRMSG, _T("expect SQL_DESC_NULLABLE: '%d' and actual: '%d' are not matched\n"), setDescNullable, getDescNullable);
		}
		// end of checks 
		TESTCASE_END;

	} //end for loop; end of positive tests for APD
	 

//===============================================================================================================
//			Begin Testing:Positive Test for Explicit APD 
//===============================================================================================================
	ExAPDtests: ;		// beginning next set of tests
	
	//mark the beginning of tests in log file
	//LogMsg(SHORTTIMESTAMP, "Test the positive functionality of SQLSetDescRec and SQLGetDescRec for Explicit APD.\n");
	
	//Get Explicit APD handle
	returncode = SQLAllocHandle(SQL_HANDLE_DESC, (SQLHANDLE)hdbc, &hExApd);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLAllocHandle: get Explicit APD"))
	{
		LogAllErrorsVer3(henv,hdbc,hstmt);
		LogMsg(ERRMSG,_T("Cannot allocate descriptor: Aborting Explicit APD tests.\n"));
		TEST_FAILED;
		//TEST_RETURN;
		goto ARDtests;		// transfers control to the next set of tests
	}

	//associate with a statement
	returncode = SQLSetStmtAttr(hstmt, SQL_ATTR_APP_PARAM_DESC, (SQLPOINTER)hExApd, SQL_IS_POINTER);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLSetStmtAttr: explicit APD"))
	{
		LogAllErrorsVer3(henv,hdbc,hstmt);
		LogMsg(ERRMSG, _T("Cannot set Explicit APD for statement.\n"));
		TEST_FAILED;
	}

	setDescRecHandle = hExApd ;

	for (i = 0;i < DATA_ARR_LEN; i++)		// i = index to TestDataAPD
	{
		TESTCASE_BEGIN("Test the positive functionality of SQLSetDescRec and SQLGetDescRec for Explicit APD.\n");


		//set multiple Fields
		RecNumber = i + 1;		//increment the recnumber and thus set the next rec (change SQL_DESC_COUNT)
		

		setDescRecNumber		= RecNumber;
		setDescType				= TestDataAPD[i].DescType; 
		setDescIntervalCode		= TestDataAPD[i].DescDatetimeIntervalCode;
		setDescOctetLength		= TestDataAPD[i].DescOctetLength;	
		setDescPrecision		= TestDataAPD[i].DescPrecision;	
		setDescScale			= TestDataAPD[i].DescScale;	
		setDescDataPtr			= TestDataAPD[i].DescDataPtr;			
		setDescOctectLengthPtr	= TestDataAPD[i].DescOctectLengthPtr;			
		setDescIndicatorPtr		= TestDataAPD[i].DescIndicatorPtr;	


		/*LogMsg(NONE,_T("SQLSetDescRect(handle,%d,%d,%d,%d,%d,%d,%s,%d,%d)\n"),
									setDescRecNumber, 
									setDescType, 
									setDescIntervalCode, 
									setDescOctetLength , 
									setDescPrecision, 
									setDescScale, 
									setDescDataPtr,
									setDescOctectLengthPtr, 
									setDescIndicatorPtr);*/

		returncode = SQLSetDescRec(setDescRecHandle, setDescRecNumber, setDescType, setDescIntervalCode, setDescOctetLength , setDescPrecision, setDescScale, setDescDataPtr,&setDescOctectLengthPtr, &setDescIndicatorPtr);
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLSetDescRec"))
		{
			LogAllErrorsVer3(henv,hdbc,hstmt);
			LogMsg(ERRMSG,_T("SQLSetDescRec: positive tests for Explicit APD: TestDataAPD['%d'].\n"),i);
			TEST_FAILED;
			//TEST_RETURN;
			continue;
		}
		
			
		//Get the Explicit APD Descriptor 
		//LogMsg(SHORTTIMESTAMP,"SQLGetDescRec: test for Implicit APD.\n");
		LogMsg(NONE,_T("SQLSetDescRec / SQLGetDescRec: positive tests for Explicit APD.\n"));


		getDescRecHandle		= 	setDescRecHandle;					
		getDescRecNumber		= RecNumber;				
		getNameMaxLength		= MAXLEN;
		_tcscpy(getDescName	,_T(""));	//initialize		
		setDescNullable			= TestDataAPD[i].DescNullable;

		returncode = SQLGetDescRec(getDescRecHandle, getDescRecNumber, (SQLTCHAR*)getDescName, getNameMaxLength, &getDescNameActualLength, &getDescType, &getDescIntervalCode, &getDescOctectLength, &getDescPrecision, &getDescScale, &getDescNullable);
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLSetDescRec and SQLGetDescRec"))
		{
			LogAllErrorsVer3(henv,hdbc,hstmt);
			LogMsg(ERRMSG,_T("SQLGetDescRec: positive tests for Explicit APD: TestDataAPD['%d'].\n"),i);
			TEST_FAILED;
			continue;
		}

		//begin checking  APD values 
		
		//check  SQL_DESC_NAME
		if (!(_tcscmp(getDescName, setDescName)))
		{
			LogMsg(NONE,_T("SQL_DESC_NAME value returned is '%s'\n"),getDescName);
		}
		else
		{
			TEST_FAILED;					
			LogMsg(ERRMSG, _T("expect SQL_DESC_NAME: '%s' and actual: '%s' are not matched\n"), setDescName,getDescName);
		}
		
		//check SQL_DESC_TYPE
		if (getDescType == setDescType)
		{
			LogMsg(NONE,_T("SQL_DESC_TYPE value returned is '%d'\n"),getDescType);
		}
		else
		{
			TEST_FAILED;					
			LogMsg(ERRMSG, _T("expect SQL_DESC_TYPE: '%d' and actual: '%d' are not matched\n"), setDescType, getDescType);
		}

		//check SQL_DESC_DATETIME_INTERVAL_CODE
		if (getDescIntervalCode == setDescIntervalCode)
		{
			LogMsg(NONE,_T("SQL_DESC_DATETIME_INTERVAL_CODE value returned is '%d'\n"),getDescIntervalCode);
		}
		else
		{
			TEST_FAILED;					
			LogMsg(ERRMSG, _T("expect SQL_DESC_DATETIME_INTERVAL_CODE: '%d' and actual: '%d' are not matched\n"), setDescIntervalCode, getDescIntervalCode);
		}
		//check SQL_DESC_OCTECT_LENGTH
		if (getDescOctectLength == setDescOctetLength)
		{
			LogMsg(NONE,_T("SQL_DESC_OCTECT_LENGTH value returned is '%d'\n"),getDescOctectLength);
		}
		else
		{
			TEST_FAILED;					
			LogMsg(ERRMSG, _T("expect SQL_DESC_OCTECT_LENGTH: '%d' and actual: '%d' are not matched\n"), setDescOctetLength,getDescOctectLength);
		}

		//check SQL_DESC_PRECISION
		if (getDescPrecision == setDescPrecision)
		{
			LogMsg(NONE,_T("SQL_DESC_PRECISION value returned is '%d'\n"),getDescPrecision);
		}
		else
		{
			TEST_FAILED;					
			LogMsg(ERRMSG, _T("expect SQL_DESC_PRECISION: '%d' and actual: '%d' are not matched\n"), setDescPrecision,getDescPrecision);
		}

		//check SQL_DESC_SCALE
		if (getDescScale == setDescScale)
		{
			LogMsg(NONE,_T("SQL_DESC_SCALE value returned is '%d'\n"),getDescScale);
		}
		else
		{
			TEST_FAILED;					
			LogMsg(ERRMSG, _T("expect SQL_DESC_SCALE: '%d' and actual: '%d' are not matched\n"), setDescScale,getDescScale);
		}

		//check SQL_DESCNULLABLE
		if (getDescNullable == setDescNullable)
		{
			LogMsg(NONE,_T("SQL_DESC_NULLABLE value returned is '%d'\n"),getDescNullable);
		}
		else
		{
			TEST_FAILED;					
			LogMsg(ERRMSG, _T("expect SQL_DESC_NULLABLE: '%d' and actual: '%d' are not matched\n"), setDescNullable, getDescNullable);
		}
		// end of checks 


		
		TESTCASE_END;

	} //end for loop; end of positive tests for Explicit APD


	 
//===============================================================================================================
//			Begin Testing: Statement reverts to Implicit APD after freeing Explicit Descriptor
//===============================================================================================================
	
	//mark the beginning of tests in log file
	//LogMsg(SHORTTIMESTAMP, "SQLGetDescRec for Explicit-Implicit APD: statement reverts to implicit descriptor after explicit descriptor has been freed.\n");
	
	//free Explicit APD
	returncode = SQLFreeHandle(SQL_HANDLE_DESC, hExApd);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLFreeHandle (for APD)"))
	{
		LogAllErrorsVer3(henv,hdbc,hstmt);
		LogMsg(ERRMSG,_T("Cannot free explicit descriptor: Aborting Explicit-Implicit Descriptor tests.\n"));
		TEST_FAILED;
		goto ARDtests;		// transfers control to the next set of tests
	}

	//Use the previously allocated Implicit APD handle
	getDescRecHandle		= hImApd;

		TESTCASE_BEGIN("Test that the implicit descriptor get associated with statement after explicit descriptor has been freed.\n");


		//set multiple Fields
		i			= 0;
		RecNumber = i + 1;		//increment the recnumber and thus set the next rec (change SQL_DESC_COUNT)
		
		
		setDescRecNumber		= RecNumber;
		setDescType				= TestDataAPD[i].DescType; 
		setDescIntervalCode		= TestDataAPD[i].DescDatetimeIntervalCode;
		setDescOctetLength		= TestDataAPD[i].DescOctetLength;	
		setDescPrecision		= TestDataAPD[i].DescPrecision;	
		setDescScale			= TestDataAPD[i].DescScale;	
		setDescDataPtr			= TestDataAPD[i].DescDataPtr;			
		setDescOctectLengthPtr	= TestDataAPD[i].DescOctectLengthPtr;			
		setDescIndicatorPtr		= TestDataAPD[i].DescIndicatorPtr;	

			
		//Get the Implicit APD Descriptor 
		LogMsg(NONE,_T("SQLGetDescRec: tests for Explicit-Implicit Descriptor.\n"));
			
		getDescRecNumber		= RecNumber;				
		getNameMaxLength		= MAXLEN;
		_tcscpy(getDescName	,_T(""));	//initialize		
		setDescNullable			= TestDataAPD[i].DescNullable;

		returncode = SQLGetDescRec(getDescRecHandle, getDescRecNumber, (SQLTCHAR*)getDescName, getNameMaxLength, &getDescNameActualLength, &getDescType, &getDescIntervalCode, &getDescOctectLength, &getDescPrecision, &getDescScale, &getDescNullable);
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLGetDescRec"))
		{
			LogAllErrorsVer3(henv,hdbc,hstmt);
			LogMsg(ERRMSG,_T("SQLGetDescRec: tests for Explicit-Implicit APD: TestDataAPD['%d'].\n"),i);
			TEST_FAILED;
			//continue;
		}

		//begin checking  APD values ----------
		
		//check  SQL_DESC_NAME
		if (!(_tcscmp(getDescName, setDescName)))
		{
			LogMsg(NONE,_T("SQL_DESC_NAME value returned is '%s'\n"),getDescName);
		}
		else
		{
			TEST_FAILED;					
			LogMsg(ERRMSG, _T("expect SQL_DESC_NAME: '%s' and actual: '%s' are not matched\n"), setDescName,getDescName);
		}
		
		//check SQL_DESC_TYPE
		if (getDescType == setDescType)
		{
			LogMsg(NONE,_T("SQL_DESC_TYPE value returned is '%d'\n"),getDescType);
		}
		else
		{
			TEST_FAILED;					
			LogMsg(ERRMSG, _T("expect SQL_DESC_TYPE: '%d' and actual: '%d' are not matched\n"), setDescType, getDescType);
		}

		//check SQL_DESC_DATETIME_INTERVAL_CODE
		if (getDescIntervalCode == setDescIntervalCode)
		{
			LogMsg(NONE,_T("SQL_DESC_DATETIME_INTERVAL_CODE value returned is '%d'\n"),getDescIntervalCode);
		}
		else
		{
			TEST_FAILED;					
			LogMsg(ERRMSG, _T("expect SQL_DESC_DATETIME_INTERVAL_CODE: '%d' and actual: '%d' are not matched\n"), setDescIntervalCode, getDescIntervalCode);
		}
		//check SQL_DESC_OCTECT_LENGTH
		if (getDescOctectLength == setDescOctetLength)
		{
			LogMsg(NONE,_T("SQL_DESC_OCTECT_LENGTH value returned is '%d'\n"),getDescOctectLength);
		}
		else
		{
			TEST_FAILED;					
			LogMsg(ERRMSG, _T("expect SQL_DESC_OCTECT_LENGTH: '%d' and actual: '%d' are not matched\n"), setDescOctetLength,getDescOctectLength);
		}

		//check SQL_DESC_PRECISION
		if (getDescPrecision == setDescPrecision)
		{
			LogMsg(NONE,_T("SQL_DESC_PRECISION value returned is '%d'\n"),getDescPrecision);
		}
		else
		{
			TEST_FAILED;					
			LogMsg(ERRMSG, _T("expect SQL_DESC_PRECISION: '%d' and actual: '%d' are not matched\n"), setDescPrecision,getDescPrecision);
		}

		//check SQL_DESC_SCALE
		if (getDescScale == setDescScale)
		{
			LogMsg(NONE,_T("SQL_DESC_SCALE value returned is '%d'\n"),getDescScale);
		}
		else
		{
			TEST_FAILED;					
			LogMsg(ERRMSG, _T("expect SQL_DESC_SCALE: '%d' and actual: '%d' are not matched\n"), setDescScale,getDescScale);
		}

		//check SQL_DESCNULLABLE
		if (getDescNullable == setDescNullable)
		{
			LogMsg(NONE,_T("SQL_DESC_NULLABLE value returned is '%d'\n"),getDescNullable);
		}
		else
		{
			TEST_FAILED;					
			LogMsg(ERRMSG, _T("expect SQL_DESC_NULLABLE: '%d' and actual: '%d' are not matched\n"), setDescNullable, getDescNullable);
		}
		// end of checks 
		TESTCASE_END;




//==================================================================================================================
//		Begin Testing: Positive Test for Implicit ARD 
//===================================================================================================================
	ARDtests:	;
	
	//mark the beginning of tests in log file
	//LogMsg(SHORTTIMESTAMP, "Test the positive functionality of SQLSetDescRec and SQLGetDescRec for Implicit ARD.\n");
	

	//Get Implicit ARD handle
	returncode = SQLGetStmtAttr(hstmt, SQL_ATTR_APP_ROW_DESC, &hImArd, 0, NULL);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLGetStmtAttr: get ARD"))
	{
		LogAllErrorsVer3(henv,hdbc,hstmt);
		LogMsg(ERRMSG, _T("Cannot get ARD: Aborting Implicit ARD tests.\n"));
		TEST_FAILED;
		goto ExARDtests;		//go to next set of tests
	}
				
	for (i = 0;i < DATA_ARR_LEN; i++)		// i = index to TestDataARD
	{
		TESTCASE_BEGIN("Test the positive functionality of SQLSetDescRec and SQLGetDescRec for Implicit ARD.\n");


		
		//set multiple Fields
		RecNumber = i + 1;		//increment the recnumber and thus set the next rec (change SQL_DESC_COUNT)
		
		setDescRecHandle		= hImArd ;
		setDescRecNumber		= RecNumber;
		setDescType				= TestDataARD[i].DescType; 
		setDescIntervalCode		= TestDataARD[i].DescDatetimeIntervalCode;	
		setDescOctetLength		= TestDataARD[i].DescOctetLength;	
		setDescPrecision		= TestDataARD[i].DescPrecision;	
		setDescScale			= TestDataARD[i].DescScale;		
		setDescDataPtr			= TestDataARD[i].DescDataPtr;			
		setDescOctectLengthPtr	= TestDataARD[i].DescOctectLengthPtr;			
		setDescIndicatorPtr		= TestDataARD[i].DescIndicatorPtr;				


		returncode = SQLSetDescRec(setDescRecHandle, setDescRecNumber, setDescType, setDescIntervalCode, setDescOctetLength , setDescPrecision, setDescScale, setDescDataPtr,&setDescOctectLengthPtr, &setDescIndicatorPtr);
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLSetDescRec and SQLGetDescRec"))
		{
			LogAllErrorsVer3(henv,hdbc,hstmt);
			LogMsg(ERRMSG,_T("SQLSetDescRec: positive tests for Implicit ARD: TestDataARD['%d'].\n"),i);
			//FullDisconnect(pTestInfo);
			TEST_FAILED;
			//TEST_RETURN;
			continue;
		}
		
			
		//Get the Implicit ARD Descriptor 
		LogMsg(NONE,_T("SQLSetDescRec / SQLGetDescRec: positive tests for Implicit ARD.\n"));

		getDescRecHandle		= hImApd;					
		getDescRecNumber		= RecNumber;				
		getNameMaxLength		= MAXLEN;
		_tcscpy(getDescName	,_T(""));	//initialize		
		setDescNullable			= TestDataARD[i].DescNullable;

		returncode = SQLGetDescRec(getDescRecHandle, getDescRecNumber, (SQLTCHAR*)getDescName, getNameMaxLength, &getDescNameActualLength, &getDescType, &getDescIntervalCode, &getDescOctectLength, &getDescPrecision, &getDescScale, &getDescNullable);
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLSetDescRec and SQLGetDescRec"))
		{
			LogAllErrorsVer3(henv,hdbc,hstmt);
			LogMsg(ERRMSG,_T("SQLGetDescRec: positive tests for Implicit ARD: TestDataARD['%d'].\n"),i);
			//FullDisconnect(pTestInfo);
			TEST_FAILED;
			//TEST_RETURN;
			break;
		}

		//begin checking  ARD values 
		
		//check  SQL_DESC_NAME
		if (!(_tcscmp(getDescName, setDescName)))
		{
			LogMsg(NONE,_T("SQL_DESC_NAME value returned is '%s'\n"),getDescName);
		}
		else
		{
			TEST_FAILED;					
			LogMsg(ERRMSG, _T("expect SQL_DESC_NAME: '%s' and actual: '%s' are not matched\n"), setDescName,getDescName);
		}
		
		//check SQL_DESC_TYPE
		if (getDescType == setDescType)
		{
			LogMsg(NONE,_T("SQL_DESC_TYPE value returned is '%d'\n"),getDescType);
		}
		else
		{
			TEST_FAILED;					
			LogMsg(ERRMSG, _T("expect SQL_DESC_TYPE: '%d' and actual: '%d' are not matched\n"), setDescType, getDescType);
		}

		//check SQL_DESC_DATETIME_INTERVAL_CODE
		if (getDescIntervalCode == setDescIntervalCode)
		{
			LogMsg(NONE,_T("SQL_DESC_DATETIME_INTERVAL_CODE value returned is '%d'\n"),getDescIntervalCode);
		}
		else
		{
			TEST_FAILED;					
			LogMsg(ERRMSG, _T("expect SQL_DESC_DATETIME_INTERVAL_CODE: '%d' and actual: '%d' are not matched\n"), setDescIntervalCode, getDescIntervalCode);
		}
		//check SQL_DESC_OCTECT_LENGTH
		if (getDescOctectLength == setDescOctetLength)
		{
			LogMsg(NONE,_T("SQL_DESC_OCTECT_LENGTH value returned is '%d'\n"),getDescOctectLength);
		}
		else
		{
			TEST_FAILED;					
			LogMsg(ERRMSG, _T("expect SQL_DESC_OCTECT_LENGTH: '%d' and actual: '%d' are not matched\n"), setDescOctetLength,getDescOctectLength);
		}

		//check SQL_DESC_PRECISION
		if (getDescPrecision == setDescPrecision)
		{
			LogMsg(NONE,_T("SQL_DESC_PRECISION value returned is '%d'\n"),getDescPrecision);
		}
		else
		{
			TEST_FAILED;					
			LogMsg(ERRMSG, _T("expect SQL_DESC_PRECISION: '%d' and actual: '%d' are not matched\n"), setDescPrecision,getDescPrecision);
		}

		//check SQL_DESC_SCALE
		if (getDescScale == setDescScale)
		{
			LogMsg(NONE,_T("SQL_DESC_SCALE value returned is '%d'\n"),getDescScale);
		}
		else
		{
			TEST_FAILED;					
			LogMsg(ERRMSG, _T("expect SQL_DESC_SCALE: '%d' and actual: '%d' are not matched\n"), setDescScale,getDescScale);
		}

		//check SQL_DESCNULLABLE
		if (getDescNullable == setDescNullable)
		{
			LogMsg(NONE,_T("SQL_DESC_NULLABLE value returned is '%d'\n"),getDescNullable);
		}
		else
		{
			TEST_FAILED;					
			LogMsg(ERRMSG, _T("expect SQL_DESC_NULLABLE: '%d' and actual: '%d' are not matched\n"), setDescNullable, getDescNullable);
		}
		// end of checks
		TESTCASE_END;

	} //end for loop; end of positive tests for ARD
	


//==================================================================================================================
//		Begin Testing: Positive Test for Explicit ARD 
//===================================================================================================================
	ExARDtests:	;
	
	//mark the beginning of tests in log file
	//LogMsg(SHORTTIMESTAMP, "Test the positive functionality of SQLSetDescRec and SQLGetDescRec for Explicit ARD.\n");
	

	//Get Explicit ARD handle
	returncode = SQLAllocHandle(SQL_HANDLE_DESC, (SQLHANDLE)hdbc, &hExArd);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLAllocHandle: get explicit ARD"))
	{
		LogAllErrorsVer3(henv,hdbc,hstmt);
		LogMsg(ERRMSG, _T("Cannot get ARD: Aborting Implicit ARD tests.\n"));
		TEST_FAILED;
		goto IPDtests;		//go to next set of tests
	}

	//associate with a statement
	returncode = SQLSetStmtAttr(hstmt, SQL_ATTR_APP_ROW_DESC, (SQLPOINTER)hExArd, SQL_IS_POINTER);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLSetStmtAttr: explicit ARD"))
	{
		LogAllErrorsVer3(henv,hdbc,hstmt);
		LogMsg(ERRMSG, _T("Cannot set Explicit ARD for statement.\n"));
		TEST_FAILED;
	}

				
	for (i = 0;i < DATA_ARR_LEN; i++)		// i = index to TestDataARD
	{
		TESTCASE_BEGIN("Test the positive functionality of SQLSetDescRec and SQLGetDescRec for Explicit ARD.\n");


		
		//set multiple Fields
		RecNumber = i + 1;		//increment the recnumber and thus set the next rec (change SQL_DESC_COUNT)
		
		setDescRecHandle		= hExArd ;
		setDescRecNumber		= RecNumber;
		setDescType				= TestDataARD[i].DescType; 
		setDescIntervalCode		= TestDataARD[i].DescDatetimeIntervalCode;	
		setDescOctetLength		= TestDataARD[i].DescOctetLength;	
		setDescPrecision		= TestDataARD[i].DescPrecision;	
		setDescScale			= TestDataARD[i].DescScale;		
		setDescDataPtr			= TestDataARD[i].DescDataPtr;			
		setDescOctectLengthPtr	= TestDataARD[i].DescOctectLengthPtr;			
		setDescIndicatorPtr		= TestDataARD[i].DescIndicatorPtr;				


		returncode = SQLSetDescRec(setDescRecHandle, setDescRecNumber, setDescType, setDescIntervalCode, setDescOctetLength , setDescPrecision, setDescScale, setDescDataPtr,&setDescOctectLengthPtr, &setDescIndicatorPtr);
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLSetDescRec"))
		{
			LogAllErrorsVer3(henv,hdbc,hstmt);
			LogMsg(ERRMSG,_T("SQLSetDescRec: positive tests for Explicit ARD: TestDataARD['%d'].\n"),i);
			TEST_FAILED;
			continue;
		}
		
			
		//Get the Explicit ARD Descriptor 
		LogMsg(NONE,_T("SQLSetDescRec and SQLGetDescRec: positive tests for Explicit ARD.\n"));

		getDescRecHandle		= hExArd;					
		getDescRecNumber		= RecNumber;				
		getNameMaxLength		= MAXLEN;
		_tcscpy(getDescName	,_T(""));	//initialize		
		setDescNullable			= TestDataARD[i].DescNullable;

		returncode = SQLGetDescRec(getDescRecHandle, getDescRecNumber, (SQLTCHAR*)getDescName, getNameMaxLength, &getDescNameActualLength, &getDescType, &getDescIntervalCode, &getDescOctectLength, &getDescPrecision, &getDescScale, &getDescNullable);
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLGetDescRec"))
		{
			LogAllErrorsVer3(henv,hdbc,hstmt);
			LogMsg(ERRMSG,_T("SQLGetDescRec: positive tests for Explicit ARD: TestDataARD['%d'].\n"),i);
			TEST_FAILED;
			break;
		}

		//begin checking  ARD values 
		
		//check  SQL_DESC_NAME
		if (!(_tcscmp(getDescName, setDescName)))
		{
			LogMsg(NONE,_T("SQL_DESC_NAME value returned is '%s'\n"),getDescName);
		}
		else
		{
			TEST_FAILED;					
			LogMsg(ERRMSG, _T("expect SQL_DESC_NAME: '%s' and actual: '%s' are not matched\n"), setDescName,getDescName);
		}
		
		//check SQL_DESC_TYPE
		if (getDescType == setDescType)
		{
			LogMsg(NONE,_T("SQL_DESC_TYPE value returned is '%d'\n"),getDescType);
		}
		else
		{
			TEST_FAILED;					
			LogMsg(ERRMSG, _T("expect SQL_DESC_TYPE: '%d' and actual: '%d' are not matched\n"), setDescType, getDescType);
		}

		//check SQL_DESC_DATETIME_INTERVAL_CODE
		if (getDescIntervalCode == setDescIntervalCode)
		{
			LogMsg(NONE,_T("SQL_DESC_DATETIME_INTERVAL_CODE value returned is '%d'\n"),getDescIntervalCode);
		}
		else
		{
			TEST_FAILED;					
			LogMsg(ERRMSG, _T("expect SQL_DESC_DATETIME_INTERVAL_CODE: '%d' and actual: '%d' are not matched\n"), setDescIntervalCode, getDescIntervalCode);
		}
		//check SQL_DESC_OCTECT_LENGTH
		if (getDescOctectLength == setDescOctetLength)
		{
			LogMsg(NONE,_T("SQL_DESC_OCTECT_LENGTH value returned is '%d'\n"),getDescOctectLength);
		}
		else
		{
			TEST_FAILED;					
			LogMsg(ERRMSG, _T("expect SQL_DESC_OCTECT_LENGTH: '%d' and actual: '%d' are not matched\n"), setDescOctetLength,getDescOctectLength);
		}

		//check SQL_DESC_PRECISION
		if (getDescPrecision == setDescPrecision)
		{
			LogMsg(NONE,_T("SQL_DESC_PRECISION value returned is '%d'\n"), getDescPrecision);
		}
		else
		{
			TEST_FAILED;					
			LogMsg(ERRMSG, _T("expect SQL_DESC_PRECISION: '%d' and actual: '%d' are not matched\n"), setDescPrecision,getDescPrecision);
		}

		//check SQL_DESC_SCALE
		if (getDescScale == setDescScale)
		{
			LogMsg(NONE,_T("SQL_DESC_SCALE value returned is '%d'\n"),getDescScale);
		}
		else
		{
			TEST_FAILED;					
			LogMsg(ERRMSG, _T("expect SQL_DESC_SCALE: '%d' and actual: '%d' are not matched\n"), setDescScale,getDescScale);
		}

		//check SQL_DESCNULLABLE
		if (getDescNullable == setDescNullable)
		{
			LogMsg(NONE,_T("SQL_DESC_NULLABLE value returned is '%d'\n"),getDescNullable);
		}
		else
		{
			TEST_FAILED;					
			LogMsg(ERRMSG, _T("expect SQL_DESC_NULLABLE: '%d' and actual: '%d' are not matched\n"), setDescNullable, getDescNullable);
		}
		// end of checks
		TESTCASE_END;

	} //end for loop; end of positive tests for Explicit ARD

	//free explicit ARD
	returncode = SQLFreeHandle(SQL_HANDLE_DESC, hExArd);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLFreeHandle (for ARD)"))
	{
		LogAllErrorsVer3(henv,hdbc,hstmt);
		TEST_FAILED;
	}
	

//======================================================================================================================
//		 Begin Testing: Positive Test for Implicit IPD 
//=====================================================================================================================	

	IPDtests:	;
	
	//mark the beginning of tests in log file
	//LogMsg(SHORTTIMESTAMP, "Test the positive functionality of SQLSetDescRec and SQLGetDescRec for Implicit IPD.\n");
	

	//Get Implicit IPD handle
	returncode = SQLGetStmtAttr(hstmt, SQL_ATTR_APP_ROW_DESC, &hImIpd, 0, NULL);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLGetStmtAttr: get IPD"))
	{
		LogAllErrorsVer3(henv,hdbc,hstmt);
		LogMsg(ERRMSG, _T("Cannot get IPD: Aborting Implicit IPD tests.\n"));
		TEST_FAILED;
		goto IRDtests;		//go to next set of tests
	}	
	
	
	
	for (i = 0;i < DATA_ARR_LEN; i++)		// i = index to TestDataIPD
	{
		TESTCASE_BEGIN("Test the positive functionality of SQLSetDescRec and SQLGetDescRec for Implicit IPD.\n");
		

		
		//set multiple Fields
		RecNumber = i + 1;		//increment the recnumber and thus set the next rec (change SQL_DESC_COUNT)
		
		setDescRecHandle		= hImIpd ;
		setDescRecNumber		= RecNumber;
		setDescType				= TestDataIPD[i].DescType; 
		setDescIntervalCode		= TestDataIPD[i].DescDatetimeIntervalCode;
		setDescOctetLength		= TestDataIPD[i].DescOctetLength;
		setDescPrecision		= TestDataIPD[i].DescPrecision;	
		setDescScale			= TestDataIPD[i].DescScale;		
		setDescDataPtr			= TestDataIPD[i].DescDataPtr;			
		setDescOctectLengthPtr	= TestDataIPD[i].DescOctectLengthPtr;			
		setDescIndicatorPtr		= TestDataIPD[i].DescIndicatorPtr;				

		returncode = SQLSetDescRec(setDescRecHandle, setDescRecNumber, setDescType, setDescIntervalCode, setDescOctetLength , setDescPrecision, setDescScale, setDescDataPtr,&setDescOctectLengthPtr, &setDescIndicatorPtr);
		if(!CHECKRC(SQL_SUCCESS,returncode, "SQLSetDescRec and SQLGetDescRec"))
		{
			LogAllErrorsVer3(henv,hdbc,hstmt);
			LogMsg(ERRMSG,_T("SQLSetDescRec: positive tests for Implicit IPD: TestDataIPD['%d'].\n"),i);
			//FullDisconnect(pTestInfo);
			TEST_FAILED;
			//TEST_RETURN;
			continue;
		}
		
			
		//Get the Implicit IPD Descriptor 
		LogMsg(NONE,_T("SQLSetDescRec and SQLGetDescRec: positive tests for Implicit IPD.\n"));


		getDescRecHandle		= hImApd;					
		getDescRecNumber		= RecNumber;				
		getNameMaxLength		= MAXLEN;
		_tcscpy(getDescName	,_T(""));	//initialize	
		setDescNullable			= TestDataIPD[i].DescNullable;

		returncode = SQLGetDescRec(getDescRecHandle, getDescRecNumber, (SQLTCHAR*)getDescName, getNameMaxLength, &getDescNameActualLength, &getDescType, &getDescIntervalCode, &getDescOctectLength, &getDescPrecision, &getDescScale, &getDescNullable);
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLGetDescRec"))
		{
			LogAllErrorsVer3(henv,hdbc,hstmt);
			LogMsg(ERRMSG,_T("SQLGetDescRec: positive tests for Implicit IPD: TestDataIPD['%d'].\n"),i);
			//FullDisconnect(pTestInfo);
			TEST_FAILED;
			//TEST_RETURN;
			continue;
		}

		//begin checking  IPD values 
		
		//check  SQL_DESC_NAME
		if (!(_tcscmp(getDescName, setDescName)))
		{
			LogMsg(NONE,_T("SQL_DESC_NAME value returned is '%s'\n"),getDescName);
		}
		else
		{
			TEST_FAILED;					
			LogMsg(ERRMSG, _T("expect SQL_DESC_NAME: '%s' and actual: '%s' are not matched\n"), setDescName,getDescName);
		}
		
		//check SQL_DESC_TYPE
		if (getDescType == setDescType)
		{
			LogMsg(NONE,_T("SQL_DESC_TYPE value returned is '%d'\n"), getDescType);
		}
		else
		{
			TEST_FAILED;					
			LogMsg(ERRMSG, _T("expect SQL_DESC_TYPE: '%d' and actual: '%d' are not matched\n"), setDescType, getDescType);
		}

		//check SQL_DESC_DATETIME_INTERVAL_CODE
		if (getDescIntervalCode == setDescIntervalCode)
		{
			LogMsg(NONE,_T("SQL_DESC_DATETIME_INTERVAL_CODE value returned is '%d'\n"),getDescIntervalCode);
		}
		else
		{
			TEST_FAILED;					
			LogMsg(ERRMSG, _T("expect SQL_DESC_DATETIME_INTERVAL_CODE: '%d' and actual: '%d' are not matched\n"), setDescIntervalCode, getDescIntervalCode);
		}
		//check SQL_DESC_OCTECT_LENGTH
		if (getDescOctectLength == setDescOctetLength)
		{
			LogMsg(NONE,_T("SQL_DESC_OCTECT_LENGTH value returned is '%d'\n"),getDescOctectLength);
		}
		else
		{
			TEST_FAILED;					
			LogMsg(ERRMSG, _T("expect SQL_DESC_OCTECT_LENGTH: '%d' and actual: '%d' are not matched\n"), setDescOctetLength,getDescOctectLength);
		}

		//check SQL_DESC_PRECISION
		if (getDescPrecision == setDescPrecision)
		{
			LogMsg(NONE,_T("SQL_DESC_PRECISION value returned is '%d'\n"),getDescPrecision);
		}
		else
		{
			TEST_FAILED;					
			LogMsg(ERRMSG, _T("expect SQL_DESC_PRECISION: '%d' and actual: '%d' are not matched\n"), setDescPrecision,getDescPrecision);
		}

		//check SQL_DESC_SCALE
		if (getDescScale == setDescScale)
		{
			LogMsg(NONE,_T("SQL_DESC_SCALE value returned is '%d'\n"),getDescScale);
		}
		else
		{
			TEST_FAILED;					
			LogMsg(ERRMSG, _T("expect SQL_DESC_SCALE: '%d' and actual: '%d' are not matched\n"), setDescScale,getDescScale);
		}

		//check SQL_DESCNULLABLE
		if (getDescNullable == setDescNullable)
		{
			LogMsg(NONE,_T("SQL_DESC_NULLABLE value returned is '%d'\n"),getDescNullable);
		}
		else
		{
			TEST_FAILED;					
			LogMsg(ERRMSG, _T("expect SQL_DESC_NULLABLE: '%d' and actual: '%d' are not matched\n"), setDescNullable, getDescNullable);
		}
		// end of checks 
		TESTCASE_END;

	} //end for loop; end of positive tests for IPD


//==================================================================================================================
//		 Begin Testing: Posituve Tests for IRD (IRD Desc Fields are read only) 
//==================================================================================================================
		IRDtests: ;

		//mark the beginning of tests in log file
		//LogMsg(SHORTTIMESTAMP, "Test the positive functionality of SQLSetDescRec and SQLGetDescRec for Implicit IRD.\n");
	
		//Get Implicit IRD handle
		returncode = SQLGetStmtAttr(hstmt, SQL_ATTR_IMP_ROW_DESC, &hImIrd, 0, NULL);
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLGetStmtAttr"))
		{
			LogAllErrorsVer3(henv,hdbc,hstmt);
			LogMsg(ERRMSG, _T("Cannot get IRD: Aborting Implicit IRD tests.\n"));
			TEST_FAILED;
		//	TEST_RETURN;		//this will abort tests and perform a full disconnect.
		}

		//---------------------------------------------------------------------------------------------------------
		
		TESTCASE_BEGIN("Test SQLSetDescRec for Implicit IRD: IRD Descriptor Fields cannot be set by the application.\n");
		
		//set multiple Fields
		RecNumber = i + 1;		//increment the recnumber and thus set the next rec (change SQL_DESC_COUNT)
		
		setDescRecHandle		= hImIrd ;
		setDescRecNumber		= RecNumber;
		setDescType				= TestDataIRD[i].DescType; 
		setDescIntervalCode		= TestDataIRD[i].DescDatetimeIntervalCode;	
		setDescOctetLength		= TestDataIRD[i].DescOctetLength;	
		setDescPrecision		= TestDataIRD[i].DescPrecision;	
		setDescScale			= TestDataIRD[i].DescScale;		
		setDescDataPtr			= TestDataIRD[i].DescDataPtr;			
		setDescOctectLengthPtr	= TestDataIRD[i].DescOctectLengthPtr;			
		setDescIndicatorPtr		= TestDataIRD[i].DescIndicatorPtr;				

		returncode = SQLSetDescRec(setDescRecHandle, setDescRecNumber, setDescType, setDescIntervalCode, setDescOctetLength , setDescPrecision, setDescScale, setDescDataPtr,&setDescOctectLengthPtr, &setDescIndicatorPtr);
		if(!CHECKRC(SQL_ERROR,returncode,"SQLSetDescRec"))
		{
			LogAllErrorsVer3(henv,hdbc,hstmt);
			TEST_FAILED;

		}
		TESTCASE_END;
		
		//-------------------------------------------------------------------------------------------------------------
		
		TESTCASE_BEGIN("Test SQLGetDescRec for Implicit IRD: IRD Descriptor Fields not populated before call to DB.\n");
		
		//This testcases use the Implicit IRD handle obtained in previous testcase

		returncode = SQLGetDescRec(hImIrd, 1, (SQLTCHAR*)getDescName, MAXLEN, &getDescNameActualLength, &getDescType, &getDescIntervalCode, &getDescOctectLength, &getDescPrecision, &getDescScale, &getDescNullable);
		if(!CHECKRC(SQL_NO_DATA_FOUND,returncode,"SQLGetDescField"))
		{
			LogAllErrorsVer3(henv,hdbc,hstmt);
			TEST_FAILED;
			//TEST_RETURN;	//last test: valid to use TEST_RETURN when the test suite must be exited.
		}

		TESTCASE_END;

//===============================================================================================================
//			Begin Testing:Positive Test for populated Implicit IRD 
//===============================================================================================================

	TESTCASE_BEGIN("Test SQLGetDescRec for populated Implicit IRD.\n");

	//mark the beginning of tests in log file
	//LogMsg(SHORTTIMESTAMP, "Test the positive functionality of (SQLSetDescRec) and SQLGetDescRec for Implicit IRD.\n");
	
	//alloc new handle
	returncode = SQLAllocHandle(SQL_HANDLE_STMT, (SQLHANDLE)hdbc, &hstmt1);	
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLAllocHandle"))
	{
		LogAllErrorsVer3(henv,hdbc,hstmt1);
		LogMsg(ERRMSG,_T("Cannot allocate statement: Aborting populated Implicit IRD tests.\n"));
		FullDisconnect(pTestInfo);
		TEST_FAILED;
		goto Cleanup;		// transfers control to the next set 
	}

	//Get Implicit IRD handle
	returncode = SQLGetStmtAttr(hstmt, SQL_ATTR_APP_PARAM_DESC, &hIrd, 0, NULL);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLGetStmtAttr: get IRD"))
	{
		LogAllErrorsVer3(henv,hdbc,hstmt1);
		LogMsg(ERRMSG,_T("Cannot allocate descriptor: Aborting populated Implicit IRD tests.\n"));
		TEST_FAILED;
		goto Cleanup;		// transfers control to the next set 
	}

	//populate the IRD by executing an catalog api
	returncode = SQLGetTypeInfo(hstmt1, SQL_ALL_TYPES);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLGetTypeInfo: population of IRD"))
	{
		LogAllErrorsVer3(henv,hdbc,hstmt1);
		LogMsg(ERRMSG,_T("Cannot execute statement: Aborting populated Implicit IRD tests.\n"));
		TEST_FAILED;
		goto Cleanup;		// transfers control to the next set 
	}	

	//check IRD
	returncode = SQLGetDescRec(hIrd, 1, (SQLTCHAR*)getDescName, MAXLEN, &getDescNameActualLength, &getDescType, &getDescIntervalCode, &getDescOctectLength, &getDescPrecision, &getDescScale, &getDescNullable);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLGetDescField"))
	{
			LogAllErrorsVer3(henv,hdbc,hstmt1);
			TEST_FAILED;
			//TEST_RETURN;	//last test: valid to use TEST_RETURN when the test suite must be exited.
	}
	
	TESTCASE_END;

	// free implicitly allocated descriptors by freeing statement
	returncode = SQLFreeHandle(SQL_HANDLE_STMT,hstmt1);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLFreeHandle"))
	{
		LogAllErrorsVer3(henv,hdbc,hstmt1);
		TEST_FAILED;
	}

//===========================================================================================================
//		begin cleanup 
//==============================================================================================================
Cleanup: ;
		
	// free implicitly allocated descriptors by freeing statement
	returncode = SQLFreeHandle(SQL_HANDLE_STMT,hstmt);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLFreeHandle"))
	{
		LogAllErrorsVer3(henv,hdbc,hstmt);
		TEST_FAILED;
	}
	

	
	FullDisconnect3(pTestInfo);
	LogMsg(SHORTTIMESTAMP+LINEAFTER,_T("End testing API => SQLSetDescRec and SQLGetDescRec.\n"));
    TEST_RETURN;
} //end of test ****************
Beispiel #24
0
/*
---------------------------------------------------------
   TestSQLTransact
---------------------------------------------------------
*/
PassFail TestSQLTransact(TestInfo *pTestInfo)
{                  
	TEST_DECLARE;
	RETCODE			returncode;
	TCHAR			Heading[MAX_STRING_SIZE];
	SQLHANDLE 		henv;
 	SQLHANDLE 		hdbc;
 	SQLHANDLE		hstmt;
	TCHAR			*ExecDirStr[6];
	UWORD			fType[] = { SQL_ROLLBACK,SQL_COMMIT };
	TCHAR			*TypeDesc[] = { _T("SQL_ROLLBACK"),_T("SQL_COMMIT") };
	TCHAR			*Output;
	SQLLEN			OutputLen;
	struct
	{
		SWORD	ExeRes[2];
		SWORD	FetchRes[2];
		TCHAR	*DataRes[2];
	} CheckRes[] =	
		{
			{SQL_ERROR,SQL_SUCCESS,SQL_NO_DATA_FOUND,SQL_NO_DATA_FOUND,_T(""),_T("")},
			{SQL_SUCCESS,SQL_SUCCESS,SQL_NO_DATA_FOUND,SQL_SUCCESS,_T(""),_T("--")},
			{SQL_SUCCESS,SQL_SUCCESS,SQL_SUCCESS,SQL_SUCCESS,_T("--"),_T("--")},
			{SQL_SUCCESS,SQL_SUCCESS,SQL_SUCCESS,SQL_NO_DATA_FOUND,_T("--"),_T("")},
			{SQL_SUCCESS,SQL_ERROR,SQL_NO_DATA_FOUND,SQL_NO_DATA_FOUND,_T(""),_T("")}
		};
	int	i = 0, j = 0, iend = 5, jend = 1, commit_on_off = 0;

//===========================================================================================================
	var_list_t *var_list;
	var_list = load_api_vars(_T("SQLTransact"), charset_file);
	if (var_list == NULL) return FAILED;

	ExecDirStr[0] = var_mapping(_T("SQLTransact_ExecDirStr_0"), var_list);
	ExecDirStr[1] = var_mapping(_T("SQLTransact_ExecDirStr_1"), var_list);
	ExecDirStr[2] = var_mapping(_T("SQLTransact_ExecDirStr_2"), var_list);
	ExecDirStr[3] = var_mapping(_T("SQLTransact_ExecDirStr_3"), var_list);
	ExecDirStr[4] = var_mapping(_T("SQLTransact_ExecDirStr_4"), var_list);
	ExecDirStr[5] = var_mapping(_T("SQLTransact_ExecDirStr_5"), var_list);

	CheckRes[1].DataRes[1] = var_mapping(_T("SQLTransact_Insert"), var_list);
	CheckRes[2].DataRes[0] = var_mapping(_T("SQLTransact_Insert"), var_list);
	CheckRes[2].DataRes[1] = var_mapping(_T("SQLTransact_Update"), var_list);
	CheckRes[3].DataRes[0] = var_mapping(_T("SQLTransact_Update"), var_list);

//========================================================================================================

	LogMsg(LINEBEFORE+SHORTTIMESTAMP,_T("Begin testing API => SQLTransact.\n"));
	TEST_INIT;

	TESTCASE_BEGIN("Initializing SQLTransact test environment\n");
//	
	if(!FullConnect(pTestInfo))
	{
		LogMsg(NONE,_T("Unable to connect\n"));
		TEST_FAILED;
		TEST_RETURN;
	}
	henv = pTestInfo->henv;
 	hdbc = pTestInfo->hdbc;
 	hstmt = (SQLHANDLE)pTestInfo->hstmt;
	returncode = SQLAllocStmt((SQLHANDLE)hdbc, &hstmt);	
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLAllocStmt"))
	{
		LogAllErrors(henv,hdbc,hstmt);
		FullDisconnect(pTestInfo);
		TEST_FAILED;
		TEST_RETURN;
	}
	
	for (commit_on_off = 0; commit_on_off < 10; commit_on_off++)
	{
		returncode = SQLSetConnectOption((SQLHANDLE)hdbc,SQL_AUTOCOMMIT,SQL_AUTOCOMMIT_ON);
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLSetConnectOption"))
		{
			LogAllErrors(henv,hdbc,hstmt);
			FullDisconnect(pTestInfo);
			TEST_FAILED;
			TEST_RETURN;
		}
		TESTCASE_END;
		SQLExecDirect(hstmt, (SQLTCHAR*)ExecDirStr[4], SQL_NTS); /* CLEANUP */
		for (i = 0; i <= (iend-1); i++)
		{
			_stprintf(Heading,_T("Test Positive Functionality of SQLTransact while Autocommit is ON and executing\n"));
			_tcscat(Heading, ExecDirStr[i]);
			_tcscat(Heading, _T("\n"));
			TESTCASE_BEGINW(Heading);
			
			returncode = SQLExecDirect(hstmt,(SQLTCHAR*)ExecDirStr[i],SQL_NTS);
			if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect"))
			{
				LogAllErrors(henv,hdbc,hstmt);
				TEST_FAILED;
			}
		}
		SQLExecDirect(hstmt,(SQLTCHAR*)ExecDirStr[4],SQL_NTS); /* CLEANUP */
		returncode = SQLSetConnectOption((SQLHANDLE)hdbc,SQL_AUTOCOMMIT,SQL_AUTOCOMMIT_OFF);
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLSetConnectOption"))
		{
			LogAllErrors(henv,hdbc,hstmt);
			FullDisconnect(pTestInfo);
			TEST_FAILED;
			TEST_RETURN;
		}
		TESTCASE_END;
		
		for (i = 0; i <= (iend-1); i++)
		{
			for (j = 0; j <= jend; j++)
			{
				_stprintf(Heading,_T("Test Positive Functionality of SQLTransact while Autocommit is OFF and executing\n"));
				_tcscat(Heading, ExecDirStr[i]);
				_tcscat(Heading, _T(" & "));
				_tcscat(Heading, TypeDesc[j]);
				_tcscat(Heading, _T("\n"));
				TESTCASE_BEGINW(Heading);
				
				//MAY 9, 2014 - TURNING AUTOCOMMIT ON FOR DDLs FOR TRAF, AS DDLs ARE NOT SUPPORTED WITH AUTOCOMMIT OFF
				if (i == 4 || i == 0)
					SQLSetConnectOption((SQLHANDLE)hdbc, SQL_AUTOCOMMIT, SQL_AUTOCOMMIT_ON);
				returncode = SQLExecDirect(hstmt,(SQLTCHAR*)ExecDirStr[i],SQL_NTS);
				SQLSetConnectOption((SQLHANDLE)hdbc, SQL_AUTOCOMMIT, SQL_AUTOCOMMIT_OFF);
				if (!CHECKRC(SQL_SUCCESS, returncode, "SQLExecDirect"))
				{
					LogAllErrors(henv,hdbc,hstmt);
					TEST_FAILED;
				}
				else
				{
					returncode=SQLTransact((SQLHANDLE)henv,(SQLHANDLE)hdbc,fType[j]);
					Sleep(2);																// tmf rollback is slower.
					if(!CHECKRC(SQL_SUCCESS,returncode,"SQLTransact"))
					{
						LogAllErrors(henv,hdbc,hstmt);
						TEST_FAILED;
					}

					returncode = SQLExecDirect(hstmt,(SQLTCHAR*)ExecDirStr[iend],SQL_NTS);
					if(!CHECKRC(CheckRes[i].ExeRes[j],returncode,"SQLExecDirect"))
					{
						LogAllErrors(henv,hdbc,hstmt);
						TEST_FAILED;
					}
					else
					{
						if (returncode == SQL_SUCCESS || returncode == SQL_SUCCESS_WITH_INFO)
						{
							Output = (TCHAR *)malloc(NAME_LEN);
							returncode=SQLBindCol(hstmt,1,SQL_C_TCHAR,Output,NAME_LEN,&OutputLen);
							if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol"))
							{
								LogAllErrors(henv,hdbc,hstmt);
								TEST_FAILED;
							}
							else
							{
								returncode = SQLFetch(hstmt);
								if(!CHECKRC(CheckRes[i].FetchRes[j],returncode,"SQLFetch"))
								{
									LogAllErrors(henv,hdbc,hstmt);
									TEST_FAILED;
								}
								else
								{
									if (returncode != SQL_NO_DATA_FOUND && returncode != SQL_ERROR)
									{
										if (_tcscspn(CheckRes[i].DataRes[j],Output) == 0)
										{
											LogMsg(NONE,_T("expect: %s and actual: %s are matched\n"),Output,CheckRes[i].DataRes[j]);
										}	
										else
										{
											LogMsg(NONE,_T("expect: %s and actual: %s are not matched\n"),Output,CheckRes[i].DataRes[j]);
											TEST_FAILED;	
										}
									}
								}
								free(Output);
								SQLFreeStmt(hstmt,SQL_CLOSE);
							}
						}
					}
				}
				TESTCASE_END;
			}/* end j loop */
		}/* end i loop */
	}

//========================================================================================================

	SQLExecDirect(hstmt,(SQLTCHAR*)ExecDirStr[4],SQL_NTS); /* CLEANUP */
	returncode = SQLDisconnect((SQLHANDLE)hdbc);
    if(!CHECKRC(SQL_ERROR,returncode,"SQLDisconnect")) 
	{
		LogAllErrorsVer3(henv,hdbc,hstmt);
		TEST_FAILED;	
	}	
	
	// Free the open transactions.
	returncode=SQLTransact((SQLHANDLE)henv,(SQLHANDLE)hdbc,SQL_ROLLBACK);
	Sleep(2);	

	returncode=FullDisconnect(pTestInfo);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLFullDisconnect"))
	{
		LogAllErrorsVer3(henv,hdbc,hstmt);
		TEST_FAILED;
	}

	LogMsg(SHORTTIMESTAMP+LINEAFTER,_T("End testing API => SQLTransact.\n"));

	free_list(var_list);

	TEST_RETURN;
}
Beispiel #25
0
/*
---------------------------------------------------------
   TestSQLExecute
---------------------------------------------------------
*/
PassFail TestSQLExecute(TestInfo *pTestInfo, int MX_MP_SPECIFIC)
{                  
	TEST_DECLARE;

 	RETCODE			returncode;
 	SQLHANDLE 		henv;
 	SQLHANDLE 		hdbc;
 	SQLHANDLE		hstmt;
	TCHAR			*ExecStr[15];
	TCHAR			*szInput[] = {_T("Inst char"),_T("Inst vchar"),_T("1234.56789"),_T("1234.56789"),_T("1200"),_T("12000"),_T("123.45"),_T("123.45"),_T("123.45"),_T("1993-07-01"),_T("09:45:30"),_T("1993-08-02 08:44:31.001"),_T("120000"),_T("1234567890.56789"),_T("1234567890.456789"),_T("1234567890.456789"),_T("0.01234567890123456789"),_T("1234.56789"),_T("1234567890.56789"),_T("12345678901234567890.0123456789"),_T("Inst char"),_T("Inst vchar")};
	SQLLEN			cbInput = SQL_NTS;
	SQLUSMALLINT	i = 0;
	SQLSMALLINT		Type[] = {SQL_WCHAR,SQL_WVARCHAR,SQL_DECIMAL,SQL_NUMERIC,SQL_SMALLINT,SQL_INTEGER,SQL_REAL,SQL_FLOAT,SQL_DOUBLE,SQL_DATE,SQL_TIME,SQL_TIMESTAMP,SQL_BIGINT,SQL_NUMERIC,SQL_NUMERIC,SQL_NUMERIC,SQL_NUMERIC,SQL_NUMERIC,SQL_NUMERIC,SQL_NUMERIC,SQL_WCHAR,SQL_WVARCHAR};
	SQLUINTEGER		ColPrec[] = {254,254,10,10,5,10,7,15,15,10,8,26,19,19,19,128,128,10,18,30,254,254};
	SQLSMALLINT		ColScale[]= {0,0,5,5,0,0,0,0,0,0,0,0,0,0,6,0,128,5,5,10,0,0};
	short			CCharOutput1,CCharOutput2;
	SQLLEN			OutputLen1,OutputLen2;
	int				actual_insert=0,num_insert=0;
	SWORD			param = 0;

//===========================================================================================================
	var_list_t *var_list;
	var_list = load_api_vars(_T("SQLExecute"), charset_file);
	if (var_list == NULL) return FAILED;

	//print_list(var_list);
	ExecStr[0] = var_mapping(_T("SQLExecute_ExecStr_0"), var_list);
	ExecStr[1] = var_mapping(_T("SQLExecute_ExecStr_1"), var_list);
	ExecStr[2] = var_mapping(_T("SQLExecute_ExecStr_2"), var_list);
	ExecStr[3] = var_mapping(_T("SQLExecute_ExecStr_3"), var_list);

	ExecStr[4] = var_mapping(_T("SQLExecute_ExecStr_4"), var_list);
	ExecStr[5] = var_mapping(_T("SQLExecute_ExecStr_5"), var_list);
	ExecStr[6] = var_mapping(_T("SQLExecute_ExecStr_6"), var_list); 
	ExecStr[7] = var_mapping(_T("SQLExecute_ExecStr_7"), var_list);
	ExecStr[8] = var_mapping(_T("SQLExecute_ExecStr_8"), var_list);
	ExecStr[9] = var_mapping(_T("SQLExecute_ExecStr_9"), var_list);
	ExecStr[10] = var_mapping(_T("SQLExecute_ExecStr_10"), var_list);
	ExecStr[11] = var_mapping(_T("SQLExecute_ExecStr_11"), var_list);
	ExecStr[12] = var_mapping(_T("SQLExecute_ExecStr_12"), var_list);
	ExecStr[13] = var_mapping(_T("SQLExecute_ExecStr_13"), var_list);
	ExecStr[14] = var_mapping(_T("SQLExecute_ExecStr_14"), var_list);

//=================================================================================================

	LogMsg(LINEBEFORE+SHORTTIMESTAMP,_T("Begin testing API => SQLExecute.\n"));

	TEST_INIT;

	TESTCASE_BEGIN("Setup for SQLExecute tests\n");

	if(!FullConnect(pTestInfo)){
		LogMsg(NONE,_T("Unable to connect\n"));
		TEST_FAILED;
		TEST_RETURN;
	}

	henv = pTestInfo->henv;
 	hdbc = pTestInfo->hdbc;
 	hstmt = (SQLHANDLE)pTestInfo->hstmt;
   	
	returncode = SQLAllocStmt((SQLHANDLE)hdbc, &hstmt);	
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLAllocStmt")){
		LogAllErrors(henv,hdbc,hstmt);
		TEST_FAILED;
		TEST_RETURN;
		}

	returncode=SQLExecDirect(hstmt,(SQLTCHAR*)ExecStr[4],SQL_NTS);

	returncode=SQLExecDirect(hstmt,(SQLTCHAR*)ExecStr[5],SQL_NTS); 
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect")){
		LogAllErrors(henv,hdbc,hstmt);
		TEST_FAILED;
		TEST_RETURN;
		}

	returncode=SQLExecDirect(hstmt,(SQLTCHAR *)ExecStr[6],SQL_NTS); 
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect")){
		LogAllErrors(henv,hdbc,hstmt);
		TEST_FAILED;
		TEST_RETURN;
		}

	returncode=SQLExecDirect(hstmt,(SQLTCHAR*)ExecStr[7],SQL_NTS); 
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect")){
		LogAllErrors(henv,hdbc,hstmt);
		TEST_FAILED;
		TEST_RETURN;
		}
	returncode=SQLExecDirect(hstmt,(SQLTCHAR*)ExecStr[8],SQL_NTS); 
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect")){
		LogAllErrors(henv,hdbc,hstmt);
		TEST_FAILED;
		TEST_RETURN;
		}

	TESTCASE_END;  // end of setup

	TESTCASE_BEGIN("Test #1: Positive Functionality of SQLExecute\n");

	returncode = SQLPrepare(hstmt,(SQLTCHAR *)ExecStr[9],SQL_NTS);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLPrepare")){
		LogAllErrors(henv,hdbc,hstmt);
		TEST_FAILED;
		}

	returncode = SQLExecute(hstmt); 
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecute")){
		LogAllErrors(henv,hdbc,hstmt);
		TEST_FAILED;
		}

	returncode = SQLBindCol(hstmt,1,SQL_C_SHORT,&CCharOutput1,0,&OutputLen1);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol")){
		LogAllErrors(henv,hdbc,hstmt);
		TEST_FAILED;
		}

	returncode = SQLBindCol(hstmt,2,SQL_C_SHORT,&CCharOutput2,0,&OutputLen2);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol")){
		LogAllErrors(henv,hdbc,hstmt);
		TEST_FAILED;
		}

	while (returncode != SQL_NO_DATA_FOUND)
	{
		returncode = SQLFetch(hstmt);
		if (returncode != SQL_NO_DATA_FOUND)
		{
			if(!CHECKRC(SQL_SUCCESS,returncode,"SQLFetch"))
			{
				TEST_FAILED;
				LogAllErrors(henv,hdbc,hstmt);
			}
		}
	}
	SQLFreeStmt(hstmt,SQL_CLOSE);
	returncode = SQLPrepare(hstmt,(SQLTCHAR *)ExecStr[10],SQL_NTS);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLPrepare")){
		LogAllErrors(henv,hdbc,hstmt);
		TEST_FAILED;
		}

	returncode = SQLExecute(hstmt); 
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecute")){
		LogAllErrors(henv,hdbc,hstmt);
		TEST_FAILED;
		}

	SQLFreeStmt(hstmt,SQL_CLOSE);
	SQLExecDirect(hstmt,(SQLTCHAR*)ExecStr[4],SQL_NTS); 
	TESTCASE_END;

	TESTCASE_BEGIN("Test #2: Positive Functionality of SQLExecute\n");
	returncode = SQLExecDirect(hstmt,(SQLTCHAR*)ExecStr[0],_tcslen(ExecStr[0])); /* cleanup */

	returncode = SQLPrepare(hstmt,(SQLTCHAR*)ExecStr[1],_tcslen(ExecStr[1]));
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLPrepare")){
		LogAllErrors(henv,hdbc,hstmt);
		TEST_FAILED;
		}

	returncode = SQLExecute(hstmt); 
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecute")){
		LogAllErrors(henv,hdbc,hstmt);
		TEST_FAILED;
		}
	TESTCASE_END;
	
	TESTCASE_BEGIN("Test #3: Positive Functionality of SQLExecute with SQL_NTS\n");
	returncode = SQLPrepare(hstmt,(SQLTCHAR*)ExecStr[2],SQL_NTS);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLPrepare")){
		LogAllErrors(henv,hdbc,hstmt);
		TEST_FAILED;
		}

	returncode = SQLExecute(hstmt); 
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecute")){
		LogAllErrors(henv,hdbc,hstmt);
		TEST_FAILED;
		}
	TESTCASE_END;

	TESTCASE_BEGIN("Test #4: Positive Functionality of SQLPrepare then SQLExecute twice\n");
	returncode = SQLPrepare(hstmt,(SQLTCHAR*)ExecStr[2],_tcslen(ExecStr[2]));
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLPrepare")){
		LogAllErrors(henv,hdbc,hstmt);
		TEST_FAILED;
		}

	returncode = SQLExecute(hstmt); 
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecute")){
		LogAllErrors(henv,hdbc,hstmt);
		TEST_FAILED;
		}

	returncode = SQLExecute(hstmt); 
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecute")){
		LogAllErrors(henv,hdbc,hstmt);
		TEST_FAILED;
		}

	TESTCASE_END;

	SQLFreeStmt(hstmt,SQL_CLOSE);
	SQLFreeStmt(hstmt,SQL_UNBIND);
	SQLFreeStmt(hstmt,SQL_RESET_PARAMS);
		
	TESTCASE_BEGIN("Test #5: Positive Functionality of SQLExecute with params\n");
	returncode = SQLPrepare(hstmt,(SQLTCHAR*)ExecStr[3],SQL_NTS);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLPrepare")){
		LogAllErrors(henv,hdbc,hstmt);
		TEST_FAILED;
		}
	else{
		for (i = 0; i <= 3; i++){
			    
			if (i==0) Type[0] = 1;	
			returncode = SQLBindParameter(hstmt,(SWORD)(i+1),SQL_PARAM_INPUT,SQL_C_TCHAR,Type[i],EXEC_LEN,0,szInput[i],0,&cbInput);
			if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindParameter")){
				LogMsg(NONE,_T("Type[i]: %d  \n"),Type[i]);
				LogAllErrors(henv,hdbc,hstmt);
				TEST_FAILED;
				}
			
			}
		returncode = SQLExecute(hstmt); 
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecute")){
			LogAllErrors(henv,hdbc,hstmt);
			TEST_FAILED;
			}
		}
	TESTCASE_END;
		
	TESTCASE_BEGIN("Test #6: Negative Functionality of SQLExecute with less params\n");
	returncode = SQLFreeStmt(hstmt,SQL_DROP);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLFreeStmt")){
		LogAllErrors(henv,hdbc,hstmt);
		TEST_FAILED;
		}
	else{
		returncode = SQLAllocStmt((SQLHANDLE)hdbc, &hstmt);
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLAllocStmt")){
			LogAllErrors(henv,hdbc,hstmt);
			TEST_FAILED;
			}
		else{
			returncode = SQLPrepare(hstmt,(SQLTCHAR*)ExecStr[3],SQL_NTS);
			if(!CHECKRC(SQL_SUCCESS,returncode,"SQLPrepare")){
				LogAllErrors(henv,hdbc,hstmt);
				TEST_FAILED;
				}
			else{
				returncode = SQLBindParameter(hstmt,1,SQL_PARAM_INPUT,SQL_C_TCHAR,Type[0],EXEC_LEN,0,szInput[0],0,&cbInput);
				if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindParameter")){
					LogAllErrors(henv,hdbc,hstmt);
					TEST_FAILED;
					}
				else{
					returncode = SQLExecute(hstmt); 
					if(!CHECKRC(SQL_ERROR,returncode,"SQLExecute")){
						LogAllErrors(henv,hdbc,hstmt);
						TEST_FAILED;
						}
					}
				}	
			}
		}
	TESTCASE_END;

	TESTCASE_BEGIN("Test #7: Negative Functionality of SQLExecute with not prepared stmt\n");
	returncode = SQLFreeStmt(hstmt,SQL_DROP);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLFreeStmt")){
		LogAllErrors(henv,hdbc,hstmt);
		TEST_FAILED;
		}
	else{
		returncode = SQLAllocStmt((SQLHANDLE)hdbc, &hstmt);
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLAllocStmt")){
			LogAllErrors(henv,hdbc,hstmt);
			TEST_FAILED;
			}
		else{
			returncode = SQLExecute(hstmt);
			if(!CHECKRC(SQL_ERROR,returncode,"SQLExecute")){
				LogAllErrors(henv,hdbc,hstmt);
				TEST_FAILED;
				}
			}
		}
	TESTCASE_END;

	TESTCASE_BEGIN("Test #8: Negative Functionality of SQLExecute with invalid handle\n");
	returncode = SQLPrepare(hstmt,(SQLTCHAR*)ExecStr[2],_tcslen(ExecStr[2]));
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLPrepare")){
		LogAllErrors(henv,hdbc,hstmt);
		TEST_FAILED;
		}
	else{
		returncode = SQLExecute((SQLHANDLE)NULL); 
		if(!CHECKRC(SQL_INVALID_HANDLE,returncode,"SQLExecute")){
			LogAllErrors(henv,hdbc,hstmt);
			TEST_FAILED;
			}
		}
	TESTCASE_END;

	returncode = SQLExecDirect(hstmt,(SQLTCHAR*)ExecStr[0],_tcslen(ExecStr[0])); /* cleanup */
 
	TESTCASE_BEGIN("Test #9: Stress Positive Functionality of SQLExecute.\n");
	returncode = SQLExecDirect(hstmt,(SQLTCHAR*)ExecStr[11],SQL_NTS);

	returncode = SQLExecDirect(hstmt,(SQLTCHAR*)ExecStr[12],SQL_NTS); 
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect"))
	{
		TEST_FAILED;
		LogAllErrors(henv,hdbc,hstmt);
	}
	else
	{
		returncode = SQLPrepare(hstmt,(SQLTCHAR*)ExecStr[13],SQL_NTS); 
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLPrepare"))
		{
			TEST_FAILED;
			LogAllErrors(henv,hdbc,hstmt);
		}
		else
		{
			actual_insert = 0;
			for (num_insert = 0; num_insert < MAX_INSERTED_ROWS; num_insert++)
			{
				returncode = SQLExecute(hstmt);
				if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecute"))
				{
					TEST_FAILED;
					LogAllErrors(henv,hdbc,hstmt);
				}
				else
					actual_insert++;
			}
			if (actual_insert != MAX_INSERTED_ROWS)
			{
				TEST_FAILED;
				LogMsg(ERRMSG,_T("failed to insert rows actual => %d & excepted => %d.\n"),actual_insert,MAX_INSERTED_ROWS);
			}
		}
	}

	SQLExecDirect(hstmt,(SQLTCHAR*)ExecStr[11],SQL_NTS); 
	TESTCASE_END;
 
	TESTCASE_BEGIN("Test #10: Stress Positive Functionality of SQLExecute with Params.\n");
	returncode = SQLExecDirect(hstmt,(SQLTCHAR*)ExecStr[11],SQL_NTS); 

	returncode = SQLExecDirect(hstmt,(SQLTCHAR*)ExecStr[12],SQL_NTS); 
	LogMsg(NONE,_T("ExecStr[12]: %s\n"), ExecStr[12]);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect"))
	{
		TEST_FAILED;
		LogAllErrors(henv,hdbc,hstmt);
	}
	else
	{
		returncode = SQLPrepare(hstmt,(SQLTCHAR*)ExecStr[14],SQL_NTS); 
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLPrepare"))
		{
			TEST_FAILED;
			LogAllErrors(henv,hdbc,hstmt);
		}
		else
		{
			actual_insert = 0;
			returncode = SQLNumParams(hstmt, &param);
			if(!CHECKRC(SQL_SUCCESS,returncode,"SQLNumParams"))
			{
				LogAllErrors(henv,hdbc,hstmt);
				TEST_FAILED;
			}
			for (num_insert = 0; num_insert < MAX_INSERTED_ROWS; num_insert++)
			{
				for (i = 0; i < param; i++)
				{
					if (i==0) Type[0] = 1;

					if (MX_MP_SPECIFIC == MX_SPECIFIC)
					{
						returncode = SQLBindParameter(hstmt,(SWORD)(i+1),SQL_PARAM_INPUT,SQL_C_TCHAR,Type[i],ColPrec[i],ColScale[i],szInput[i],0,&cbInput);
					}
					else
					{
						returncode = SQLBindParameter(hstmt,(SWORD)(i+1),SQL_PARAM_INPUT,SQL_C_TCHAR,Type[i],ColPrec[i],ColScale[i],szInput[i],300,&cbInput);
					}
					if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindParameter"))
					{
						LogAllErrors(henv,hdbc,hstmt);
						TEST_FAILED;
					}
				}
				returncode = SQLExecute(hstmt);
				if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecute"))
				{
					TEST_FAILED;
					LogAllErrors(henv,hdbc,hstmt);
				}
				else
					actual_insert++;
			}
			if (actual_insert != MAX_INSERTED_ROWS)
			{
				TEST_FAILED;
				LogMsg(ERRMSG,_T("failed to insert rows actual => %d & excepted => %d.\n"),actual_insert,MAX_INSERTED_ROWS);
			}
		}
	}

	SQLExecDirect(hstmt,(SQLTCHAR*)ExecStr[11],SQL_NTS); 
	TESTCASE_END;

	TESTCASE_BEGIN("Test #11: Negative Functionality of SQLExecute with already existing table\n");
	returncode = SQLFreeStmt(hstmt,SQL_DROP);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLFreeStmt"))
	{
		LogAllErrors(henv,hdbc,hstmt);
		TEST_FAILED;
	}
	else
	{
		returncode = SQLAllocStmt((SQLHANDLE)hdbc, &hstmt);
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLAllocStmt"))
		{
			LogAllErrors(henv,hdbc,hstmt);
			TEST_FAILED;
		}
		else
		{
			SQLExecDirect(hstmt,(SQLTCHAR*)ExecStr[0],_tcslen(ExecStr[0])); /* cleanup */
			returncode = SQLPrepare(hstmt,(SQLTCHAR*)ExecStr[1],_tcslen(ExecStr[1]));
			if(!CHECKRC(SQL_SUCCESS,returncode,"SQLPrepare"))
			{
				LogAllErrors(henv,hdbc,hstmt);
				TEST_FAILED;
			}
			else
			{
				returncode = SQLExecute(hstmt); 
				if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecute"))
				{
					LogAllErrors(henv,hdbc,hstmt);
					TEST_FAILED;
				}
				else
				{
					returncode = SQLExecute(hstmt); 
					if(!CHECKRC(SQL_ERROR,returncode,"SQLExecute"))
					{
						LogAllErrors(henv,hdbc,hstmt);
						TEST_FAILED;
					}
				}
			}
			SQLExecDirect(hstmt,(SQLTCHAR*)ExecStr[0],_tcslen(ExecStr[0])); /* cleanup */
		}
	}
	TESTCASE_END;

//=================================================================================================
	
	FullDisconnect(pTestInfo);
	LogMsg(SHORTTIMESTAMP+LINEAFTER,_T("End testing API => SQLExecute.\n"));
	free_list(var_list);
	TEST_RETURN;
}
Beispiel #26
0
/*
---------------------------------------------------------
   TestSQLError Minimum tests since this is tested all over the places
---------------------------------------------------------
*/
PassFail TestSQLError(TestInfo *pTestInfo)
{                  
	TEST_DECLARE;
	RETCODE		returncode;
	SQLHANDLE 	henv;
	SQLHANDLE 	hdbc;
	SQLHANDLE	hstmt;
	CHAR		SqlState[STATE_SIZE];
	SDWORD		NativeError;
	CHAR		ErrorMsg[MAX_STRING_SIZE];
	SWORD		ErrorMsglen;

	CHAR		*CrtTab = "--";

//===========================================================================================================
	var_list_t *var_list;
	var_list = load_api_vars("SQLError", charset_file);
	if (var_list == NULL) return FAILED;

	CrtTab = var_mapping("SQLError_CrtTab", var_list);
//===========================================================================================================

	LogMsg(LINEBEFORE+SHORTTIMESTAMP,"Begin testing API =>SQLError | SQLError | error.c\n");
	
  TEST_INIT;

	returncode=FullConnect(pTestInfo);
  if (pTestInfo->hdbc == (SQLHANDLE)NULL)
	{
		TEST_FAILED;
		TEST_RETURN;
	}

	henv = pTestInfo->henv;
 	hdbc = pTestInfo->hdbc;
 	hstmt = pTestInfo->hstmt;

	returncode = SQLAllocStmt((SQLHANDLE)hdbc, &hstmt);	
  if (returncode == SQL_SUCCESS)
	{
		TESTCASE_BEGIN("Test syntax while creating a table SQLError\n");
		returncode = SQLExecDirect(hstmt,(SQLCHAR*)CrtTab,SQL_NTS);
	  if (returncode == SQL_ERROR)
		{
			returncode = SQLError((SQLHANDLE)henv, (SQLHANDLE)hdbc, hstmt, (SQLCHAR*)SqlState, &NativeError, (SQLCHAR*)ErrorMsg, MAX_STRING_SIZE, &ErrorMsglen);
			if(!CHECKRC(SQL_SUCCESS,returncode,"SQLError"))
			{
				TEST_FAILED;
				LogAllErrors(henv,hdbc,hstmt);
			}
			else
			{
				LogMsg(NONE,"SqlState: %s and ErrorMsg: %s\n",SqlState,ErrorMsg);
				TESTCASE_END;
			}
		}
	}
	FullDisconnect(pTestInfo);
	LogMsg(SHORTTIMESTAMP+LINEAFTER,"End testing API => SQLError.\n");
	free_list(var_list);
	TEST_RETURN;
}
Beispiel #27
0
/*
------------------------------------------------------------------
   TestSQLGetInfo: Tests SQLGetInfoVer3
------------------------------------------------------------------
*/
PassFail TestMXSQLGetInfoVer3(TestInfo *pTestInfo)
{
	TEST_DECLARE;
	char Heading[MAX_STRING_SIZE];
 	RETCODE	returncode;
 	SQLHANDLE henv;
 	SQLHANDLE hdbc;
 	SQLHANDLE	hstmt;
	union{
	    SQLLEN longInfoValue;//  
		SQLUINTEGER	intInfoValue;
		SQLUSMALLINT smiInfoValue;
		char charInfoValue[MAX_LEN_BUF+1];
		} u1;

	SWORD	pcbInfoValue;
	
	short i;
	char TempString[MAX_STRING_SIZE];
	char ExpectedStr[MAX_LEN_BUF];
	char ActualHex[MAX_STRING_SIZE];
	char ActualStr[MAX_LEN_BUF]; // Changed to reflect the very large amount of data SQL_KEYWORDS returns.
	TrueFalse DifferenceOK;
	
	// The following list of variables are alphabetized, 
	// please try and keep it that way!
	char accessible_procedures[]={"N"};
	char accessible_tables[]={"N"};
	SQLUSMALLINT active_environments = 0;
	SQLUINTEGER aggregate_functions = {SQL_AF_AVG | SQL_AF_COUNT | SQL_AF_MAX | 
										SQL_AF_MIN | SQL_AF_SUM};
	SQLUINTEGER alter_domain=0;
	SQLUINTEGER alter_table=0;
	SQLUINTEGER async_mode=SQL_AM_STATEMENT;
	SQLUINTEGER batch_row_count = 0;
	SQLUINTEGER batch_support = 0;
	SQLUINTEGER bookmark_persistence=0;
	SQLUSMALLINT catalog_location=SQL_CL_START;
	char catalog_name[]={"Y"};
	char catalog_name_separator[]={"."};
	char catalog_term[]={"CATALOG"};
	SQLUINTEGER catalog_usage={SQL_CU_DML_STATEMENTS | SQL_CU_TABLE_DEFINITION |
								SQL_CU_INDEX_DEFINITION};
	char collation_seq[]={"ISO 8859-1"};
	char column_alias[]={"Y"};
	SQLUSMALLINT concat_null_behavior=SQL_CB_NULL;
	SQLUINTEGER convert_bigint={SQL_CVT_CHAR | SQL_CVT_BIGINT | SQL_CVT_DECIMAL | 
								SQL_CVT_DOUBLE | SQL_CVT_FLOAT | SQL_CVT_INTEGER |
								SQL_CVT_LONGVARCHAR | SQL_CVT_NUMERIC | SQL_CVT_REAL |
								SQL_CVT_SMALLINT | SQL_CVT_VARCHAR};
	SQLUINTEGER convert_binary=0;
	SQLUINTEGER convert_bit=0;
	SQLUINTEGER convert_char={SQL_CVT_CHAR | SQL_CVT_BIGINT | SQL_CVT_DATE |
								SQL_CVT_DECIMAL | SQL_CVT_DOUBLE | SQL_CVT_FLOAT |
								SQL_CVT_INTEGER | SQL_CVT_LONGVARCHAR | SQL_CVT_NUMERIC |
								SQL_CVT_REAL | SQL_CVT_SMALLINT | SQL_CVT_TIME |
								SQL_CVT_TIMESTAMP | SQL_CVT_VARCHAR};
	SQLUINTEGER convert_date={SQL_CVT_CHAR | SQL_CVT_DATE | SQL_CVT_LONGVARCHAR | 
								SQL_CVT_TIMESTAMP | SQL_CVT_VARCHAR};
	SQLUINTEGER convert_decimal=convert_bigint;
	SQLUINTEGER convert_double=convert_bigint;
	SQLUINTEGER convert_float=convert_bigint;
	SQLUINTEGER convert_functions=SQL_FN_CVT_CONVERT;
	SQLUINTEGER convert_integer=convert_bigint;
	SQLUINTEGER convert_interval_day_time = 0;
	SQLUINTEGER convert_interval_year_month = 0;
	SQLUINTEGER convert_longvarbinary=0;
#ifdef unixcli
        SQLUINTEGER convert_longvarchar=convert_char;
#else
        SQLUINTEGER convert_longvarchar=0;
#endif
	SQLUINTEGER convert_numeric=convert_bigint;
	SQLUINTEGER convert_real=convert_bigint;
	SQLUINTEGER convert_smallint=convert_bigint;
	SQLUINTEGER convert_time={SQL_CVT_CHAR | SQL_CVT_LONGVARCHAR | SQL_CVT_TIME |
								SQL_CVT_TIMESTAMP | SQL_CVT_VARCHAR};
	SQLUINTEGER convert_timestamp={SQL_CVT_CHAR | SQL_CVT_DATE | SQL_CVT_LONGVARCHAR | 
									SQL_CVT_TIME | SQL_CVT_TIMESTAMP | SQL_CVT_VARCHAR};
	SQLUINTEGER convert_tinyint=0;
	SQLUINTEGER convert_varbinary=0;
	SQLUINTEGER convert_varchar=convert_char;
        /* sq
        SQLUINTEGER convert_wchar = 0;
        SQLUINTEGER convert_wlongvarchar = 0;
        SQLUINTEGER convert_wvarchar = 0;
        */
/* sq new */
        SQLUINTEGER convert_wchar={SQL_CVT_CHAR | SQL_CVT_BIGINT | SQL_CVT_DATE
|
                                                                SQL_CVT_DECIMAL
| SQL_CVT_DOUBLE | SQL_CVT_FLOAT |
                                                                SQL_CVT_INTEGER
| SQL_CVT_NUMERIC | SQL_CVT_REAL |
                                                                SQL_CVT_SMALLINT
 | SQL_CVT_TIME | SQL_CVT_TIMESTAMP |
                                                                SQL_CVT_VARCHAR
| SQL_CVT_WCHAR | SQL_CVT_WVARCHAR};
#ifdef unixcli
        SQLUINTEGER convert_wlongvarchar = convert_wchar;
#else
        SQLUINTEGER convert_wlongvarchar = 0;
#endif
        SQLUINTEGER convert_wvarchar = convert_wchar;
/* end of sq new */
	SQLUSMALLINT correlation_name=SQL_CN_ANY;
	SQLUINTEGER create_assertion = 0;
	SQLUINTEGER create_character_set = 0;
	SQLUINTEGER create_collation = 0;
	SQLUINTEGER create_domain = 0;
	SQLUINTEGER create_schema = 0;
	SQLUINTEGER create_table = {SQL_CT_CREATE_TABLE};
	SQLUINTEGER create_translation = 0;
	SQLUINTEGER create_view = {SQL_CV_CREATE_VIEW | SQL_CV_CHECK_OPTION | SQL_CV_CASCADED};
	// (replaced with above) SQLUINTEGER create_view = {SQL_CV_CREATE_VIEW};
	SQLUSMALLINT cursor_commit_behavior=SQL_CB_CLOSE;
	SQLUSMALLINT cursor_rollback_behavior=SQL_CB_CLOSE;
	SQLUINTEGER cursor_sensitivity=SQL_UNSPECIFIED;
	char data_source_name[60];
	char data_source_read_only[]={"N"};
	char database_name[60];
	SQLUINTEGER datetime_literals = {SQL_DL_SQL92_DATE | SQL_DL_SQL92_TIME | SQL_DL_SQL92_TIMESTAMP | SQL_DL_SQL92_INTERVAL_YEAR |
		SQL_DL_SQL92_INTERVAL_MONTH | SQL_DL_SQL92_INTERVAL_DAY |
		SQL_DL_SQL92_INTERVAL_HOUR | SQL_DL_SQL92_INTERVAL_MINUTE |
		SQL_DL_SQL92_INTERVAL_SECOND | SQL_DL_SQL92_INTERVAL_YEAR_TO_MONTH |
		SQL_DL_SQL92_INTERVAL_DAY_TO_HOUR | SQL_DL_SQL92_INTERVAL_DAY_TO_MINUTE |
		SQL_DL_SQL92_INTERVAL_DAY_TO_SECOND |SQL_DL_SQL92_INTERVAL_HOUR_TO_MINUTE |
		SQL_DL_SQL92_INTERVAL_HOUR_TO_SECOND | SQL_DL_SQL92_INTERVAL_MINUTE_TO_SECOND};
	char dbms_name[]={"Trafodion"};
	char dbms_ver[]=/* sq {"02.03.0054"} */ {"0.8.0"};
	SQLUINTEGER ddl_index = {SQL_DI_CREATE_INDEX | SQL_DI_DROP_INDEX};
	SQLUINTEGER default_txn_isolation=SQL_TXN_READ_COMMITTED;
	char describe_parameter[]={"Y"};
	char dm_ver[] = {"03.51.4202.0000"};  //must be greatr than 3.51.0: checking in test code
	SQLUINTEGER driver_hdbc=0;
	SQLUINTEGER driver_henv=0;
	SQLUINTEGER driver_hlib=0;
	SQLUINTEGER driver_hstmt=0;
#ifdef unixcli
	char driver_name[]={"libhpodbc"};
#else
	char driver_name[]={"HP_ODBC0200.DLL"};
#endif /* WIN32 */
	char driver_odbc_ver[]={"03.51"};
	char driver_ver[]=/* SEAQUSET {"02.03"} */ {"03.00"};
	SQLUINTEGER drop_assertion = 0;
	SQLUINTEGER drop_character_set = 0;
	SQLUINTEGER drop_collation = 0;
	SQLUINTEGER drop_domain = 0;
	SQLUINTEGER drop_schema = 0;
	SQLUINTEGER drop_table = {SQL_DT_DROP_TABLE | SQL_DT_RESTRICT | SQL_DT_CASCADE};
	// (replaced with above) SQLUINTEGER drop_table = {SQL_DT_DROP_TABLE};
	SQLUINTEGER drop_translation = 0;
	SQLUINTEGER drop_view = {SQL_DV_DROP_VIEW | SQL_DV_RESTRICT | SQL_DV_CASCADE};
	// (replaced with above) SQLUINTEGER drop_view = {SQL_DV_DROP_VIEW};
	SQLUINTEGER dynamic_cursor_attributes1 = 0;
	SQLUINTEGER dynamic_cursor_attributes2 = 0;
	char expressions_in_orderby[]={"N"};
	SQLUINTEGER fetch_direction=SQL_FD_FETCH_NEXT;
	SQLUSMALLINT file_usage=SQL_FILE_NOT_SUPPORTED;
	SQLUINTEGER forward_only_cursor_attributes1={SQL_CA1_NEXT | SQL_CA1_SELECT_FOR_UPDATE};
	SQLUINTEGER forward_only_cursor_attributes2={SQL_CA2_READ_ONLY_CONCURRENCY |
													SQL_CA2_LOCK_CONCURRENCY |
													SQL_CA2_MAX_ROWS_SELECT};
	SQLUINTEGER getdata_extensions={SQL_GD_ANY_COLUMN | SQL_GD_ANY_ORDER | SQL_GD_BOUND};
	SQLUSMALLINT group_by=SQL_GB_GROUP_BY_EQUALS_SELECT;
	SQLUSMALLINT identifier_case=SQL_IC_UPPER;
	char identifier_quote_char[]={"\""};
	SQLUINTEGER index_keywords = {SQL_IK_ASC | SQL_IK_DESC};
	SQLUINTEGER info_schema_views = 0;
	SQLUINTEGER insert_statement = {SQL_IS_INSERT_LITERALS | SQL_IS_INSERT_SEARCHED |
									SQL_IS_SELECT_INTO};
	char integrity[]={"N"};
	SQLUINTEGER keyset_cursor_attributes1 = 0;
	SQLUINTEGER keyset_cursor_attributes2 = 0;
	char keywords[] ={"ABS,AFTER,ALIAS,BEFORE,BOOLEAN,BREADTH,CALL,COMPLETION,CONVERTTIMESTAMP,CYCLE,DATEFORMAT,DAYOFWEEK,DEPTH,DICTIONARY,EACH,EQUALS,GENERAL,IF,IGNORE,INDEX_TABLE,INVOKE,JULIANTIMESTAMP,LEAVE,LESS,LIMIT,LOAD_TABLE,LOOP,MODIFY,NEW,OBJECT,OFF,OID,OLD,OPERATION,OPERATORS,OTHERS,PARAMETERS,PENDANT,PREORDER,PRIVATE,PROTECTED,PROTOTYPE,RECURSIVE,REF,REFERENCING,REPLACE,RESIGNAL,RESOURCE_FORK,RETURN,RETURNS,ROLE,ROUTINE,ROW,SAVEPOINT,SEARCH,SENSITIVE,SHOWDDL,SHOWPLAN,SIGNAL,SIMILAR,SQLEXCEPTION,STDDEV,STRUCTURE,TEST,THERE,TRANSPOSE,TRIGGER,TYPE,UNDER,UPSHIFT,VARIABLE,VARIANCE,VIRTUAL,WAIT,WHILE,WITHOUT"};
	char like_escape_clause[]={"Y"};
	SQLUINTEGER lock_types = 0;
	SQLUINTEGER max_async_concurrent_statements=0;
	SQLUINTEGER max_binary_literal_len=8100;
	SQLUSMALLINT max_catalog_name_len=128; //Changed to 128 in R2.2
	SQLUINTEGER max_char_literal_len=4050; 
	SQLUSMALLINT max_column_name_len=128;	//Changed to 128 in R2.2
	SQLUSMALLINT max_columns_in_group_by=0;
	SQLUSMALLINT max_columns_in_index=0;
	SQLUSMALLINT max_columns_in_order_by=0;
	SQLUSMALLINT max_columns_in_select=0;
	SQLUSMALLINT max_columns_in_table=0;
	SQLUSMALLINT max_concurrent_activities=0;  // zero for unlimit
	SQLUSMALLINT max_cursor_name_len=128; //Changed to 128 in R2.2
	SQLUSMALLINT max_driver_connections=0;
	SQLUSMALLINT max_identifier_len=128; //Changed to 128 in R2.2
	SQLUINTEGER max_index_size=4050;
	SQLUSMALLINT max_procedure_name_len=128;
	SQLUINTEGER max_row_size=4050;
	char max_row_size_includes_long[]={"Y"};
	SQLUSMALLINT max_schema_name_len=128;	//Changed to 128 in R2.2
	SQLUINTEGER max_statement_len=0;
	SQLUSMALLINT max_table_name_len=128;	//Changed to 128 in R2.2
	SQLUSMALLINT max_tables_in_select=0;
	SQLUSMALLINT max_user_name_len=32;
	char mult_result_sets[]={"N"};
	char multiple_active_txn[]={"N"};
	char need_long_data_len[]={"N"};
	SQLUSMALLINT non_nullable_columns=SQL_NNC_NON_NULL;
	SQLUSMALLINT null_collation=SQL_NC_HIGH;
	SQLUINTEGER numeric_functions={SQL_FN_NUM_ABS | SQL_FN_NUM_ACOS | SQL_FN_NUM_ASIN | 
									SQL_FN_NUM_ATAN | SQL_FN_NUM_ATAN2 | SQL_FN_NUM_CEILING | 
									SQL_FN_NUM_COS | SQL_FN_NUM_DEGREES | SQL_FN_NUM_EXP | 
									SQL_FN_NUM_FLOOR | SQL_FN_NUM_LOG | SQL_FN_NUM_LOG10 | 
									SQL_FN_NUM_MOD | SQL_FN_NUM_PI | SQL_FN_NUM_POWER | 
									SQL_FN_NUM_RADIANS | SQL_FN_NUM_RAND | SQL_FN_NUM_SIGN | 
									SQL_FN_NUM_SIN | SQL_FN_NUM_SQRT | SQL_FN_NUM_TAN};
	SQLUSMALLINT odbc_api_conformance=SQL_OAC_LEVEL2;
	SQLUINTEGER odbc_interface_conformance = {SQL_OIC_CORE};
	SQLUSMALLINT odbc_sql_conformance = {SQL_OSC_CORE};
	char odbc_ver[]=/* sq {"03.52.0000"} */ {"03.51"};
	SQLUINTEGER oj_capabilities={SQL_OJ_LEFT | SQL_OJ_RIGHT | SQL_OJ_NESTED | 
									SQL_OJ_NOT_ORDERED | SQL_OJ_INNER |
									SQL_OJ_ALL_COMPARISON_OPS | SQL_OJ_FULL};
	char order_by_columns_in_select[]={"N"};
	char outer_joins[]={"Y"};
	SQLUINTEGER param_array_roy_counts = SQL_PARC_NO_BATCH;
	SQLUINTEGER param_array_selects = SQL_PAS_NO_SELECT;
	SQLUINTEGER pos_operations = 0;
	SQLUINTEGER positioned_statements = {SQL_PS_POSITIONED_DELETE |
											SQL_PS_POSITIONED_UPDATE |
											SQL_PS_SELECT_FOR_UPDATE};
	char procedure_term[]={"PROCEDURE"};
	char procedures[]={"Y"};
	SQLUSMALLINT quoted_identifier_case=SQL_IC_SENSITIVE;
	char row_updates[]={"N"};
	char schema_term[]={"SCHEMA"};
	SQLUINTEGER schema_usage={SQL_SU_DML_STATEMENTS | SQL_SU_TABLE_DEFINITION |
								SQL_SU_PRIVILEGE_DEFINITION};
	SQLUINTEGER scroll_concurrency = {SQL_SCCO_LOCK};
	SQLUINTEGER scroll_options=SQL_SO_FORWARD_ONLY;
	char search_pattern_escape[]={"\\"};
	SQLUINTEGER sql_conformance = {SQL_SC_SQL92_ENTRY};
	SQLUINTEGER sql92_datetime_functions = {SQL_SDF_CURRENT_DATE | SQL_SDF_CURRENT_TIME |
											SQL_SDF_CURRENT_TIMESTAMP};
	SQLUINTEGER sql92_foreign_key_delete_rule = 0;
	SQLUINTEGER sql92_foreign_key_update_rule = 0;
	SQLUINTEGER sql92_grant = 0;
	SQLUINTEGER sql92_numeric_value_functions = {SQL_SNVF_CHAR_LENGTH |
													SQL_SNVF_CHARACTER_LENGTH | 
													SQL_SNVF_EXTRACT | SQL_SNVF_OCTET_LENGTH |
													SQL_SNVF_POSITION};
	SQLUINTEGER sql92_predicates = {SQL_SP_EXISTS | SQL_SP_ISNOTNULL | SQL_SP_ISNULL |
									SQL_SP_MATCH_FULL | SQL_SP_MATCH_PARTIAL | SQL_SP_LIKE |
									SQL_SP_IN | SQL_SP_BETWEEN | SQL_SP_COMPARISON |
									SQL_SP_QUANTIFIED_COMPARISON};
	SQLUINTEGER sql92_relational_join_operators = {SQL_SRJO_CORRESPONDING_CLAUSE |
													SQL_SRJO_CROSS_JOIN |
													SQL_SRJO_FULL_OUTER_JOIN |
													SQL_SRJO_INNER_JOIN |
													SQL_SRJO_LEFT_OUTER_JOIN |
													SQL_SRJO_NATURAL_JOIN |
													SQL_SRJO_RIGHT_OUTER_JOIN |
													SQL_SRJO_UNION_JOIN};
	SQLUINTEGER sql92_revoke = 0;
	SQLUINTEGER sql92_row_value_constructor = 0;
	SQLUINTEGER sql92_string_functions = {SQL_SSF_CONVERT | SQL_SSF_LOWER | SQL_SSF_UPPER |
											SQL_SSF_SUBSTRING | SQL_SSF_TRIM_BOTH |
											SQL_SSF_TRIM_LEADING | SQL_SSF_TRIM_TRAILING};
	SQLUINTEGER sql92_value_expressions = {SQL_SVE_CASE | SQL_SVE_CAST};
	SQLUINTEGER standard_cli_conformance = {SQL_SCC_XOPEN_CLI_VERSION1 | SQL_SCC_ISO92_CLI};
/*	SQLUINTEGER static_cursor_attributes1={SQL_CA1_NEXT | SQL_CA1_POSITIONED_UPDATE |
											SQL_CA1_POSITIONED_DELETE | SQL_CA1_SELECT_FOR_UPDATE};*/
	SQLUINTEGER static_cursor_attributes1 = 0;
	SQLUINTEGER static_cursor_attributes2 = 0;
//  char server_name[]={"TDM_Default_DataSource"};
	char server_name[128];
	char special_characters[]={"$\\"};
	SQLUINTEGER static_sensitivity = {SQL_SS_ADDITIONS | SQL_SS_DELETIONS | SQL_SS_UPDATES};
	SQLUINTEGER string_functions={SQL_FN_STR_ASCII | SQL_FN_STR_CHAR | SQL_FN_STR_CONCAT | 
									SQL_FN_STR_INSERT | SQL_FN_STR_LCASE | SQL_FN_STR_LEFT | 
									SQL_FN_STR_LENGTH | SQL_FN_STR_LOCATE_2 | SQL_FN_STR_LTRIM | 
									SQL_FN_STR_REPEAT | SQL_FN_STR_REPLACE | SQL_FN_STR_RIGHT | 
									SQL_FN_STR_RTRIM | SQL_FN_STR_SPACE | SQL_FN_STR_SUBSTRING | 
									SQL_FN_STR_UCASE };
	SQLUINTEGER subqueries={SQL_SQ_CORRELATED_SUBQUERIES | SQL_SQ_COMPARISON |
							SQL_SQ_EXISTS | SQL_SQ_IN | SQL_SQ_QUANTIFIED};
	SQLUINTEGER system_functions={SQL_FN_SYS_USERNAME};
	char table_term[]={"TABLE"};
	SQLUINTEGER timedate_add_intervals={SQL_FN_TSI_FRAC_SECOND | SQL_FN_TSI_SECOND |
										SQL_FN_TSI_MINUTE | SQL_FN_TSI_HOUR |
										SQL_FN_TSI_DAY | SQL_FN_TSI_WEEK |
										SQL_FN_TSI_MONTH | SQL_FN_TSI_YEAR};
	SQLUINTEGER timedate_diff_intervals={SQL_FN_TSI_FRAC_SECOND | SQL_FN_TSI_SECOND |
											SQL_FN_TSI_MINUTE | SQL_FN_TSI_HOUR |
											SQL_FN_TSI_DAY | SQL_FN_TSI_WEEK |
											SQL_FN_TSI_MONTH | SQL_FN_TSI_YEAR};
	SQLUINTEGER timedate_functions={SQL_FN_TD_DAYOFMONTH
										 | SQL_FN_TD_DAYOFWEEK | SQL_FN_TD_DAYOFYEAR | SQL_FN_TD_MONTH | SQL_FN_TD_QUARTER
										 | SQL_FN_TD_WEEK | SQL_FN_TD_YEAR | SQL_FN_TD_HOUR | SQL_FN_TD_MINUTE | SQL_FN_TD_SECOND
										 | SQL_FN_TD_DAYNAME | SQL_FN_TD_MONTHNAME | SQL_FN_TD_CURRENT_DATE | SQL_FN_TD_CURRENT_TIME
										 | SQL_FN_TD_CURRENT_TIMESTAMP};
	SQLUSMALLINT txn_capable=SQL_TC_ALL;
	SQLUINTEGER txn_isolation_option={SQL_TXN_READ_UNCOMMITTED | SQL_TXN_READ_COMMITTED |
										SQL_TXN_REPEATABLE_READ | SQL_TXN_SERIALIZABLE};
	SQLUINTEGER sql_union={SQL_U_UNION};
	char user_name[100]; // size is based upon SQL_MAX_USER_NAME_LEN
	char xopen_cli_year[] = {"1995"};


	// The SQLGetInfo options initialized in this structure are in alphabetical
	// order to make it easier to maintain.  Please try and keep it that way
	struct{
		SQLUSMALLINT	InfoType;
		SQLPOINTER		pInfoValue;
		long			InfoValueLength;	// equals zero if variable length string returned
	} ExpectedResults[] = {
		{SQL_ACCESSIBLE_PROCEDURES,accessible_procedures,1},
		{SQL_ACCESSIBLE_TABLES,accessible_tables,1},
		{SQL_ACTIVE_ENVIRONMENTS,&active_environments, 2},
		{SQL_AGGREGATE_FUNCTIONS, &aggregate_functions, 4},
		{SQL_ALTER_DOMAIN, &alter_domain, 4},
		{SQL_ALTER_TABLE,&alter_table,4},
		{SQL_ASYNC_MODE,&async_mode,4},
		{SQL_BATCH_ROW_COUNT, &batch_row_count, 4},
		{SQL_BATCH_SUPPORT, &batch_support, 4},
		{SQL_BOOKMARK_PERSISTENCE,&bookmark_persistence,4},
		{SQL_CATALOG_LOCATION,&catalog_location,2},
		{SQL_CATALOG_NAME,catalog_name,1},
		{SQL_CATALOG_NAME_SEPARATOR,catalog_name_separator,1},
		{SQL_CATALOG_TERM,catalog_term,strlen(catalog_term)},
		{SQL_CATALOG_USAGE,&catalog_usage,4},
		{SQL_COLLATION_SEQ,collation_seq,strlen(collation_seq)},
		{SQL_COLUMN_ALIAS,column_alias,strlen(column_alias)},
		{SQL_CONCAT_NULL_BEHAVIOR,&concat_null_behavior,2},
		{SQL_CONVERT_BIGINT,&convert_bigint,4},
		{SQL_CONVERT_BINARY,&convert_binary,4},
		{SQL_CONVERT_BIT,&convert_bit,4},
		{SQL_CONVERT_CHAR,&convert_char,4},
		{SQL_CONVERT_DATE,&convert_date,4},
		{SQL_CONVERT_DECIMAL,&convert_decimal,4},
		{SQL_CONVERT_DOUBLE,&convert_double,4},
		{SQL_CONVERT_FLOAT,&convert_float,4},
		{SQL_CONVERT_FUNCTIONS,&convert_functions,4},
		{SQL_CONVERT_INTERVAL_DAY_TIME, &convert_interval_day_time, 4},
		{SQL_CONVERT_INTERVAL_YEAR_MONTH, &convert_interval_year_month, 4},
		{SQL_CONVERT_INTEGER,&convert_integer,4},
		{SQL_CONVERT_LONGVARBINARY,&convert_longvarbinary,4},
		{SQL_CONVERT_LONGVARCHAR,&convert_longvarchar,4},
		{SQL_CONVERT_NUMERIC,&convert_numeric,4},
		{SQL_CONVERT_REAL,&convert_real,4},
		{SQL_CONVERT_SMALLINT,&convert_smallint,4},
		{SQL_CONVERT_TIME,&convert_time,4},
		{SQL_CONVERT_TIMESTAMP,&convert_timestamp,4},
		{SQL_CONVERT_TINYINT,&convert_tinyint,4},
		{SQL_CONVERT_VARBINARY,&convert_varbinary,4},
		{SQL_CONVERT_VARCHAR,&convert_varchar,4},
		{SQL_CONVERT_WCHAR, &convert_wchar, 4},
		{SQL_CONVERT_WLONGVARCHAR, &convert_wlongvarchar, 4},
		{SQL_CONVERT_WVARCHAR, &convert_wvarchar, 4},
		{SQL_CORRELATION_NAME,&correlation_name,2},
		{SQL_CREATE_ASSERTION, &create_assertion, 4},
		{SQL_CREATE_CHARACTER_SET, &create_character_set, 4},
		{SQL_CREATE_COLLATION, &create_collation, 4},
		{SQL_CREATE_DOMAIN, &create_domain, 4},
		{SQL_CREATE_SCHEMA, &create_schema, 4},
		{SQL_CREATE_TABLE, &create_table, 4},
		{SQL_CREATE_TRANSLATION, &create_translation, 4},
		{SQL_CREATE_VIEW, &create_view, 4},
		{SQL_CURSOR_COMMIT_BEHAVIOR,&cursor_commit_behavior,2},
		{SQL_CURSOR_ROLLBACK_BEHAVIOR,&cursor_rollback_behavior,2},
		{SQL_CURSOR_SENSITIVITY,&cursor_sensitivity,4},
		{SQL_DATA_SOURCE_NAME,data_source_name,strlen(data_source_name)},
		{SQL_DATA_SOURCE_READ_ONLY,data_source_read_only,1},
		{SQL_DATABASE_NAME,database_name,strlen(database_name)},
		{SQL_DATETIME_LITERALS, &datetime_literals, 4},
		{SQL_DBMS_NAME,dbms_name,strlen(dbms_name)},
		{SQL_DBMS_VER,dbms_ver,strlen(dbms_ver)},
		{SQL_DDL_INDEX, &ddl_index, 4},
		{SQL_DEFAULT_TXN_ISOLATION,&default_txn_isolation,4},
		{SQL_DESCRIBE_PARAMETER,describe_parameter,1},
		{SQL_DM_VER, dm_ver, strlen(dm_ver)},
#ifdef _LP64 //  
        {SQL_DRIVER_HDBC,&driver_hdbc,8},
        {SQL_DRIVER_HENV,&driver_henv,8},
#else
        {SQL_DRIVER_HDBC,&driver_hdbc,4},
        {SQL_DRIVER_HENV,&driver_henv,4},
#endif
/* sq */ #ifndef unixcli
		{SQL_DRIVER_HLIB,&driver_hlib,4},
/* SEAQUSET */ #endif
#ifdef _LP64 //  
		{SQL_DRIVER_HSTMT,&driver_hstmt,8},
#else
		{SQL_DRIVER_HSTMT,&driver_hstmt,4},
#endif
		{SQL_DRIVER_NAME,driver_name,strlen(driver_name)},
		{SQL_DRIVER_ODBC_VER,driver_odbc_ver,strlen(driver_odbc_ver)},
		{SQL_DRIVER_VER,driver_ver,strlen(driver_ver)},
		{SQL_DROP_ASSERTION, &drop_assertion, 4},
		{SQL_DROP_CHARACTER_SET, &drop_character_set, 4},
		{SQL_DROP_COLLATION, &drop_collation, 4},
		{SQL_DROP_DOMAIN, &drop_domain, 4},
		{SQL_DROP_SCHEMA, &drop_schema, 4},
		{SQL_DROP_TABLE, &drop_table, 4},
		{SQL_DROP_TRANSLATION, &drop_translation, 4},
		{SQL_DROP_VIEW, &drop_view, 4},
		{SQL_DYNAMIC_CURSOR_ATTRIBUTES1,&dynamic_cursor_attributes1,4},
		{SQL_DYNAMIC_CURSOR_ATTRIBUTES2, &dynamic_cursor_attributes2, 4},
		{SQL_EXPRESSIONS_IN_ORDERBY,expressions_in_orderby,1},
		{SQL_FETCH_DIRECTION,&fetch_direction,4},
		{SQL_FILE_USAGE,&file_usage,2},
		{SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES1,&forward_only_cursor_attributes1,4},
		{SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES2, &forward_only_cursor_attributes2, 4},
		{SQL_GETDATA_EXTENSIONS,&getdata_extensions,4},
		{SQL_GROUP_BY,&group_by,2},
		{SQL_IDENTIFIER_CASE,&identifier_case,2},
		{SQL_IDENTIFIER_QUOTE_CHAR,identifier_quote_char,1},
		{SQL_INDEX_KEYWORDS, &index_keywords, 4},
		{SQL_INFO_SCHEMA_VIEWS, &info_schema_views, 4},
		{SQL_INSERT_STATEMENT, &insert_statement, 4},
		{SQL_INTEGRITY,integrity,1},
		{SQL_KEYWORDS,keywords,strlen(keywords)},
		{SQL_KEYSET_CURSOR_ATTRIBUTES1,&keyset_cursor_attributes1,4},
		{SQL_KEYSET_CURSOR_ATTRIBUTES2, &keyset_cursor_attributes2, 4},
		{SQL_LIKE_ESCAPE_CLAUSE,like_escape_clause,1},
		{SQL_LOCK_TYPES, &lock_types, 4},
		{SQL_MAX_ASYNC_CONCURRENT_STATEMENTS,&max_async_concurrent_statements,4},
		{SQL_MAX_BINARY_LITERAL_LEN,&max_binary_literal_len,4},
		{SQL_MAX_CATALOG_NAME_LEN,&max_catalog_name_len,2},
		{SQL_MAX_CHAR_LITERAL_LEN,&max_char_literal_len,4},
		{SQL_MAX_COLUMN_NAME_LEN,&max_column_name_len,2},
		{SQL_MAX_COLUMNS_IN_GROUP_BY,&max_columns_in_group_by,2},
		{SQL_MAX_COLUMNS_IN_INDEX,&max_columns_in_index,2},
		{SQL_MAX_COLUMNS_IN_ORDER_BY,&max_columns_in_order_by,2},
		{SQL_MAX_COLUMNS_IN_SELECT,&max_columns_in_select,2},
		{SQL_MAX_COLUMNS_IN_TABLE,&max_columns_in_table,2},
		{SQL_MAX_CONCURRENT_ACTIVITIES,&max_concurrent_activities,2},
		{SQL_MAX_CURSOR_NAME_LEN,&max_cursor_name_len,2},
		{SQL_MAX_DRIVER_CONNECTIONS,&max_driver_connections,2},
		{SQL_MAX_IDENTIFIER_LEN,&max_identifier_len,2},
		{SQL_MAX_INDEX_SIZE,&max_index_size,4},
		{SQL_MAX_PROCEDURE_NAME_LEN,&max_procedure_name_len,2},
		{SQL_MAX_ROW_SIZE,&max_row_size,4},
		{SQL_MAX_ROW_SIZE_INCLUDES_LONG,max_row_size_includes_long,1},
		{SQL_MAX_SCHEMA_NAME_LEN,&max_schema_name_len,2},
		{SQL_MAX_STATEMENT_LEN,&max_statement_len,4},
		{SQL_MAX_TABLE_NAME_LEN,&max_table_name_len,2},
		{SQL_MAX_TABLES_IN_SELECT,&max_tables_in_select,2},
		{SQL_MAX_USER_NAME_LEN,&max_user_name_len,2},
		{SQL_MULT_RESULT_SETS,mult_result_sets,1},
		{SQL_MULTIPLE_ACTIVE_TXN,multiple_active_txn,1},
		{SQL_NEED_LONG_DATA_LEN,need_long_data_len,1},
		{SQL_NON_NULLABLE_COLUMNS,&non_nullable_columns,2},
		{SQL_NULL_COLLATION,&null_collation,2},
		{SQL_NUMERIC_FUNCTIONS,&numeric_functions,4},
		{SQL_ODBC_API_CONFORMANCE,&odbc_api_conformance,2},
		{SQL_ODBC_INTERFACE_CONFORMANCE, &odbc_interface_conformance, 4},
		{SQL_ODBC_SAG_CLI_CONFORMANCE, &odbc_sql_conformance, 2},
		{SQL_ODBC_SQL_CONFORMANCE, &odbc_sql_conformance, 2},
		{SQL_ODBC_VER,odbc_ver,strlen(odbc_ver)},
		{SQL_OJ_CAPABILITIES,&oj_capabilities,4},
		{SQL_ORDER_BY_COLUMNS_IN_SELECT,order_by_columns_in_select,1},
		{SQL_OUTER_JOINS,outer_joins,1},
		{SQL_PARAM_ARRAY_ROW_COUNTS, &param_array_roy_counts, 4},
		{SQL_PARAM_ARRAY_SELECTS, &param_array_selects, 4},
		{SQL_POS_OPERATIONS, &pos_operations, 4},
		{SQL_POSITIONED_STATEMENTS, &positioned_statements, 4},
		{SQL_PROCEDURE_TERM,procedure_term,strlen(procedure_term)},
		{SQL_PROCEDURES,procedures,1},
		{SQL_QUOTED_IDENTIFIER_CASE,&quoted_identifier_case,2},
		{SQL_ROW_UPDATES,row_updates,1},
		{SQL_SCHEMA_TERM,schema_term,strlen(schema_term)},
		{SQL_SCHEMA_USAGE,&schema_usage,4},
		{SQL_SCROLL_CONCURRENCY, &scroll_concurrency, 4},
		{SQL_SCROLL_OPTIONS,&scroll_options,4},
		{SQL_SEARCH_PATTERN_ESCAPE,search_pattern_escape,1},
		{SQL_SERVER_NAME,server_name,strlen(server_name)},
		{SQL_SPECIAL_CHARACTERS,special_characters,strlen(special_characters)},
		{SQL_SQL_CONFORMANCE, &sql_conformance, 4},
		{SQL_SQL92_DATETIME_FUNCTIONS, &sql92_datetime_functions, 4},
		{SQL_SQL92_FOREIGN_KEY_DELETE_RULE, &sql92_foreign_key_delete_rule, 4},
		{SQL_SQL92_FOREIGN_KEY_UPDATE_RULE, &sql92_foreign_key_update_rule, 4},
		{SQL_SQL92_GRANT, &sql92_grant, 4},
		{SQL_SQL92_NUMERIC_VALUE_FUNCTIONS, &sql92_numeric_value_functions, 4},
		{SQL_SQL92_PREDICATES, &sql92_predicates, 4},
		{SQL_SQL92_RELATIONAL_JOIN_OPERATORS, &sql92_relational_join_operators, 4},
		{SQL_SQL92_REVOKE, &sql92_revoke, 4},
		{SQL_SQL92_ROW_VALUE_CONSTRUCTOR, &sql92_row_value_constructor, 4},
		{SQL_SQL92_STRING_FUNCTIONS, &sql92_string_functions, 4},
		{SQL_SQL92_VALUE_EXPRESSIONS, &sql92_value_expressions, 4},
		{SQL_STANDARD_CLI_CONFORMANCE, &standard_cli_conformance, 4},
		{SQL_STATIC_CURSOR_ATTRIBUTES1,&static_cursor_attributes1,4},
		{SQL_STATIC_CURSOR_ATTRIBUTES2, &static_cursor_attributes2, 4},
		{SQL_STATIC_SENSITIVITY, &static_sensitivity, 4},
		{SQL_STRING_FUNCTIONS,&string_functions,4},
		{SQL_SUBQUERIES,&subqueries,4},
		{SQL_SYSTEM_FUNCTIONS,&system_functions,4},
		{SQL_TABLE_TERM,table_term,strlen(table_term)},
		{SQL_TIMEDATE_ADD_INTERVALS,&timedate_add_intervals,4},
		{SQL_TIMEDATE_DIFF_INTERVALS,&timedate_diff_intervals,4},
		{SQL_TIMEDATE_FUNCTIONS,&timedate_functions,4},
		{SQL_TXN_CAPABLE,&txn_capable,2},
		{SQL_TXN_ISOLATION_OPTION,&txn_isolation_option,4},
		{SQL_UNION,&sql_union,4},
		{SQL_USER_NAME,user_name,strlen(user_name)},
		{SQL_XOPEN_CLI_YEAR, xopen_cli_year, strlen(xopen_cli_year)}
	  };

	short TotalOptions=sizeof(ExpectedResults)/sizeof(ExpectedResults[0]);

//=====================Modified for Longvarchar Changes========================================================
	if(!pTestInfo->bLongOn)
	{
		int i = 0;
		convert_bigint = SQL_CVT_CHAR | SQL_CVT_BIGINT | SQL_CVT_DECIMAL | 
								SQL_CVT_DOUBLE | SQL_CVT_FLOAT | SQL_CVT_INTEGER |
								SQL_CVT_VARCHAR | SQL_CVT_NUMERIC | SQL_CVT_REAL |
								SQL_CVT_SMALLINT | SQL_CVT_VARCHAR ;
		convert_char = SQL_CVT_CHAR | SQL_CVT_BIGINT | SQL_CVT_DATE |
								SQL_CVT_DECIMAL | SQL_CVT_DOUBLE | SQL_CVT_FLOAT |
								SQL_CVT_INTEGER | SQL_CVT_VARCHAR | SQL_CVT_NUMERIC |
								SQL_CVT_REAL | SQL_CVT_SMALLINT | SQL_CVT_TIME |
								SQL_CVT_TIMESTAMP | SQL_CVT_VARCHAR;
		convert_date = SQL_CVT_CHAR | SQL_CVT_DATE | SQL_CVT_VARCHAR | 
								SQL_CVT_TIMESTAMP | SQL_CVT_VARCHAR;

		convert_time = SQL_CVT_CHAR | SQL_CVT_VARCHAR | SQL_CVT_TIME |
								SQL_CVT_TIMESTAMP | SQL_CVT_VARCHAR;
		convert_timestamp = SQL_CVT_CHAR | SQL_CVT_DATE | SQL_CVT_VARCHAR | 
									SQL_CVT_TIME | SQL_CVT_TIMESTAMP | SQL_CVT_VARCHAR;
		convert_decimal=convert_bigint;
		convert_double=convert_bigint;
		convert_float=convert_bigint;
		convert_integer=convert_bigint;
		convert_numeric=convert_bigint;
		convert_real=convert_bigint;
	    convert_smallint=convert_bigint;

#ifdef unixcli	
		convert_longvarchar=convert_char;
#else
		convert_longvarchar=0;
#endif
		convert_varchar=convert_char;
	}
//=====================Modified for Longvarchar Changes========================================================
	LogMsg(LINEBEFORE+SHORTTIMESTAMP,"Begin testing API => MX specific SQLGetInfo | SQLGetInfo30 | sqlgetinfover3.c\n");

	TEST_INIT;       
	TESTCASE_BEGIN("Setup for SQLGetInfo tests\n");

	if(!FullConnectWithOptions(pTestInfo, CONNECT_ODBC_VERSION_3))
	{
		LogMsg(NONE,"Unable to connect\n");
		TEST_FAILED;
		TEST_RETURN;
	}

  	/* Set up some local variables to save on typing in longer ones */
	henv = pTestInfo->henv;
	hdbc = pTestInfo->hdbc;
 	hstmt = (SQLHANDLE)pTestInfo->hstmt;
   	
	returncode = SQLAllocHandle(SQL_HANDLE_STMT, (SQLHANDLE)hdbc, &hstmt);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLAllocHandle")){
		LogAllErrorsVer3(henv,hdbc,hstmt);
		TEST_FAILED;
		TEST_RETURN;
	}
	
	TESTCASE_END;

	// Further defining data for some of the test cases that are run-time dependant.
	for (i = 0; i < TotalOptions; i++)
	{
		switch (ExpectedResults[i].InfoType)
		{
			case SQL_DATA_SOURCE_NAME:
				strcpy(data_source_name,pTestInfo->DataSource);
				ExpectedResults[i].InfoValueLength = strlen(data_source_name);
				break;
			case SQL_DATABASE_NAME:
				strcpy(database_name,pTestInfo->Catalog);
				ExpectedResults[i].InfoValueLength = strlen(database_name);
				break;
			case SQL_SERVER_NAME:
				strcpy(server_name,pTestInfo->Server);
				strupr(server_name);
				ExpectedResults[i].InfoValueLength = strlen(server_name);
				break;
			case SQL_USER_NAME:
				//We now return schema as user_name.
				//And now return the login name as user_name. 06/21/07 - R2.2
				strcpy(user_name,pTestInfo->UserID);
				//strcpy(user_name,pTestInfo->Schema);
				ExpectedResults[i].InfoValueLength = strlen(user_name);
			default:
				break;
		}
	}

	// Running tests
	for (i = 0; i < TotalOptions; i++){
		sprintf(Heading,"Test SQLGetInfo(%s)\n",
			InfoTypeToChar(ExpectedResults[i].InfoType, TempString));
		TESTCASE_BEGIN(Heading);
		
		memset(u1.charInfoValue,NULL_STRING,sizeof(u1.charInfoValue));
		pcbInfoValue=INVALID_pcbINFOVALUE;

		if(SQL_DRIVER_HSTMT==ExpectedResults[i].InfoType){
			u1.longInfoValue=(unsigned long)hstmt;
		}

		returncode = SQLGetInfo((SQLHANDLE)hdbc,ExpectedResults[i].InfoType,u1.charInfoValue,
								(SWORD)sizeof(u1.charInfoValue),&pcbInfoValue);
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLGetInfo")){
			TEST_FAILED;
			LogAllErrorsVer3(henv,hdbc,hstmt);
		}
		else{
			// Check results for correct values

			// Check returned length
			switch(ExpectedResults[i].InfoType){
				// These options can have a different length so don't check the length
/* sq new */
                                case SQL_DBMS_NAME:
/* end of sq new */
				case SQL_DRIVER_NAME:
				case SQL_DRIVER_VER:
				case SQL_SERVER_NAME:
				case SQL_ODBC_VER:
				case SQL_DRIVER_HLIB:
					break;
				default:
					if(ExpectedResults[i].InfoValueLength!=pcbInfoValue){
						LogMsg(ERRMSG,"Count of bytes returned is wrong\n");
						if(pcbInfoValue==INVALID_pcbINFOVALUE){
							LogMsg(NONE,"   Expected:%ld  Actual:<no value returned>\n",
								ExpectedResults[i].InfoValueLength);
							pcbInfoValue=(SWORD)ExpectedResults[i].InfoValueLength;	// set it to a safe value since no value was returned
						}
						else{
							LogMsg(NONE,"   Expected:%ld  Actual:%ld\n",
								ExpectedResults[i].InfoValueLength,pcbInfoValue);
						}
						TEST_FAILED;
					}
					break;
			} // end of switch
			
			// Check returned value
			DifferenceOK=FALSE;
			if(memcmp(ExpectedResults[i].pInfoValue,u1.charInfoValue,ExpectedResults[i].InfoValueLength)){
				switch(ExpectedResults[i].InfoType){

					// Yes/No return values
					case SQL_ACCESSIBLE_PROCEDURES:
					case SQL_ACCESSIBLE_TABLES:
					case SQL_CATALOG_NAME:
					case SQL_COLUMN_ALIAS:
					case SQL_DATA_SOURCE_READ_ONLY:
					case SQL_DESCRIBE_PARAMETER:
					case SQL_EXPRESSIONS_IN_ORDERBY:
					case SQL_LIKE_ESCAPE_CLAUSE:
					case SQL_MULT_RESULT_SETS:
					case SQL_MULTIPLE_ACTIVE_TXN:
					case SQL_NEED_LONG_DATA_LEN:
					case SQL_ORDER_BY_COLUMNS_IN_SELECT:
					case SQL_PROCEDURES:
					case SQL_ROW_UPDATES:
					case SQL_OUTER_JOINS:
						strcpy(ExpectedStr,(char *)ExpectedResults[i].pInfoValue);
						BufferToHex(u1.charInfoValue,ActualHex,pcbInfoValue+1);
						strncpy(ActualStr,u1.charInfoValue,pcbInfoValue+1);
						break;

					// SQLUINTEGER return values
					case SQL_AGGREGATE_FUNCTIONS:
						AggregateToString(*((long *)ExpectedResults[i].pInfoValue),ExpectedStr);
						sprintf(ActualHex,"0x%08lX",u1.intInfoValue);
						AggregateToString(u1.intInfoValue,ActualStr);
						break;
					case SQL_ALTER_TABLE:
						AlterTableToString(*((long *)ExpectedResults[i].pInfoValue),ExpectedStr);
						sprintf(ActualHex,"0x%08lX",u1.intInfoValue);
						AlterTableToString(u1.intInfoValue,ActualStr);
						break;
					case SQL_CATALOG_USAGE:
						CatalogUsageToString(*((long *)ExpectedResults[i].pInfoValue),ExpectedStr);
						sprintf(ActualHex,"0x%08lX",u1.intInfoValue);
						CatalogUsageToString(u1.intInfoValue,ActualStr);
						break;
					case SQL_CONVERT_BIGINT:
					case SQL_CONVERT_BINARY:
					case SQL_CONVERT_BIT:
					case SQL_CONVERT_CHAR:
					case SQL_CONVERT_DATE:
					case SQL_CONVERT_DECIMAL:
					case SQL_CONVERT_DOUBLE:
					case SQL_CONVERT_FLOAT:
					case SQL_CONVERT_INTERVAL_DAY_TIME:
					case SQL_CONVERT_INTERVAL_YEAR_MONTH:
					case SQL_CONVERT_INTEGER:
					case SQL_CONVERT_LONGVARBINARY:
					case SQL_CONVERT_LONGVARCHAR:
					case SQL_CONVERT_NUMERIC:
					case SQL_CONVERT_REAL:
					case SQL_CONVERT_SMALLINT:
					case SQL_CONVERT_TIME:
					case SQL_CONVERT_TIMESTAMP:
					case SQL_CONVERT_TINYINT:
					case SQL_CONVERT_VARBINARY:
					case SQL_CONVERT_VARCHAR:
					case SQL_CONVERT_WCHAR:
					case SQL_CONVERT_WLONGVARCHAR:
					case SQL_CONVERT_WVARCHAR:
						ConvertValueToString(*((long *)ExpectedResults[i].pInfoValue),ExpectedStr);
						sprintf(ActualHex,"0x%08lX",u1.intInfoValue);
						ConvertValueToString(u1.intInfoValue,ActualStr);
						break;
					case SQL_CONVERT_FUNCTIONS:
						CvtFunctionToString(*((long *)ExpectedResults[i].pInfoValue),ExpectedStr);
						sprintf(ActualHex,"0x%08lX",u1.intInfoValue);
						CvtFunctionToString(u1.intInfoValue,ActualStr);
						break;
					case SQL_DEFAULT_TXN_ISOLATION:
						TxnIsolationToString(*((long *)ExpectedResults[i].pInfoValue),ExpectedStr);
						sprintf(ActualHex,"0x%08lX",u1.intInfoValue);
						TxnIsolationToString(u1.intInfoValue,ActualStr);
						break;
					case SQL_DYNAMIC_CURSOR_ATTRIBUTES1:
					case SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES1:
					case SQL_KEYSET_CURSOR_ATTRIBUTES1:
					case SQL_STATIC_CURSOR_ATTRIBUTES1:
						CA1ToString(*((long *)ExpectedResults[i].pInfoValue),ExpectedStr);
						sprintf(ActualHex,"0x%08lX",u1.intInfoValue);
						CA1ToString(u1.intInfoValue,ActualStr);
						break;
					case SQL_DYNAMIC_CURSOR_ATTRIBUTES2:
					case SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES2:
					case SQL_KEYSET_CURSOR_ATTRIBUTES2:
					case SQL_STATIC_CURSOR_ATTRIBUTES2:
						CA2ToString(*((long *)ExpectedResults[i].pInfoValue),ExpectedStr);
						sprintf(ActualHex,"0x%08lX",u1.intInfoValue);
						CA2ToString(u1.intInfoValue,ActualStr);
						break;
					case SQL_NUMERIC_FUNCTIONS:
						NumFunctionToString(*((long *)ExpectedResults[i].pInfoValue),ExpectedStr);
						sprintf(ActualHex,"0x%08lX",u1.intInfoValue);
						NumFunctionToString(u1.intInfoValue,ActualStr);
						break;
					case SQL_STRING_FUNCTIONS:
						StrFunctionToString(*((long *)ExpectedResults[i].pInfoValue),ExpectedStr);
						sprintf(ActualHex,"0x%08lX",u1.intInfoValue);
						StrFunctionToString(u1.intInfoValue,ActualStr);
						break;
					case SQL_TIMEDATE_ADD_INTERVALS:
					case SQL_TIMEDATE_DIFF_INTERVALS:
						TimeIntToString(*((long *)ExpectedResults[i].pInfoValue),ExpectedStr);
						sprintf(ActualHex,"0x%08lX",u1.intInfoValue);
						TimeIntToString(u1.intInfoValue,ActualStr);
						break;
					case SQL_TIMEDATE_FUNCTIONS:
						TimeFunctionToString(*((long *)ExpectedResults[i].pInfoValue),ExpectedStr);
						sprintf(ActualHex,"0x%08lX",u1.intInfoValue);
						TimeFunctionToString(u1.intInfoValue,ActualStr);
						break;
					case SQL_OJ_CAPABILITIES:
						OJToString(*((long *)ExpectedResults[i].pInfoValue),ExpectedStr);
						sprintf(ActualHex,"0x%08lX",u1.intInfoValue);
						OJToString(u1.intInfoValue,ActualStr);
						break;
					case SQL_GETDATA_EXTENSIONS:
						GDExtToString(*((long *)ExpectedResults[i].pInfoValue),ExpectedStr);
						sprintf(ActualHex,"0x%08lX",u1.intInfoValue);
						GDExtToString(u1.intInfoValue,ActualStr);
						break;
					case SQL_SCHEMA_USAGE:
						SchemaUsageToString(*((long *)ExpectedResults[i].pInfoValue),ExpectedStr);
						sprintf(ActualHex,"0x%08lX",u1.intInfoValue);
						SchemaUsageToString(u1.intInfoValue,ActualStr);
						break;
					case SQL_DRIVER_HDBC:
					case SQL_DRIVER_HENV:
					case SQL_DRIVER_HLIB:
					case SQL_DRIVER_HSTMT:
						DifferenceOK=TRUE;
						break;
					case SQL_ALTER_DOMAIN:
					case SQL_ASYNC_MODE:
					case SQL_BATCH_ROW_COUNT:
					case SQL_BATCH_SUPPORT:
					case SQL_BOOKMARK_PERSISTENCE:
					case SQL_SQL_CONFORMANCE:
					case SQL_CREATE_ASSERTION:
					case SQL_CREATE_CHARACTER_SET:
					case SQL_CREATE_COLLATION:
					case SQL_CREATE_DOMAIN:
					case SQL_CREATE_SCHEMA:
					case SQL_CREATE_TABLE:
					case SQL_CREATE_TRANSLATION:
					case SQL_CREATE_VIEW:
					case SQL_CURSOR_SENSITIVITY:
					case SQL_DATETIME_LITERALS:
					case SQL_DDL_INDEX:
					case SQL_DROP_ASSERTION:
					case SQL_DROP_CHARACTER_SET:
					case SQL_DROP_COLLATION:
					case SQL_DROP_DOMAIN:
					case SQL_DROP_SCHEMA:
					case SQL_DROP_TABLE:
					case SQL_DROP_TRANSLATION:
					case SQL_DROP_VIEW:
					case SQL_FETCH_DIRECTION:
					case SQL_INDEX_KEYWORDS:
					case SQL_INFO_SCHEMA_VIEWS:
					case SQL_INSERT_STATEMENT:
					case SQL_LOCK_TYPES:
					case SQL_MAX_ASYNC_CONCURRENT_STATEMENTS:
					case SQL_MAX_BINARY_LITERAL_LEN:
					case SQL_MAX_CHAR_LITERAL_LEN:
					case SQL_MAX_INDEX_SIZE:
					case SQL_MAX_ROW_SIZE:
					case SQL_MAX_STATEMENT_LEN:
					case SQL_ODBC_INTERFACE_CONFORMANCE:
					case SQL_PARAM_ARRAY_ROW_COUNTS:
					case SQL_PARAM_ARRAY_SELECTS:
					case SQL_POS_OPERATIONS:
					case SQL_POSITIONED_STATEMENTS:
					case SQL_SCROLL_CONCURRENCY:
					case SQL_SCROLL_OPTIONS:
					case SQL_SQL92_DATETIME_FUNCTIONS:
					case SQL_SQL92_FOREIGN_KEY_DELETE_RULE:
					case SQL_SQL92_FOREIGN_KEY_UPDATE_RULE:
					case SQL_SQL92_GRANT:
					case SQL_SQL92_NUMERIC_VALUE_FUNCTIONS:
					case SQL_SQL92_PREDICATES:
					case SQL_SQL92_RELATIONAL_JOIN_OPERATORS:
					case SQL_SQL92_REVOKE:
					case SQL_SQL92_ROW_VALUE_CONSTRUCTOR:
					case SQL_SQL92_STRING_FUNCTIONS:
					case SQL_SQL92_VALUE_EXPRESSIONS:
					case SQL_STANDARD_CLI_CONFORMANCE:
					case SQL_STATIC_SENSITIVITY:
					case SQL_SUBQUERIES:
					case SQL_SYSTEM_FUNCTIONS:
					case SQL_TXN_ISOLATION_OPTION:
					case SQL_UNION:
						sprintf(ExpectedStr,"%ld",*((long *)ExpectedResults[i].pInfoValue));
						sprintf(ActualHex,"0x%08lX",u1.intInfoValue);
						sprintf(ActualStr,"%ld",u1.intInfoValue);
						break;

					// SQLUSMALLINT return values
					case SQL_CATALOG_LOCATION:
						CatalogLocationToString(*((short *)ExpectedResults[i].pInfoValue),ExpectedStr);
						sprintf(ActualHex,"0x%04X",u1.smiInfoValue);
						CatalogLocationToString(u1.smiInfoValue,ActualStr);
						break;
					case SQL_CONCAT_NULL_BEHAVIOR:
						ConcatNullToString(*((short *)ExpectedResults[i].pInfoValue),ExpectedStr);
						sprintf(ActualHex,"0x%04X",u1.smiInfoValue);
						ConcatNullToString(u1.smiInfoValue,ActualStr);
						break;
					case SQL_CORRELATION_NAME:
						CorrelationToString(*((short *)ExpectedResults[i].pInfoValue),ExpectedStr);
						sprintf(ActualHex,"0x%04X",u1.smiInfoValue);
						CorrelationToString(u1.smiInfoValue,ActualStr);
						break;
					case SQL_CURSOR_COMMIT_BEHAVIOR:
					case SQL_CURSOR_ROLLBACK_BEHAVIOR:
						CursorBehaviorToString(*((short *)ExpectedResults[i].pInfoValue),ExpectedStr);
						sprintf(ActualHex,"0x%04X",u1.smiInfoValue);
						CursorBehaviorToString(u1.smiInfoValue,ActualStr);
						break;
					case SQL_FILE_USAGE:
						FileUsageToString(*((short *)ExpectedResults[i].pInfoValue),ExpectedStr);
						sprintf(ActualHex,"0x%04X",u1.smiInfoValue);
						FileUsageToString(u1.smiInfoValue,ActualStr);
						break;
					case SQL_GROUP_BY:
						GroupByToString(*((short *)ExpectedResults[i].pInfoValue),ExpectedStr);
						sprintf(ActualHex,"0x%04X",u1.smiInfoValue);
						GroupByToString(u1.smiInfoValue,ActualStr);
						break;
					case SQL_IDENTIFIER_CASE:
						CaseToString(*((short *)ExpectedResults[i].pInfoValue),ExpectedStr);
						sprintf(ActualHex,"0x%04X",u1.smiInfoValue);
						CaseToString(u1.smiInfoValue,ActualStr);
						break;
					case SQL_ACTIVE_ENVIRONMENTS:
					case SQL_MAX_CATALOG_NAME_LEN:
					case SQL_MAX_COLUMN_NAME_LEN:
					case SQL_MAX_COLUMNS_IN_GROUP_BY:
					case SQL_MAX_COLUMNS_IN_INDEX:
					case SQL_MAX_COLUMNS_IN_ORDER_BY:
					case SQL_MAX_COLUMNS_IN_SELECT:
					case SQL_MAX_COLUMNS_IN_TABLE:
					case SQL_MAX_CONCURRENT_ACTIVITIES:
					case SQL_MAX_CURSOR_NAME_LEN:
					case SQL_MAX_DRIVER_CONNECTIONS:
					case SQL_MAX_PROCEDURE_NAME_LEN:
					case SQL_MAX_SCHEMA_NAME_LEN:
					case SQL_MAX_TABLE_NAME_LEN:
					case SQL_MAX_TABLES_IN_SELECT:
					case SQL_MAX_USER_NAME_LEN:
					case SQL_ODBC_SAG_CLI_CONFORMANCE:
					case SQL_ODBC_SQL_CONFORMANCE:
						sprintf(ExpectedStr,"%d",*((short *)ExpectedResults[i].pInfoValue));
						sprintf(ActualHex,"0x%04X",u1.smiInfoValue);
						sprintf(ActualStr,"%d",u1.smiInfoValue);
						break;


					// Character string return values
/* sq new */
                                        /* These values change from time to
                                       * time, mark them as OK.
                                       */
				      case SQL_DBMS_NAME:
                                      case SQL_DBMS_VER:
				      case SQL_DRIVER_NAME:
                                      case SQL_DRIVER_VER:
                                      case SQL_SERVER_NAME:
				      case SQL_ODBC_VER:
				      case SQL_DM_VER:
                                              DifferenceOK = TRUE;
                                                break;
/* end of sq new */
					case SQL_CATALOG_NAME_SEPARATOR:
					case SQL_CATALOG_TERM:
					case SQL_COLLATION_SEQ:
					case SQL_DATA_SOURCE_NAME:
					case SQL_DATABASE_NAME:
					// sq case SQL_DBMS_NAME:
					// sq case SQL_DBMS_VER:
					//case SQL_DM_VER: special case
					//case SQL_DRIVER_ODBC_VER: special case handled later
					case SQL_IDENTIFIER_QUOTE_CHAR:
//					case SQL_KEYWORDS:
					// sq case SQL_ODBC_VER:
					case SQL_PROCEDURE_TERM:
					case SQL_SCHEMA_TERM:
					case SQL_SEARCH_PATTERN_ESCAPE:
					case SQL_SPECIAL_CHARACTERS:
					case SQL_TABLE_TERM:
					case SQL_USER_NAME:
					case SQL_XOPEN_CLI_YEAR:
						// Verifying to see if our first check failed due to text casing.
						if (strcmp((char *)ExpectedResults[i].pInfoValue,
									_strupr(_strdup(u1.charInfoValue))) == 0) {
							DifferenceOK = TRUE;
							break;
						}
						// Mismatched casing wasn't the problem! Let's log this as an error.
						strcpy(ExpectedStr,(char *)ExpectedResults[i].pInfoValue);
						BufferToHex(u1.charInfoValue,ActualHex,pcbInfoValue+1);
						strncpy(ActualStr,u1.charInfoValue,pcbInfoValue+1);
						break;
					case SQL_KEYWORDS:
						// Verifying to see if our first check failed due to text casing.
						if (strcmp((char *)ExpectedResults[i].pInfoValue,
									_strupr(_strdup(u1.charInfoValue))) == 0) {
							DifferenceOK = TRUE;
							break;
						}
						// Mismatched casing wasn't the problem! Let's log this as an error.
						strcpy(ExpectedStr,(char *)ExpectedResults[i].pInfoValue);
						strncpy(ActualStr,u1.charInfoValue,pcbInfoValue+1);
						break;
					// sq case SQL_DRIVER_NAME:
					// sq case SQL_DRIVER_VER:
					// sq case SQL_SERVER_NAME:
#if 0 /* SEAQUSET */
						if(strstr(_strupr(_strdup(u1.charInfoValue)),
							(char *)ExpectedResults[i].pInfoValue)==NULL)
						{
							sprintf(ExpectedStr," something containing this string -->'%s'",
									(char *)ExpectedResults[i].pInfoValue);
							BufferToHex(u1.charInfoValue,ActualHex,pcbInfoValue+1);
							strncpy(ActualStr,u1.charInfoValue,pcbInfoValue+1);
						}
						else DifferenceOK=TRUE;
						break;
#endif /* SEAQUSET */
					//check for driver  version >= 3.51
					case SQL_DRIVER_ODBC_VER:
					// case SQL_DM_VER:
						if(strstr(u1.charInfoValue,
							"3.5")==NULL)
						{
							sprintf(ExpectedStr," something containing this string -->'%s'",
									"3.5");
							BufferToHex(u1.charInfoValue,ActualHex,pcbInfoValue+1);
							strncpy(ActualStr,u1.charInfoValue,pcbInfoValue+1);
						}
						else DifferenceOK=TRUE;
						break;

					// These options still need functions to convert their flag values to
					// a more user friendly string.  Until then, we'll simple display them
					// in hex.
					// SQLUSMALLINT
					case SQL_MAX_IDENTIFIER_LEN:
					case SQL_NON_NULLABLE_COLUMNS:
					case SQL_NULL_COLLATION:
					case SQL_QUOTED_IDENTIFIER_CASE:
					case SQL_TXN_CAPABLE:
					case SQL_ODBC_API_CONFORMANCE:
						sprintf(ExpectedStr,"%d (0x%04X)",*((short *)ExpectedResults[i].pInfoValue),
							*((short *)ExpectedResults[i].pInfoValue));
						sprintf(ActualHex,"0x%04X",u1.smiInfoValue);
						sprintf(ActualStr,"%d",u1.smiInfoValue);
						break;
				} // end of switch
				if(DifferenceOK){
					// don't display any message
				}
				else{
					LogMsg(ERRMSG,"Returned value is wrong\n"
						"      Expected:%s\n"
						"        Actual:%s\n"
						"   Actual(hex):%s\n",ExpectedStr,ActualStr,ActualHex);
					TEST_FAILED;
				}
			} // end of if
		}
		TESTCASE_END;
	}

	// Test with StringLengthPtr set to NULL
	for (i = 0; i < TotalOptions; i++){
		sprintf(Heading,"Test SQLGetInfo(%s) with StringLengthPtr set to NULL.\n",
			InfoTypeToChar(ExpectedResults[i].InfoType, TempString));
		TESTCASE_BEGIN(Heading);
		
		if(SQL_DRIVER_HSTMT==ExpectedResults[i].InfoType){
			u1.longInfoValue=(unsigned long)hstmt;
		}

		returncode = SQLGetInfo((SQLHANDLE)hdbc,ExpectedResults[i].InfoType,u1.charInfoValue,
			(SWORD)sizeof(u1.charInfoValue),NULL);
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLGetInfo")){
			TEST_FAILED;
			LogAllErrorsVer3(henv,hdbc,hstmt);
		}
		TESTCASE_END;
	}

	// Test with InfoValuePtr set to NULL
	for (i = 0; i < TotalOptions; i++){
		sprintf(Heading,"Test SQLGetInfo(%s) with InfoValuePtr set to NULL.\n",
			InfoTypeToChar(ExpectedResults[i].InfoType, TempString));
		TESTCASE_BEGIN(Heading);
	
if (ExpectedResults[i].InfoType==SQL_GETDATA_EXTENSIONS) {
returncode = SQLGetInfo((SQLHANDLE)hdbc,ExpectedResults[i].InfoType,
        &u1.intInfoValue, (SWORD)sizeof(u1.intInfoValue),&pcbInfoValue);
}
else {	
     	returncode = SQLGetInfo((SQLHANDLE)hdbc,ExpectedResults[i].InfoType,NULL,
			(SWORD)sizeof(u1.charInfoValue),&pcbInfoValue);
}
		if(SQL_DRIVER_HSTMT==ExpectedResults[i].InfoType){
			if(!CHECKRC(SQL_ERROR,returncode,"SQLGetInfo")){
				TEST_FAILED;
				LogAllErrorsVer3(henv,hdbc,hstmt);
			}
		}
		else{
			if(!CHECKRC(SQL_SUCCESS,returncode,"SQLGetInfo")){
				TEST_FAILED;
				LogAllErrorsVer3(henv,hdbc,hstmt);
			}
		}
		TESTCASE_END;
	}
	
	// BufferLength should only effect character data returned.
	// BufferLength should be ignored for any numeric values returned.
	for (i = 0; i < TotalOptions; i++){
		sprintf(Heading,"Test SQLGetInfo(%s) with BufferLength set to 1.\n",
			InfoTypeToChar(ExpectedResults[i].InfoType, TempString));
		TESTCASE_BEGIN(Heading);
		
		if(SQL_DRIVER_HSTMT==ExpectedResults[i].InfoType){
			u1.longInfoValue=(unsigned long)hstmt;
		}

		returncode = SQLGetInfo((SQLHANDLE)hdbc,ExpectedResults[i].InfoType,
								u1.charInfoValue,1,&pcbInfoValue);

		switch(ExpectedResults[i].InfoType){

			// character string return values
			case SQL_ACCESSIBLE_PROCEDURES:
			case SQL_ACCESSIBLE_TABLES:
			case SQL_CATALOG_NAME:
			case SQL_CATALOG_NAME_SEPARATOR:
			case SQL_CATALOG_TERM:
			case SQL_COLLATION_SEQ:
			case SQL_COLUMN_ALIAS:
			case SQL_DATA_SOURCE_NAME:
			case SQL_DATA_SOURCE_READ_ONLY:
			case SQL_DATABASE_NAME:
			case SQL_DBMS_NAME:
			case SQL_DBMS_VER:
			case SQL_DESCRIBE_PARAMETER:
			case SQL_DM_VER:
			case SQL_DRIVER_NAME:
			case SQL_DRIVER_ODBC_VER:
			case SQL_DRIVER_VER:
			case SQL_EXPRESSIONS_IN_ORDERBY:
			case SQL_IDENTIFIER_QUOTE_CHAR:
			case SQL_INTEGRITY:
			//case SQL_KEYWORDS: This is returning nothing and will return SQL_SUCCESS.
			case SQL_LIKE_ESCAPE_CLAUSE:
			case SQL_MAX_ROW_SIZE_INCLUDES_LONG:
			case SQL_MULT_RESULT_SETS:
			case SQL_MULTIPLE_ACTIVE_TXN:
			case SQL_NEED_LONG_DATA_LEN:
			case SQL_ODBC_VER:
			case SQL_ORDER_BY_COLUMNS_IN_SELECT:
			case SQL_OUTER_JOINS:
			//case SQL_PROCEDURE_TERM: This is returning nothing and will return SQL_SUCCESS.
			case SQL_PROCEDURES:
			case SQL_ROW_UPDATES:
			case SQL_SCHEMA_TERM:
			case SQL_SEARCH_PATTERN_ESCAPE:
			case SQL_SERVER_NAME:
			case SQL_SPECIAL_CHARACTERS:
			case SQL_TABLE_TERM:
			//case SQL_USER_NAME: This is returning nothing and will return SQL_SUCCESS.
			case SQL_XOPEN_CLI_YEAR:
				if(!CHECKRC(SQL_SUCCESS_WITH_INFO,returncode,"SQLGetInfo")){
					TEST_FAILED;
					LogAllErrorsVer3(henv,hdbc,hstmt);
				}
				break;

			// if not character, assume numeric return values
			default:
				if(!CHECKRC(SQL_SUCCESS,returncode,"SQLGetInfo")){
					TEST_FAILED;
					LogAllErrorsVer3(henv,hdbc,hstmt);
				}
				break;
		}
		TESTCASE_END;
	}
	
	// Testing with ConnectionHandle set to NULL
	for (i = 0; i < TotalOptions; i++){
		sprintf(Heading,"Test SQLGetInfo(%s) with ConnectionHandle set to NULL.\n",
			InfoTypeToChar(ExpectedResults[i].InfoType, TempString));
		TESTCASE_BEGIN(Heading);
		
		if(SQL_DRIVER_HSTMT==ExpectedResults[i].InfoType){
			u1.longInfoValue=(unsigned long)hstmt;
		}

		returncode = SQLGetInfo((SQLHANDLE)NULL,ExpectedResults[i].InfoType,u1.charInfoValue,
			(SWORD)sizeof(u1.charInfoValue),&pcbInfoValue);
		if(!CHECKRC(SQL_INVALID_HANDLE,returncode,"SQLGetInfo")){
			TEST_FAILED;
			LogAllErrorsVer3(henv,hdbc,hstmt);
		}
		TESTCASE_END;
	}

	SQLFreeHandle(SQL_HANDLE_STMT, hstmt);
	FullDisconnectVer(pTestInfo, SQL_OV_ODBC3);
	LogMsg(SHORTTIMESTAMP+LINEAFTER,"End testing API => MX specific SQLGetInfo.\n");
	LogMsg(LINEAFTER,"\n");
	TEST_RETURN;
}