Anne,
People with English as a first language can have difficulty understanding the description of manifest typing in the Sqlite documenation. When you have less English it is more difficult :-).

Sqlite returns the column name and type.

Here is a code fragment which returns the column name and declared type from Sqlite. It may help. For example if you declare your colmn name as "HELGA": and its type as "BLOB" you will be able to identify it when you read the row.

 /*-- sql_dc_srch ------------------------------------------------------
Lookup a reserved declared type table for a match and return a token.
Perform a binary search.*/
SQL_DECL_TYPES sql_dc_srch (char *dt) {

  SQL_DECL_TYPES  high;
  SQL_DECL_TYPES  low;
  SQL_DECL_TYPES  mid;
  int             result;

  low  = dc_first + 1;
  high = dc_last;
  while (low <= high) {
    mid   = (low + high) / 2;

    result = strcmp(dt, sql_res_types[mid]);

    if (result == 0) return(mid);

    if (result < 0) high = mid - 1;
    else low = mid + 1;
  }  /*while*/

  return(dc_last);
}     /*sql_dc_srch*/

/*-- sql_column_name_type -------------------------------------------
Given a prep'd statement and a column index, return the column name
and declared type.  Returns dc_last on error.*/
SQL_DECL_TYPES sql_column_name_type (sqlite3_stmt *sqst, int idx, char *nm,
                                     int bl, char *prec) {

  int            a;
  char           argnm[128]; /*Name of argument to function.*/
  char           *cn;        /*Column name.*/
  char           *dc = NULL; /*Declared type in text.*/
  char           dt[128];    /*Parsed declared type.*/
  char           fnm[128];   /*Name of function.*/
  char           *pt;
  SQL_DECL_TYPES tok;
  char           *wkp;

  /*Get column name.*/
  cn = (char *)sqlite3_column_name(sqst, idx);

  /*Is it a function?*/
  pt = cn;
  while (*pt > 0) {
    if (*pt == '(') {
      /*It is a function.  Extract name and arg.  Convert fn name
      to upper case.*/
      wkp = cn;
      a = 0;
      while (wkp < pt) {
        fnm[a++] = *wkp & 0xdf;
        wkp++;
      }  /*while*/
      fnm[a] = 0;   /*Func name.*/
      dc = fnm;

      pt++;
      a = 0;
      while ((*pt > 0) && (*pt != ')')) argnm[a++] = *pt++;
      argnm[a] = 0;
      cn = argnm;

      break;  /*To exit loop.*/
    }  /*if*/
    pt++;
  }    /*while*/

  /*Get declared type if we don't already have it.*/
  if (dc == NULL) dc = (char *)sqlite3_column_decltype(sqst, idx);

  /*May be something like DECIMAL(6.2).*/
  a = 0;
  pt = dt;
  wkp = dc;
  while ((*wkp != '(') && (*wkp > 0) && (a < 128)) {
    *pt++ = *wkp++;
    a++;
  }  /*while*/
  *wkp = 0;

  /*Tokenize the declared type.*/
  tok = sql_dc_srch(dt);

  /*Get the precision.*/
  pt = prec;
  if (tok == dc_decimal) {
    if (*wkp == '{') wkp++;
    while ((*wkp != '}') && (*wkp > 0)) *pt++ = *wkp++;
  }  /*if*/
  *pt = 0;

  /*Move the name.  Strip a table name.*/
  pt  = nm;
  wkp = cn;
  while ((*wkp > 0) && (*wkp != '.')) wkp++; /*Strip table.*/
  if (*wkp == '.') wkp++;
  else wkp = cn;
  a = 0;
  while ((*wkp > 0) && (a < bl)) {
    *pt++ = *wkp++;
    a++;
  }  /*while*/
  *pt = 0;

  return(tok);
}      /*sql_column_name_type*/


[EMAIL PROTECTED] wrote:
Hi John

Thanks for your answer... :-)


You could use CSV to go to Excel, SQL to Oracle etc. ..*snip*


I do that all very succesful with ADO and OLE-DB... very rarely got problems.

If you don't want to use the Sqlite API then you have probably chosen


i want to use SQLite, because it's a embedded SQL-DB and working on my Pocket-PC. I think, it's a very good tool with fast results and simple handling.


You can make whatever transformation is needed by your destination using >atoi, atof and sprintf at the destination.


yes, i know... but the problem -i cannot be solve- is a DB with a unbeknown (? (sorry, got some problems too with my englisch)) field-structure. I "select * ..." and find fields. one of this fields (in ever the same column) contains a bitmap, but i don't know, which field/column it is. i have to do ask the api "which field/column is a blob and have to show as a bitmap via a bitmapwrapper?". unfortunately the api-function sqlite3_column_type() returns SQLITE_TEXT for the Blob-Column in my Test-App.

Best greetings from Germany
Anne




Reply via email to