General discussion

Locked

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;
  else
	  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!

cheers

This conversation is currently closed to new comments.

2 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

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.

Gary

Collapse -

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.

Back to Web Development Forum
2 total posts (Page 1 of 1)  

Related Discussions

Related Forums