Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2003
    Posts
    2

    Unanswered: Converting from OC 10 to 12.5: BCP

    I'm converting a project from OC 10 to 12.5. This module does BCP out from a table. I'm stuck in blk_init: it returns CS_FAIL. What's wrong with the code below?

    _sqlinitctx(&_sql, CS_VERSION_125, CS_TRUE, &sqlca,
    (long *)NULL, (CS_CHAR *)NULL);
    if (_sql != (_SQL_CT_HANDLES *) NULL)
    {
    _sql->connName.lnlen = CS_UNUSED;

    if ((_sql->retcode = _sqlprolog(_sql)) == CS_SUCCEED)
    {
    if (_sql->retcode != CS_SUCCEED)
    {
    LogMessage(PRCPANIC,"BCP: Cannot get conn handle");
    return(0);
    }
    }
    }

    if(blk_alloc(_sql->conn.connection, BLK_VERSION_125, &blkdesc) != CS_SUCCEED)
    {
    LogMessage(PRCPANIC,"BCP: blk_alloc: failed");
    return(FALSE);
    }

    if(blk_init(blkdesc, CS_BLK_OUT, table, strlen(table)) == CS_FAIL)
    {
    LogMessage(PRCPANIC,"BCP: blk_init: failed");
    return(FALSE);
    }

    It exits after this. The table does exist, so that's not the problem.

    Thanks.

  2. #2
    Join Date
    Aug 2002
    Location
    Madrid, Spain
    Posts
    97

    Re: Converting from OC 10 to 12.5: BCP

    Originally posted by oldgrind
    I'm converting a project from OC 10 to 12.5. This module does BCP out from a table. I'm stuck in blk_init: it returns CS_FAIL. What's wrong with the code below?

    _sqlinitctx(&_sql, CS_VERSION_125, CS_TRUE, &sqlca,
    (long *)NULL, (CS_CHAR *)NULL);
    if (_sql != (_SQL_CT_HANDLES *) NULL)
    {
    _sql->connName.lnlen = CS_UNUSED;

    if ((_sql->retcode = _sqlprolog(_sql)) == CS_SUCCEED)
    {
    if (_sql->retcode != CS_SUCCEED)
    {
    LogMessage(PRCPANIC,"BCP: Cannot get conn handle");
    return(0);
    }
    }
    }

    if(blk_alloc(_sql->conn.connection, BLK_VERSION_125, &blkdesc) != CS_SUCCEED)
    {
    LogMessage(PRCPANIC,"BCP: blk_alloc: failed");
    return(FALSE);
    }

    if(blk_init(blkdesc, CS_BLK_OUT, table, strlen(table)) == CS_FAIL)
    {
    LogMessage(PRCPANIC,"BCP: blk_init: failed");
    return(FALSE);
    }

    It exits after this. The table does exist, so that's not the problem.
    Had the program defined the error handlers for the connection,
    they would have told what's going wrong. In common Open
    Client programs, the error handlers are defined first, so
    they are called whenever an error or message is raised,
    and then the handlers can report it.

    Well, it looks like you borrowed most of the Open Client
    code from the code generated by cpre, the Embedded
    SQL/C precompiler. It should be clearer having a pure
    Open Client code, but if you're trying to debug the program
    without a full re-code, perhaps you may get a SQLCA
    formatted with the error details if you run
    _sqlepilog(_sql)
    after each Open Client command (as blk_alloc and blk_init).
    After this, you may check SQLCA's sqlcode and its corresponding
    error string sqlerrmc... but this is only a guess.

    Regards,
    Mariano Corral

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •