General discussion

  • Creator
  • #2257544

    Oracle OCI Dates


    by frenchwood ·

    I have a question around the Oracle OCI.

    I have a datatype of ub1, in oratypes.h this is defined as an unsigned char[7] (6 chars with null terminator “\0”). however, when referencing the values, it appears the code i am debugging is referencing as array variables and not as char values.

    The code is as follows:
    // Converts an Oracle OCI external date/time structure (char[7])
    // into date a string format acceptable to Vectus.
    static void OracleDateToStr(ub1 *date, short ind, char *buffer)
    if (ind != 0)
    buffer[0] = 0;
    sprintf(buffer, “%02d/%02d/%04d”, (int) date[3], (int) date[2],
    ((int) date[0] – 100) * 100 + ((int) date[1] – 100));

    I guess my question is this…

    What is ub1? Is it a char? in which case my code is missing the second char of each section for dd/mm, or is it an array?

    Any help would be much appreciated!


All Comments

  • Author
    • #3201624

      Reply To: Oracle OCI Dates

      by gary_w ·

      In reply to Oracle OCI Dates

      ub1 is an array of 7 characters. “date” is a pointer to the array. You code “date[3]” is only referencing 1 character and casting it to an int.


    • #3284090

      Reply To: Oracle OCI Dates

      by swstephe ·

      In reply to Oracle OCI Dates

      ub1 stands for “unsigned-bytes-1”, and is usually “unsigned char”, for C compilers. You may be passed an array of bytes or a single byte or even NULL.

      I would think it is better to use OCIDate struct pointers and the OCIDate function, like OCIDateToText(), which takes care of language, character set and everything else for you.

Viewing 1 reply thread