views:

321

answers:

2

Hi, Currently tasked with migrating Informix ESQLC files to Oracle Pro*C and have a few questions. First, we use a lot of proprietary Informix functions within our embedded ESQLC code such as:

rstrdate( ), rtoday( ), rjulmdy( ), etc.

Any pointers on how to convert these in Oracle Pro*C?

Another thing I'm struggling with understanding is the Oracle date datatype. In Informix, we use type long in our embedded sql C code for any host variables dealing with dates for the Informix tables.

But in Oracle, I'm under the impression that dates aren't communicated back and forth as long, but as char? Or can we still specify host variables as type long?

Advice appreciated, Thank you Karen

A: 

Googling "Oracle OCI Date" comes up with functions such as OCIDateTimeFromText(), OCIDateSysdate() and maybe OCIDateTimeToArray() corresponding to the ESQL/C functions you name. There is an OCIDate type that probably corresponds more closely to an ESQL/C dtime_t (it likely includes the time components) than an Informix DATE (int4 or long in ESQL/C), but it is most likely the type you should be using in your translation process.

Jonathan Leffler
Thanks Jonathan. I'm going to do some more research but it's definitely not a walk in the park. From what little I did read, implementing OCI functionality introduces a lot more manual work in the Informix to Oracle migration than I would have hoped. The fact is that we only deal with datatype long for dates in our C code because that's what Informix operates in. But now w/ Oracle I'm assuming we would extract dates from the database all as char/string for manipulation?
KNewton
A: 

Just to add to the above, I created a method to duplicate Informix proprietary function rtoday( ):

    int rtoday(long *today) {
  EXEC SQL BEGIN DECLARE SECTION;
      time_t t;
  EXEC SQL END DECLARE SECTION;

  EXEC SQL WHENEVER SQLERROR DO sql_error("Oracle error\n");
  EXEC SQL CONNECT :"user/pass@dbname";
  EXEC SQL SELECT (new_time(sysdate,'EDT','GMT') - to_date('31-dec-1899','dd-mon-yyyy')) INTO :t FROM DUAL;

  printf( "C   Time = %d\n", time(NULL) );
  printf( "SQL Time = %d\n", t );

  *today=t;
}
KNewton