Menu

question about "OCI_GetColumnSQLType" call

Anonymous
2015-06-16
2015-06-24
  • Anonymous

    Anonymous - 2015-06-16

    Question

    Hello

    I have a problem/question about "OCI_GetColumnSQLType" call.

    When I use "OCI_GetColumnSQLType", I get "?" and when I use "OCI_ColumnGetFullSQLType" I get correct result (full description).

    My question.
    Is there a problem with "OCI_GetColumnSQLType"?
    Is it "deprecated"?
    Do I make a mistake?

    Thanks for your answer (and your work!)

    Ydl

    Info

    Server banner (first line).: Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
    Server major/minor/revision: 12.1.0
    Client runtime version.....: 11.2.0.4.0
    OCILIB major/minor/revision: 4.1.0
    OCI compile................: 11
    OCI runtime................: 11
    OCI import mode............: linkage
    OCI metadata char type.....: ansi
    OCI userdata char type.....: ansi
    

    Result

    Column Name         Type(full)       Type     Length  Prec.   Scale    Null
    ------------------------------- -------------------------------------------
    EMPNO               NUMBER(4)           ?         22      4       0       N
    ENAME               VARCHAR(10)         ?         10      0       0       Y
    JOB                 VARCHAR(9)          ?         9       0       0       Y
    MGR                 NUMBER(4)           ?         22      4       0       Y
    HIREDATE            DATE                ?         7       0       0       Y
    SAL                 NUMBER(7,2)         ?         22      7       2       Y
    COMM                NUMBER(7,2)         ?         22      7       2       Y
    DEPTNO              NUMBER(2)           ?         22      2       0       Y
    

    Source code

    #include "ocilib.h"
    int main(void)
    {
     OCI_Connection *cn;
     OCI_TypeInfo *tbl;
     int i,n;
    
     if (!OCI_Initialize(NULL, NULL, OCI_ENV_DEFAULT))
     return EXIT_FAILURE;
    
     cn = OCI_ConnectionCreate("YDL01", "SCOTT", "tiger", OCI_SESSION_DEFAULT);
     tbl = OCI_TypeInfoGet(cn, "EMP", OCI_TIF_TABLE);
     if (tbl != NULL)
     {
      printf ("Column Name         Type(full)       Type     Length  Prec.   Scale    Null\n");
      printf ("------------------------------- -------------------------------------------\n");
      n = OCI_TypeInfoGetColumnCount(tbl);
      char str[100];
      for(i = 1; i <= n; i++)
      {
       OCI_Column *col = OCI_TypeInfoGetColumn(tbl, i);
       OCI_ColumnGetFullSQLType(col, str, 100);
       printf("%-20s%-20s%-10s%-8i%-8i%-8i%-s\n",
       OCI_GetColumnName(col),
       str,
       OCI_GetColumnSQLType(col),
       OCI_GetColumnSize(col),
       OCI_GetColumnPrecision(col),
       OCI_GetColumnScale(col),
       OCI_GetColumnNullable(col) == TRUE ? "Y" : "N");
      }
     }
     OCI_Cleanup();
     return EXIT_SUCCESS;
    }
    
     
  • Vincent Rogier

    Vincent Rogier - 2015-06-16

    Hi,

    This is a bug introduced in v4.0.0

    Already fixed in the GIT repository few weeks ago.

    Best regards,

    Vincent

     
    • Anonymous

      Anonymous - 2015-06-17

      Thanks very much!
      Ydl