Execute two o more sentence PROGRESS DB ODBC Driver

Discussão em 'StackOverflow' iniciado por fdantas, Agosto 29, 2017.

  1. fdantas

    fdantas Administrator Moderador

    hi i try to execute a query to progress database but i only the first execution is success this is in c++, the second execution is return -1

    this is the code

    code :

    varQuery1 = "select \"CODIGO-OFIC\",\"SUB-APLIC\",CTA,CLTE[1] from PUB.\"TABLA-1\" ";
    Strcpy(szStmt, varQuery1);
    if (hStmt == NULL){
    nRet = SQLAllocEnv(&hEnv);
    nRet = SQLAllocConnect(hEnv, &hDBC);
    nRet = SQLConnect(hDBC, szDSN, SQL_NTS, szUID, SQL_NTS, szPWD, SQL_NTS);
    nRet = SQLAllocHandle(SQL_HANDLE_STMT, hDBC, &hStmt);
    }
    nRet = SQLExecDirect(hStmt, (SQLCHAR*)szStmt, SQL_NTS);
    SQLFetch(hStmt);
    // obtenemos el numero de cliente asociado a la cta
    // ------------------------------------------------
    nRet = SQLGetData(hStmt, 3, SQL_C_CHAR, szRetVal, 256, &cbData); // get first data column
    S1 = reinterpret_cast<char*>(szRetVal);
    Strcpy(varIdCliente, S1);
    // validar el codigo de error para validar si el registro buscado existe
    // ---------------------------------------------------------------------
    varQuery1.Init();
    varQuery1 = "SELECT \"nombre-full\" FROM PUB.TABLA2 ";
    Attach(varQuery1, ' ', "WHERE clte =");
    Attach(varQuery1, varIdCliente);
    Strcpy(szStmt1, varQuery1);
    nRet = SQLExecDirect(hStmt, (SQLCHAR*)szStmt1, SQL_NTS);
    SQLFetch(hStmt);
    // Valida el cliente y recupera el nombre
    // obtenemos el numero de cliente asociado a la cta
    // ------------------------------------------------
    nRet = SQLGetData(hStmt, 1, SQL_C_CHAR, szRetVal1, 256, &cbData); // get first data column
    S2 = reinterpret_cast<char*>(szRetVal1);
    cwStrcpy(vtNombreCuenta, S2);

    Continue reading...

Compartilhe esta Página