contentsconceptssyntaxlibrariessampleserrorsindex
Full text search
Retrieving supported ODBC data types  
Introduction: ODBC data manipulation  

Sample

  local SQL_Handle_type EnvironmentHandle
  local SQL_Handle_type ConnectionHandle
  local SQL_Handle_type StatementHandle
  local stream  TypeName
  local counter TypeNameInd
  local counter RetCode

  set RetCode to SQLAllocEnv(EnvironmentHandle)
  output "Allocating environment handle - "
  do when RetCode != SQL_SUCCESS
     output "failed%n"
     halt with 1
  else
     output "passed%n"
  done

  set RetCode to SQLAllocHandle
     ( SQL_HANDLE_DBC, EnvironmentHandle, ConnectionHandle )
  output "Allocating connection handle - "
  do when RetCode != SQL_SUCCESS
     output "failed%n"
     halt with 1
  else
     output "passed%n"
  done

  set RetCode to SQLConnect( ConnectionHandle, "omodbc", 20, "", 0, "", 0 )
  output "Connecting to database - "
  do when RetCode != SQL_SUCCESS
     output "failed%n"
     halt with 1
  else
     output "passed%n"
  done

  set RetCode to SQLAllocStmt(ConnectionHandle, StatementHandle)
  output "Allocating statement handle - "
  do when RetCode != SQL_SUCCESS
     output "failed%n"
     halt with 1
  else
     output "passed%n"
  done

  set RetCode to SQLGetTypeInfo( StatementHandle, SQL_ALL_TYPES )
  output "Getting data type information - "
  do when RetCode != SQL_SUCCESS
     output "failed%n"
     halt with 1
  else
     output "passed%n"
  done

  do when RetCode = SQL_SUCCESS
     repeat
        set RetCode to SQLFetch( StatementHandle )
        do when (RetCode=SQL_SUCCESS) or (RetCode=SQL_SUCCESS_WITH_INFO)
           set RetCode to SQLGetData
                 ( StatementHandle, 1, SQL_C_CHAR, TypeName, 32, TypeNameInd )
           do when RetCode = SQL_SUCCESS
              output "- %g(TypeName)%n"
           else
              output "Getting data from cursor - failed%n"
           done
        else
           exit
        done
     again
  done

  set RetCode to SQLFreeStmt(StatementHandle, SQL_DROP)
  output "Freeing statement handle resources - "
  do when RetCode != SQL_SUCCESS
     output "failed%n"
     halt with 1
  else
     output "passed%n"
  done

  set RetCode to SQLDisconnect( ConnectionHandle )
  output "Disconnecting from database - "
  do when RetCode != SQL_SUCCESS
     output "failed%n"
     halt with 1
  else
     output "passed%n"
  done

  set RetCode to SQLFreeHandle(SQL_HANDLE_DBC, ConnectionHandle)
  output "Freeing connection handle resources - "
  do when RetCode != SQL_SUCCESS
     output "failed%n"
     halt with 1
  else
     output "passed%n"
  done

  set RetCode to SQLFreeHandle(SQL_HANDLE_ENV, EnvironmentHandle)
  output "Freeing environment handle resources - "
  do when RetCode != SQL_SUCCESS
     output "failed%n"
     halt with 1
  else
     output "passed%n"
  done

 
----  

Top [CONTENTS] [CONCEPTS] [SYNTAX] [LIBRARIES] [SAMPLES] [ERRORS] [INDEX]

Generated: April 21, 1999 at 2:01:44 pm
If you have any comments about this section of the documentation, send email to [email protected]

Copyright © OmniMark Technologies Corporation, 1988-1999.