Integers vs floats in embedded dynamic SQL

From: A. Nair <anair_at_syllog5.watson.ibm.com>
Date: 09 Aug 1994 19:11:32 GMT
Message-ID: <ANAIR.94Aug9151134_at_syllog5.watson.ibm.com>


I have a C code fragment which prepares and describes dynamic SQL statements, like so:

  EXEC SQL PREPARE stmt FROM :sql;
  sd = sqlald(100, 0, 0);
  EXEC SQL DESCRIBE SELECT LIST FOR stmt INTO sd;   for (i = 0; i < sd->F; i++) {
    switch (sd->T[i]) {

    case  2 :       /* Oracle internal NUMBER datatype */
      sqlprc(&(sd->L[i]), &precision, &scale);
      if (precision != 0 && scale == 0) { 
	sd->T[i] = 3; /* To convert to int */
      } else {
	sd->T[i] = 4; /* To convert to double */
      }
      break;

    }
 ...
  }

I am trying to store "INTEGER"s into C's "int" and "NUMBER"s into C's "double". Right now, I call sqlprc() and use the logic above. But this will convert integer constants and expressions into "double"s. e.g. in stmts like "select 123 from test" or "select 12+23 from test". What logic can I use which will keep them as "int"s?

Anil

-- 
-----------
Anil Nair	anair_at_watson.ibm.com
Received on Tue Aug 09 1994 - 21:11:32 CEST

Original text of this message