2009-03-26 22:01 UTC+0100 Viktor Szakats (harbour.01 syenar hu)

* contrib/hbodbc/tests/odbcdemo.prg
  * contrib/hbodbc/tests/testodbc.prg
  * contrib/hbodbc/todbc.prg
  * contrib/hbodbc/odbc.c
  * contrib/hbodbc/Makefile
    + Platform protection moved to Makefile level.
    + Lots of type cleanups to use SQL types rather than Windows types.
    + Lots of type cleanups to use large integers where needed.
    * Synced Harbour integers API calls with SQL integer sizes.
    + Cleaned __DMC__ hacks.
    ! Fixed to compile with ODBCVER == 0x0100 and ODBCVER == 0x0200.
    * Update Harbour level function names as follows. Old names are
      still available, you can disabled them by defining HB_ODBC_LEGACY_LEVEL_OFF macro:
      SQLALLOCEN          => SQLALLOCENV
      SQLALLOCCO          => SQLALLOCCONNECT
      SQLDRIVERC          => SQLDRIVERCONNECT
      SQLDISCONN          => SQLDISCONNECT
      SQLFREECON          => SQLFREECONNECT
      SQLALLOCST          => SQLALLOCSTMT
      SQLFREESTM          => SQLFREESTMT
      SQLEXECDIR          => SQLEXECDIRECT
      SQLNUMRES           => SQLNUMRESULTCOLS
      SQLDESCRIB          => SQLDESCRIBECOL
      SQLEXTENDE          => SQLEXTENDEDFETCH
      SQLFETCHSC          => SQLFETCHSCROLL
      SQLROWCOUN          => SQLROWCOUNT
      SQLSETCONNECTOPTION => SQLSETCONNECTATTR
      SQLSETSTMTOPTION    => SQLSETSTMTATTR
      SQLGETCONNECTOPTION => SQLGETCONNECTATTR
      SQLGETSTMTOPTION    => SQLGETSTMTATTR

  * contrib/hbmysql/mysql.c
    % Replaced Windows headers with winsock2.h which seems to
      be required by mysql headers.

  * contrib/hbfbird/firebird.c
  * contrib/rddsql/sqlmix.c
  * contrib/hbssl/sslrand.c
    % Removed Windows headers.

  * contrib/gtwvg/gtwvg.h
  * contrib/gtwvg/wvggui.h
    + Readded ugly workaround for mingw64.
This commit is contained in:
Viktor Szakats
2009-03-26 21:02:42 +00:00
parent fc44999440
commit 633c74dfde
12 changed files with 350 additions and 263 deletions

View File

@@ -8,6 +8,51 @@
2009-12-31 13:59 UTC+0100 Foo Bar (foo.bar foobar.org)
*/
2009-03-26 22:01 UTC+0100 Viktor Szakats (harbour.01 syenar hu)
* contrib/hbodbc/tests/odbcdemo.prg
* contrib/hbodbc/tests/testodbc.prg
* contrib/hbodbc/todbc.prg
* contrib/hbodbc/odbc.c
* contrib/hbodbc/Makefile
+ Platform protection moved to Makefile level.
+ Lots of type cleanups to use SQL types rather than Windows types.
+ Lots of type cleanups to use large integers where needed.
* Synced Harbour integers API calls with SQL integer sizes.
+ Cleaned __DMC__ hacks.
! Fixed to compile with ODBCVER == 0x0100 and ODBCVER == 0x0200.
* Update Harbour level function names as follows. Old names are
still available, you can disabled them by defining HB_ODBC_LEGACY_LEVEL_OFF macro:
SQLALLOCEN => SQLALLOCENV
SQLALLOCCO => SQLALLOCCONNECT
SQLDRIVERC => SQLDRIVERCONNECT
SQLDISCONN => SQLDISCONNECT
SQLFREECON => SQLFREECONNECT
SQLALLOCST => SQLALLOCSTMT
SQLFREESTM => SQLFREESTMT
SQLEXECDIR => SQLEXECDIRECT
SQLNUMRES => SQLNUMRESULTCOLS
SQLDESCRIB => SQLDESCRIBECOL
SQLEXTENDE => SQLEXTENDEDFETCH
SQLFETCHSC => SQLFETCHSCROLL
SQLROWCOUN => SQLROWCOUNT
SQLSETCONNECTOPTION => SQLSETCONNECTATTR
SQLSETSTMTOPTION => SQLSETSTMTATTR
SQLGETCONNECTOPTION => SQLGETCONNECTATTR
SQLGETSTMTOPTION => SQLGETSTMTATTR
* contrib/hbmysql/mysql.c
% Replaced Windows headers with winsock2.h which seems to
be required by mysql headers.
* contrib/hbfbird/firebird.c
* contrib/rddsql/sqlmix.c
* contrib/hbssl/sslrand.c
% Removed Windows headers.
* contrib/gtwvg/gtwvg.h
* contrib/gtwvg/wvggui.h
+ Readded ugly workaround for mingw64.
2009-03-26 20:54 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/contrib/hbole/olecore.c
! added some very basic protection against possible GPF if wrong

View File

@@ -63,7 +63,9 @@
#endif
#ifndef _WIN32_IE
#define _WIN32_IE 0x0400
#ifndef __MINGW64__
#define _WIN32_IE 0x0400
#endif
#endif

View File

@@ -92,7 +92,9 @@
#include "hbgtwvg.ch"
#ifndef _WIN32_IE
#define _WIN32_IE 0x0400
#ifndef __MINGW64__
#define _WIN32_IE 0x0400
#endif
#endif
HB_EXTERN_BEGIN

View File

@@ -52,11 +52,8 @@
*
*/
#include <stdlib.h>
#include <time.h>
#define HB_OS_WIN_USED
/* NOTE: Ugly hack to avoid this error when compiler with BCC 5.8.2 and above:
Error E2238 C:\...\Firebird-2.1.1\include\ibase.h 82: Multiple declaration for 'intptr_t' */
#if ( defined( __BORLANDC__ ) && __BORLANDC__ >= 1410 )
@@ -482,7 +479,7 @@ HB_FUNC( FBGETDATA )
break;
case SQL_TIMESTAMP:
isc_decode_timestamp ( ( ISC_TIMESTAMP * ) var->sqldata, &times );
isc_decode_timestamp( ( ISC_TIMESTAMP * ) var->sqldata, &times );
hb_snprintf( date_s, sizeof( date_s ), "%04d-%02d-%02d %02d:%02d:%02d.%04d",
times.tm_year + 1900,
times.tm_mon + 1,
@@ -505,7 +502,7 @@ HB_FUNC( FBGETDATA )
break;
case SQL_TYPE_TIME:
isc_decode_sql_time ( ( ISC_TIME * ) var->sqldata, &times );
isc_decode_sql_time( ( ISC_TIME * ) var->sqldata, &times );
hb_snprintf( date_s, sizeof( date_s ), "%02d:%02d:%02d.%04d",
times.tm_hour,
times.tm_min,

View File

@@ -61,12 +61,15 @@
*
*/
#define HB_OS_WIN_USED
#include "hbapi.h"
#include "hbapiitm.h"
#include "hbapifs.h"
#if defined(HB_OS_WIN)
/* NOTE: To satisfy MySQL headers. */
#include <winsock2.h>
#endif
#include "mysql.h"
/* NOTE: OS/2 EMX port of MySQL needs libmysqlclient.a from 3.21.33b build which has st and mt

View File

@@ -9,6 +9,12 @@ LIBNAME=hbodbc
ifeq ($(HB_COMPILER),rsxnt)
HB_WITHOUT_ODBC=yes
endif
ifeq ($(HB_ARCHITECTURE),dos)
HB_WITHOUT_ODBC=yes
endif
ifeq ($(HB_ARCHITECTURE),os2)
HB_WITHOUT_ODBC=yes
endif
ifneq ($(HB_ARCHITECTURE),win)
ifeq ($(HB_WITHOUT_ODBC),)

View File

@@ -78,8 +78,6 @@
#include "hbapi.h"
#if !defined(HB_OS_DOS) && !defined(HB_OS_OS2)
#if defined(HB_OS_LINUX) && defined(__WATCOMC__)
#include "/usr/include/sql.h"
#include "/usr/include/sqlext.h"
@@ -105,49 +103,46 @@
#endif
#endif
#if defined(__DMC__)
#ifndef SQL_NO_DATA
#define SQL_NO_DATA SQL_NO_DATA_FOUND
#define SQLColAttribute SQLColAttributes
SQLRETURN SQL_API SQLFetchScroll( SQLHSTMT StatementHandle,
SQLSMALLINT FetchOrientation, SQLINTEGER FetchOffset );
#endif
HB_FUNC( SQLALLOCEN ) /* HB_SQLALLOCENV( @hEnv ) --> nRetCode */
HB_FUNC( SQLALLOCENV ) /* SQLALLOCENV( @hEnv ) --> nRetCode */
{
HENV hEnv;
RETCODE ret = SQLAllocEnv( &hEnv );
SQLHENV hEnv;
SQLRETURN ret = SQLAllocEnv( &hEnv );
hb_storptr( hEnv, 1 );
hb_storptr( ( void * ) hEnv, 1 );
hb_retni( ret );
}
HB_FUNC( SQLALLOCCO ) /* HB_SQLALLOCCONNECT( hEnv, @ hDbc ) --> nRetCode */
HB_FUNC( SQLALLOCCONNECT ) /* SQLALLOCCONNECT( hEnv, @ hDbc ) --> nRetCode */
{
HDBC hDbc;
RETCODE ret = SQLAllocConnect( ( HENV ) hb_parptr( 1 ), &hDbc );
SQLHDBC hDbc;
SQLRETURN ret = SQLAllocConnect( ( SQLHENV ) hb_parptr( 1 ), &hDbc );
hb_storptr( hDbc, 2 );
hb_storptr( ( void * ) hDbc, 2 );
hb_retni( ret );
}
HB_FUNC( SQLDRIVERC ) /* HB_SQLDRIVERCONNECT( hDbc, @ cConnectString ) --> nRetCode */
HB_FUNC( SQLDRIVERCONNECT ) /* SQLDRIVERCONNECT( hDbc, @ cConnectString ) --> nRetCode */
{
SWORD wLen;
RETCODE ret;
SQLRETURN ret;
#if defined( HB_OS_WIN ) && defined( UNICODE )
LPTSTR lpStr = HB_TCHAR_CONVTO( hb_parcx( 2 ) );
TCHAR buffer[ 1024 ];
buffer[ 0 ] = '\0';
ret = SQLDriverConnect( ( HDBC ) hb_parptr( 1 ),
GetDesktopWindow(),
lpStr,
ret = SQLDriverConnect( ( SQLHDBC ) hb_parptr( 1 ),
( SQLHWND ) GetDesktopWindow(),
( SQLWCHAR * ) lpStr,
( SQLSMALLINT ) hb_parclen( 2 ),
buffer,
sizeof( buffer ),
&wLen,
SQL_DRIVER_COMPLETE );
( SQLWCHAR * ) buffer,
( SQLSMALLINT ) sizeof( buffer ),
( SQLSMALLINT * ) &wLen,
( SQLUSMALLINT ) SQL_DRIVER_COMPLETE );
HB_TCHAR_FREE( lpStr );
if( ISBYREF( 3 ) )
{
@@ -158,122 +153,124 @@ HB_FUNC( SQLDRIVERC ) /* HB_SQLDRIVERCONNECT( hDbc, @ cConnectString ) --> nRetC
#else
BYTE buffer[ 1024 ];
buffer[ 0 ] = '\0';
ret = SQLDriverConnect( ( HDBC ) hb_parptr( 1 ),
0,
ret = SQLDriverConnect( ( SQLHDBC ) hb_parptr( 1 ),
( SQLHWND ) 0,
( SQLCHAR * ) hb_parcx( 2 ),
( SQLSMALLINT ) hb_parclen( 2 ),
buffer,
sizeof( buffer ),
&wLen,
SQL_DRIVER_COMPLETE );
( SQLCHAR * ) buffer,
( SQLSMALLINT ) sizeof( buffer ),
( SQLSMALLINT * ) &wLen,
( SQLUSMALLINT ) SQL_DRIVER_COMPLETE );
hb_storc( ( char * ) buffer, 3 );
#endif
hb_retni( ret );
}
HB_FUNC( SQLCONNECT ) /* HB_SQLCONNECT( hDbc, cDSN, cUseName, cPassword ) --> nRetCode */
HB_FUNC( SQLCONNECT ) /* SQLCONNECT( hDbc, cDSN, cUseName, cPassword ) --> nRetCode */
{
RETCODE ret;
SQLRETURN ret;
#if defined( HB_OS_WIN ) && defined( UNICODE )
LPTSTR lpDSN = HB_TCHAR_CONVTO( hb_parcx( 2 ) ),
lpUseName = HB_TCHAR_CONVTO( hb_parcx( 3 ) ),
lpPassword = HB_TCHAR_CONVTO( hb_parcx( 4 ) );
ret = SQLConnect( ( HDBC ) hb_parptr( 1 ),
lpDSN,
ret = SQLConnect( ( SQLHDBC ) hb_parptr( 1 ),
( SQLWCHAR * ) lpDSN,
( SQLSMALLINT ) hb_parclen( 2 ),
lpUseName,
( SQLWCHAR * ) lpUseName,
( SQLSMALLINT ) hb_parclen( 3 ),
lpPassword,
( SQLWCHAR * ) lpPassword,
( SQLSMALLINT ) hb_parclen( 4 ) );
HB_TCHAR_FREE( lpDSN );
HB_TCHAR_FREE( lpUseName );
HB_TCHAR_FREE( lpPassword );
#else
ret = SQLConnect( ( HDBC ) hb_parptr( 1 ),
( unsigned char * ) hb_parcx( 2 ),
ret = SQLConnect( ( SQLHDBC ) hb_parptr( 1 ),
( SQLCHAR * ) hb_parcx( 2 ),
( SQLSMALLINT ) hb_parclen( 2 ),
( unsigned char * ) hb_parcx( 3 ),
( SQLCHAR * ) hb_parcx( 3 ),
( SQLSMALLINT ) hb_parclen( 3 ),
( unsigned char * ) hb_parcx( 4 ),
( SQLCHAR * ) hb_parcx( 4 ),
( SQLSMALLINT ) hb_parclen( 4 ) );
#endif
hb_retni( ret );
}
HB_FUNC( SQLDISCONN ) /* HB_SQLDISCONNECT( hDbc ) --> nRetCode */
HB_FUNC( SQLDISCONNECT ) /* SQLDISCONNECT( hDbc ) --> nRetCode */
{
hb_retni( SQLDisconnect( ( HDBC ) hb_parptr( 1 ) ) );
hb_retni( SQLDisconnect( ( SQLHDBC ) hb_parptr( 1 ) ) );
}
HB_FUNC( SQLFREECON ) /* HB_SQLFREECONNECT( hDbc ) --> nRetCode */
HB_FUNC( SQLFREECONNECT ) /* SQLFREECONNECT( hDbc ) --> nRetCode */
{
hb_retni( SQLFreeConnect( ( HDBC ) hb_parptr( 1 ) ) );
hb_retni( SQLFreeConnect( ( SQLHDBC ) hb_parptr( 1 ) ) );
}
HB_FUNC( SQLFREEENV ) /* HB_SQLFREEENV( hEnv ) --> nRetCode */
HB_FUNC( SQLFREEENV ) /* SQLFREEENV( hEnv ) --> nRetCode */
{
hb_retni( SQLFreeEnv( ( HENV ) hb_parptr( 1 ) ) );
hb_retni( SQLFreeEnv( ( SQLHENV ) hb_parptr( 1 ) ) );
}
HB_FUNC( SQLALLOCST ) /* HB_SQLALLOCSTMT( hDbc, @hStmt ) --> nRetCode */
HB_FUNC( SQLALLOCSTMT ) /* SQLALLOCSTMT( hDbc, @hStmt ) --> nRetCode */
{
HSTMT hStmt;
SQLHSTMT hStmt;
hb_retni( SQLAllocStmt( ( HDBC ) hb_parptr( 1 ), &hStmt ) );
hb_storptr( hStmt, 2 );
hb_retni( SQLAllocStmt( ( SQLHDBC ) hb_parptr( 1 ), &hStmt ) );
hb_storptr( ( void * ) hStmt, 2 );
}
HB_FUNC( SQLFREESTM ) /* HB_SQLFREESTMT( hStmt, nType ) --> nRetCode */
HB_FUNC( SQLFREESTMT ) /* SQLFREESTMT( hStmt, nType ) --> nRetCode */
{
hb_retni( SQLFreeStmt( ( HSTMT ) hb_parptr( 1 ), ( SQLUSMALLINT ) hb_parni( 2 ) ) );
hb_retni( SQLFreeStmt( ( SQLHSTMT ) hb_parptr( 1 ), ( SQLUSMALLINT ) hb_parni( 2 ) ) );
}
HB_FUNC( SQLEXECDIR ) /* HB_SQLEXECDIRECT( hStmt, cStatement ) --> nRetCode */
HB_FUNC( SQLEXECDIRECT ) /* SQLEXECDIRECT( hStmt, cStatement ) --> nRetCode */
{
#if defined( HB_OS_WIN ) && defined( UNICODE )
LPTSTR lpStr = HB_TCHAR_CONVTO( hb_parcx( 2 ) );
hb_retni( SQLExecDirect( ( HSTMT ) hb_parptr( 1 ), lpStr, hb_parclen( 2 ) ) );
SQLWCHAR * lpStr = HB_TCHAR_CONVTO( hb_parcx( 2 ) );
hb_retni( SQLExecDirect( ( SQLHSTMT ) hb_parptr( 1 ), ( SQLWCHAR * ) lpStr, ( SQLINTEGER ) hb_parclen( 2 ) ) );
HB_TCHAR_FREE( lpStr );
#else
hb_retni( SQLExecDirect( ( HSTMT ) hb_parptr( 1 ), ( unsigned char * ) hb_parcx( 2 ), hb_parclen( 2 ) ) );
hb_retni( SQLExecDirect( ( SQLHSTMT ) hb_parptr( 1 ), ( SQLCHAR * ) hb_parcx( 2 ), ( SQLINTEGER ) hb_parclen( 2 ) ) );
#endif
}
HB_FUNC( SQLFETCH ) /* HB_SQLFETCH( hStmt ) --> nRetCode */
HB_FUNC( SQLFETCH ) /* SQLFETCH( hStmt ) --> nRetCode */
{
hb_retni( SQLFetch( ( HSTMT ) hb_parptr( 1 ) ) );
hb_retni( SQLFetch( ( SQLHSTMT ) hb_parptr( 1 ) ) );
}
HB_FUNC( SQLGETDATA ) /* HB_SQLGETDATA( hStmt, nField, nType, nLen, @cBuffer ) --> nRetCode */
HB_FUNC( SQLGETDATA ) /* SQLGETDATA( hStmt, nField, nType, nLen, @cBuffer ) --> nRetCode */
{
SQLLEN lLen, lInitBuff, lBuffLen;
PTR bBuffer, bOut;
WORD wType, wResult;
void * bBuffer;
void * bOut;
SQLSMALLINT wType;
SQLRETURN result;
int iReallocs = 0;
wType = ( WORD ) hb_parni( 3 );
if( !wType )
wType = ( WORD ) SQL_BINARY;
lLen = ( SQLLEN ) hb_parnl( 4 );
if( !lLen )
wType = ( SQLSMALLINT ) hb_parni( 3 );
if( ! wType )
wType = SQL_BINARY;
lLen = ( SQLLEN ) hb_parnint( 4 );
if( ! lLen )
lLen = 64;
bBuffer = hb_xgrab( (ULONG) lLen + 1 );
bBuffer = hb_xgrab( ( ULONG ) lLen + 1 );
bOut = NULL;
lInitBuff = lLen;
lBuffLen = 0;
wResult = ! SQL_NO_DATA;
while( wResult != SQL_NO_DATA )
result = ! SQL_NO_DATA;
while( result != SQL_NO_DATA )
{
wResult = SQLGetData( ( HSTMT ) hb_parptr( 1 ), ( SQLUSMALLINT ) hb_parni( 2 ), wType, ( PTR ) bBuffer, lLen, &lLen );
if( wResult == SQL_SUCCESS && iReallocs == 0 )
result = SQLGetData( ( SQLHSTMT ) hb_parptr( 1 ), ( SQLUSMALLINT ) hb_parni( 2 ), wType, ( SQLPOINTER ) bBuffer, lLen, &lLen );
if( result == SQL_SUCCESS && iReallocs == 0 )
{
hb_storclen( ( LPSTR ) bBuffer, ( ULONG ) ( lLen < 0 ? 0 : ( lLen < hb_parnl( 4 ) ? lLen : hb_parnl( 4 ) ) ), 5 );
hb_storclen( ( char * ) bBuffer, ( long ) ( lLen < 0 ? 0 : ( lLen < hb_parnl( 4 ) ? lLen : hb_parnl( 4 ) ) ), 5 );
break;
}
else if ( wResult == SQL_SUCCESS_WITH_INFO && iReallocs == 0 )
else if( result == SQL_SUCCESS_WITH_INFO && iReallocs == 0 )
{
/* Perhaps a data truncation */
if( lLen >= lInitBuff )
@@ -288,43 +285,43 @@ HB_FUNC( SQLGETDATA ) /* HB_SQLGETDATA( hStmt, nField, nType, nLen, @cBuffer ) -
}
else
{
hb_storclen( ( LPSTR ) bBuffer, ( ULONG ) ( lLen < 0 ? 0 : ( lLen < hb_parnl( 4 ) ? lLen : hb_parnl( 4 ) ) ), 5 );
hb_storclen( ( char * ) bBuffer, ( long ) ( lLen < 0 ? 0 : ( lLen < hb_parnl( 4 ) ? lLen : hb_parnl( 4 ) ) ), 5 );
break;
}
}
else if( ( wResult == SQL_SUCCESS || wResult == SQL_SUCCESS_WITH_INFO ) && iReallocs > 0 )
else if( ( result == SQL_SUCCESS || result == SQL_SUCCESS_WITH_INFO ) && iReallocs > 0 )
{
hb_strncat( ( char * ) bOut, ( char * ) bBuffer, lBuffLen );
hb_storclen( ( LPSTR ) bOut, ( ULONG ) ( lLen + lInitBuff - 1 ), 5 );
wResult = SQL_SUCCESS;
hb_storclen( ( char * ) bOut, ( long ) ( lLen + lInitBuff - 1 ), 5 );
result = SQL_SUCCESS;
break;
}
else
break;
}
hb_xfree( ( PTR ) bBuffer );
hb_xfree( bBuffer );
if( bOut )
hb_xfree( ( PTR ) bOut );
hb_retni( wResult );
hb_xfree( bOut );
hb_retni( result );
}
HB_FUNC( SQLNUMRES ) /* HB_NUMRESULTCOLS( hStmt, @nColCount ) */
HB_FUNC( SQLNUMRESULTCOLS ) /* HB_NUMRESULTCOLS( hStmt, @nColCount ) */
{
SQLSMALLINT nCols;
WORD wResult = SQLNumResultCols( ( HSTMT ) hb_parptr( 1 ), &nCols );
SQLRETURN result = SQLNumResultCols( ( SQLHSTMT ) hb_parptr( 1 ), &nCols );
/* if( wResult == SQL_SUCCESS || wResult == SQL_SUCCESS_WITH_INFO ) */
hb_stornl( ( LONG ) nCols, 2 );
/* if( result == SQL_SUCCESS || result == SQL_SUCCESS_WITH_INFO ) */
hb_stornl( ( long ) nCols, 2 );
hb_retni( wResult );
hb_retni( result );
}
HB_FUNC( SQLDESCRIB ) /* HB_SQLDESCRIBECOL( hStmt, nCol, @cName, nLen, @nBufferLen, @nDataType, @nColSize, @nDec, @nNull ) --> nRetCode */
HB_FUNC( SQLDESCRIBECOL ) /* SQLDESCRIBECOL( hStmt, nCol, @cName, nLen, @nBufferLen, @nDataType, @nColSize, @nDec, @nNull ) --> nRetCode */
{
SDWORD lLen = ( SDWORD ) hb_parnl( 4 );
SQLSMALLINT lLen = ( SQLSMALLINT ) hb_parni( 4 );
SQLSMALLINT wBufLen = ( SQLUSMALLINT ) hb_parni( 5 );
SQLSMALLINT wDataType = ( SQLUSMALLINT ) hb_parni( 6 );
SQLULEN wColSize = hb_parni( 7 );
SQLULEN wColSize = ( SQLULEN ) hb_parnint( 7 );
SQLSMALLINT wDecimals = ( SQLUSMALLINT ) hb_parni( 8 );
SQLSMALLINT wNullable = ( SQLUSMALLINT ) hb_parni( 9 );
#if defined( HB_OS_WIN ) && defined( UNICODE )
@@ -332,19 +329,19 @@ HB_FUNC( SQLDESCRIB ) /* HB_SQLDESCRIBECOL( hStmt, nCol, @cName, nLen, @nBufferL
#else
SQLCHAR * buffer = ( SQLCHAR * ) hb_xgrab( lLen * sizeof( SQLCHAR ) );
#endif
WORD wResult;
SQLRETURN result;
wResult = SQLDescribeCol( ( HSTMT ) hb_parptr( 1 ),
( SQLUSMALLINT ) hb_parni( 2 ),
buffer,
( SQLSMALLINT ) lLen,
&wBufLen,
&wDataType,
&wColSize,
&wDecimals,
&wNullable );
result = SQLDescribeCol( ( SQLHSTMT ) hb_parptr( 1 ),
( SQLUSMALLINT ) hb_parni( 2 ),
( SQLCHAR * ) buffer,
( SQLSMALLINT ) lLen,
( SQLSMALLINT * ) &wBufLen,
( SQLSMALLINT * ) &wDataType,
( SQLULEN * ) &wColSize,
( SQLSMALLINT * ) &wDecimals,
( SQLSMALLINT * ) &wNullable );
if( wResult == SQL_SUCCESS || wResult == SQL_SUCCESS_WITH_INFO )
if( result == SQL_SUCCESS || result == SQL_SUCCESS_WITH_INFO )
{
if( ISBYREF( 3 ) )
{
@@ -353,78 +350,93 @@ HB_FUNC( SQLDESCRIB ) /* HB_SQLDESCRIBECOL( hStmt, nCol, @cName, nLen, @nBufferL
hb_storc( szStr, 3 );
HB_TCHAR_FREE( szStr );
#else
hb_storclen( ( char * ) buffer, ( WORD ) wBufLen, 3 );
hb_storclen( ( char * ) buffer, ( long ) wBufLen, 3 );
#endif
}
hb_stornl( ( LONG ) wBufLen, 5 );
hb_stornl( ( LONG ) wDataType, 6 );
hb_stornl( ( LONG ) wColSize, 7 );
hb_stornl( ( LONG ) wDecimals, 8 );
hb_stornl( ( LONG ) wNullable, 9 );
hb_storni( ( int ) wBufLen, 5 );
hb_storni( ( int ) wDataType, 6 );
hb_stornint( wColSize, 7 );
hb_storni( ( int ) wDecimals, 8 );
hb_storni( ( int ) wNullable, 9 );
}
hb_xfree( buffer );
hb_retni( wResult );
hb_retni( result );
}
HB_FUNC( SQLCOLATTRIBUTE ) /* SQLCOLATTRIBUTE( hStmt, nCol, nField, @cName, nLen, @nBufferLen, @nAttribute ) --> nRetCode */
{
SDWORD lLen = ( SDWORD ) hb_parnl( 5 );
PTR bBuffer = hb_xgrab( lLen );
void * bBuffer = hb_xgrab( hb_parnl( 5 ) );
SQLSMALLINT wBufLen = ( SQLUSMALLINT ) hb_parni( 6 );
#if defined(__DMC__)
SQLINTEGER wNumPtr = hb_parni( 7 );
SQLRETURN result;
#if ODBCVER >= 0x0300
SQLLEN wNumPtr = ( SQLLEN ) hb_parnint( 7 );
result = SQLColAttribute( ( SQLHSTMT ) hb_parptr( 1 ),
( SQLUSMALLINT ) hb_parni( 2 ),
( SQLUSMALLINT ) hb_parni( 3 ),
( SQLPOINTER ) bBuffer,
( SQLUSMALLINT ) hb_parni( 5 ),
( SQLSMALLINT * ) &wBufLen,
( SQLLEN * ) &wNumPtr );
#else
SQLLEN wNumPtr = hb_parni( 7 );
SQLINTEGER wNumPtr = hb_parnl( 7 );
result = SQLColAttributes( ( SQLHSTMT ) hb_parptr( 1 ),
( SQLUSMALLINT ) hb_parni( 2 ),
( SQLUSMALLINT ) hb_parni( 3 ),
( SQLPOINTER ) bBuffer,
( SQLUSMALLINT ) hb_parni( 5 ),
( SQLSMALLINT * ) &wBufLen,
( SQLINTEGER * ) &wNumPtr );
#endif
WORD wResult = SQLColAttribute( ( HSTMT ) hb_parptr( 1 ),
( SQLUSMALLINT ) hb_parni( 2 ),
( SQLUSMALLINT ) hb_parni( 3 ),
( unsigned char * ) bBuffer,
( SQLUSMALLINT ) hb_parni( 5 ),
&wBufLen,
&wNumPtr );
if( wResult == SQL_SUCCESS || wResult == SQL_SUCCESS_WITH_INFO )
if( result == SQL_SUCCESS || result == SQL_SUCCESS_WITH_INFO )
{
hb_storclen( ( LPSTR ) bBuffer,
( WORD ) wBufLen, 4 );
hb_stornl( ( LONG ) wBufLen, 6 );
hb_stornl( ( LONG ) wNumPtr, 7 );
hb_storclen( ( char * ) bBuffer, ( long ) wBufLen, 4 );
hb_storni( ( int ) wBufLen, 6 );
hb_stornint( wNumPtr, 7 );
}
hb_xfree( ( PTR ) bBuffer );
hb_retni( wResult );
hb_xfree( bBuffer );
hb_retni( result );
}
HB_FUNC( SQLEXTENDE ) /* HB_SQLEXTENDEDFETCH( hStmt, nOrientation, nOffset, @nRows, @nRowStatus ) */
HB_FUNC( SQLEXTENDEDFETCH ) /* SQLEXTENDEDFETCH( hStmt, nOrientation, nOffset, @nRows, @nRowStatus ) */
{
#if defined(__POCC__) || defined(__XCC__)
SQLROWSETSIZE uiRowCountPtr = hb_parni( 4 );
#else
SQLULEN uiRowCountPtr = hb_parni( 4 );
#endif
SQLUSMALLINT siRowStatus = ( SQLUSMALLINT ) hb_parni( 5 );
WORD wResult = SQLExtendedFetch( ( HSTMT ) hb_parptr( 1 ),
( USHORT ) hb_parnl( 2 ),
( USHORT ) hb_parnl( 3 ),
&uiRowCountPtr,
&siRowStatus );
#if defined(__POCC__) || defined(__XCC__)
SQLROWSETSIZE uiRowCountPtr = ( SQLROWSETSIZE ) hb_parnl( 4 );
SQLRETURN result = SQLExtendedFetch( ( SQLHSTMT ) hb_parptr( 1 ),
( SQLUSMALLINT ) hb_parni( 2 ),
( SQLROWOFFSET ) hb_parnl( 3 ),
( SQLROWSETSIZE * ) &uiRowCountPtr,
( SQLUSMALLINT * ) &siRowStatus );
#else
SQLULEN uiRowCountPtr = ( SQLULEN ) hb_parnint( 4 );
SQLRETURN result = SQLExtendedFetch( ( SQLHSTMT ) hb_parptr( 1 ),
( SQLUSMALLINT ) hb_parni( 2 ),
( SQLLEN ) hb_parnint( 3 ),
( SQLULEN * ) &uiRowCountPtr,
( SQLUSMALLINT * ) &siRowStatus );
#endif
if( wResult == SQL_SUCCESS || wResult == SQL_SUCCESS_WITH_INFO )
if( result == SQL_SUCCESS || result == SQL_SUCCESS_WITH_INFO )
{
hb_stornl( ( LONG ) uiRowCountPtr, 4 );
hb_stornl( ( LONG ) siRowStatus, 5 );
hb_stornint( uiRowCountPtr, 4 );
hb_storni( ( int ) siRowStatus, 5 );
}
hb_retni( wResult );
hb_retni( result );
}
HB_FUNC( SQLFETCHSC )
HB_FUNC( SQLFETCHSCROLL )
{
hb_retni( SQLFetchScroll( ( HSTMT ) hb_parptr( 1 ),
( SHORT ) hb_parnl( 2 ),
hb_parnl( 3 ) ) );
#if ODBCVER >= 0x0300
hb_retni( SQLFetchScroll( ( SQLHSTMT ) hb_parptr( 1 ),
( SQLSMALLINT ) hb_parnl( 2 ),
( SQLLEN ) hb_parnint( 3 ) ) );
#else
hb_retni( SQL_ERROR );
#endif
}
HB_FUNC( SQLERROR ) /* hEnv, hDbc, hStmt, @ cErrorClass, @ nType, @ cErrorMsg */
@@ -436,9 +448,9 @@ HB_FUNC( SQLERROR ) /* hEnv, hDbc, hStmt, @ cErrorClass, @ nType, @ cErrorMsg */
#else
BYTE buffer[ 256 ], szErrorMsg[ 256 ];
#endif
hb_retni( SQLError( ( HENV ) hb_parptr( 1 ),
( HDBC ) hb_parptr( 2 ),
( HSTMT ) ( HB_PTRUINT ) hb_parnint( 3 ),
hb_retni( SQLError( ( SQLHENV ) hb_parptr( 1 ),
( SQLHDBC ) hb_parptr( 2 ),
( SQLHSTMT ) ( HB_PTRUINT ) hb_parnint( 3 ),
buffer,
&lError,
szErrorMsg,
@@ -468,49 +480,49 @@ HB_FUNC( SQLERROR ) /* hEnv, hDbc, hStmt, @ cErrorClass, @ nType, @ cErrorMsg */
}
}
HB_FUNC( SQLROWCOUN )
HB_FUNC( SQLROWCOUNT )
{
SQLLEN iRowCountPtr = hb_parni( 2 );
WORD wResult = SQLRowCount( ( HSTMT ) hb_parptr( 1 ),
&iRowCountPtr );
SQLLEN iRowCountPtr = ( SQLLEN ) hb_parnint( 2 );
SQLRETURN result = SQLRowCount( ( SQLHSTMT ) hb_parptr( 1 ),
( SQLLEN * ) &iRowCountPtr );
if( wResult == SQL_SUCCESS || wResult == SQL_SUCCESS_WITH_INFO )
hb_stornl( ( LONG ) iRowCountPtr, 2 );
if( result == SQL_SUCCESS || result == SQL_SUCCESS_WITH_INFO )
hb_stornint( iRowCountPtr, 2 );
hb_retni( wResult );
hb_retni( result );
}
HB_FUNC( SQLGETINFO ) /* hDbc, nType, @cResult */
{
BYTE bBuffer[ 512 ];
SQLSMALLINT wLen;
WORD wResult = SQLGetInfo( ( HDBC ) hb_parptr( 1 ),
( UWORD ) hb_parnl( 2 ),
bBuffer,
sizeof( bBuffer ),
&wLen );
SQLRETURN result = SQLGetInfo( ( SQLHDBC ) hb_parptr( 1 ),
( SQLUSMALLINT ) hb_parnl( 2 ),
( SQLPOINTER ) bBuffer,
( SQLSMALLINT ) sizeof( bBuffer ),
( SQLSMALLINT * ) &wLen );
hb_storclen( ( char * ) bBuffer, wLen, 3 );
hb_retni( wResult );
hb_retni( result );
}
HB_FUNC( SQLSETCONNECTOPTION ) /* hDbc, nOption, uOption */
HB_FUNC( SQLSETCONNECTATTR ) /* hDbc, nOption, uOption */
{
#if (ODBCVER >= 0x0300)
#if ODBCVER >= 0x0300
hb_retni( SQLSetConnectAttr( ( SQLHDBC ) hb_parptr( 1 ),
( SQLINTEGER ) hb_parnl( 2 ),
ISCHAR( 3 ) ? ( SQLPOINTER ) hb_parcx( 3 ) : ( SQLPOINTER ) ( HB_PTRUINT ) hb_parnint( 3 ),
ISCHAR( 3 ) ? ( SQLINTEGER ) hb_parclen( 3 ) : ( SQLINTEGER ) SQL_IS_INTEGER ) );
#else
hb_retni( SQLSetConnectOption( ( HDBC ) hb_parptr( 1 ),
hb_retni( SQLSetConnectOption( ( SQLHDBC ) hb_parptr( 1 ),
( UWORD ) hb_parnl( 2 ),
( UDWORD ) ISCHAR( 3 ) ? ( LONG ) hb_parcx( 3 ) : hb_parnl( 3 ) ) );
#endif
}
HB_FUNC( SQLSETSTMTOPTION ) /* hStmt, nOption, uOption ) --> nRetCode */
HB_FUNC( SQLSETSTMTATTR ) /* hStmt, nOption, uOption ) --> nRetCode */
{
#if (ODBCVER >= 0x0300)
#if ODBCVER >= 0x0300
hb_retni( SQLSetStmtAttr( ( SQLHSTMT ) hb_parptr( 1 ),
( SQLINTEGER ) hb_parnl( 2 ),
ISCHAR( 3 ) ? ( SQLPOINTER ) hb_parcx( 3 ) : ( SQLPOINTER ) ( HB_PTRUINT ) hb_parnint( 3 ),
@@ -522,43 +534,47 @@ HB_FUNC( SQLSETSTMTOPTION ) /* hStmt, nOption, uOption ) --> nRetCode */
#endif
}
HB_FUNC( SQLGETCONNECTOPTION ) /* hDbc, nOption, @cOption */
HB_FUNC( SQLGETCONNECTATTR ) /* hDbc, nOption, @cOption */
{
#if (ODBCVER >= 0x0300)
#if ODBCVER >= 0x0300
SQLPOINTER buffer[ 512 ];
SQLINTEGER len;
SQLRETURN result = SQLGetConnectAttr( ( SQLHDBC ) hb_parptr( 1 ),
( SQLINTEGER ) hb_parni( 2 ),
buffer,
( SQLINTEGER ) hb_parnl( 2 ),
( SQLPOINTER ) buffer,
( SQLINTEGER ) sizeof( buffer ),
&len );
( SQLINTEGER * ) &len );
hb_storclen( result == SQL_SUCCESS ? ( char * ) buffer : NULL, len, 3 );
hb_retni( result );
#else
BYTE bBuffer[ 512 ];
WORD result = SQLGetConnectOption( ( HDBC ) hb_parptr( 1 ), hb_parni( 2 ), bBuffer );
SQLRETURN result = SQLGetConnectOption( ( SQLHDBC ) hb_parptr( 1 ),
( SQLSMALLINT ) hb_parni( 2 ),
( SQLPOINTER ) bBuffer );
hb_storclen( result == SQL_SUCCESS ? ( char * ) bBuffer : NULL, sizeof( bBuffer ), 3 );
hb_retni( result );
#endif
}
HB_FUNC( SQLGETSTMTOPTION ) /* hStmt, nOption, @cOption */
HB_FUNC( SQLGETSTMTATTR ) /* hStmt, nOption, @cOption */
{
#if (ODBCVER >= 0x0300)
#if ODBCVER >= 0x0300
SQLPOINTER buffer[ 512 ];
SQLINTEGER len;
SQLRETURN result = SQLGetStmtAttr( ( SQLHSTMT ) hb_parptr( 1 ),
( SQLINTEGER ) hb_parni( 2 ),
buffer,
( SQLINTEGER ) hb_parnl( 2 ),
( SQLPOINTER ) buffer,
( SQLINTEGER ) sizeof( buffer ),
&len );
( SQLINTEGER * ) &len );
hb_storclen( result == SQL_SUCCESS ? ( char * ) buffer : NULL, len, 3 );
hb_retni( result );
#else
BYTE bBuffer[ 512 ];
WORD result = SQLGetStmtOption( ( SQLHSTMT ) hb_parptr( 1 ), hb_parni( 2 ), bBuffer );
SQLRETURN result = SQLGetStmtOption( ( SQLHSTMT ) hb_parptr( 1 ),
( SQLSMALLINT ) hb_parni( 2 ),
( SQLPOINTER ) bBuffer );
hb_storclen( result == SQL_SUCCESS ? ( char * ) bBuffer : NULL, sizeof( bBuffer ), 3 );
hb_retni( result );
@@ -567,69 +583,90 @@ HB_FUNC( SQLGETSTMTOPTION ) /* hStmt, nOption, @cOption */
HB_FUNC( SQLCOMMIT ) /* hEnv, hDbc */
{
hb_retni( SQLTransact( ( HENV ) hb_parptr( 1 ), ( HDBC ) hb_parptr( 2 ), SQL_COMMIT ) );
hb_retni( SQLTransact( ( SQLHENV ) hb_parptr( 1 ), ( SQLHDBC ) hb_parptr( 2 ), SQL_COMMIT ) );
}
HB_FUNC( SQLROLLBACK ) /* hEnv, hDbc */
{
hb_retni( SQLTransact( ( HENV ) hb_parptr( 1 ), ( HDBC ) hb_parptr( 2 ), SQL_ROLLBACK ) );
hb_retni( SQLTransact( ( SQLHENV ) hb_parptr( 1 ), ( SQLHDBC ) hb_parptr( 2 ), SQL_ROLLBACK ) );
}
HB_FUNC( SETNUMLEN ) /* SETNUMLEN( nValue, nSize, nDecimals ) ==> nValue (nSize, nDec) */
{
hb_retnlen( hb_parnd( 1 ), hb_parni( 2 ), hb_parni( 3 ) );
}
HB_FUNC( SQLPREPARE ) /* HB_SQLPREPARE( hStmt, cStatement ) --> nRetCode */
HB_FUNC( SQLPREPARE ) /* SQLPREPARE( hStmt, cStatement ) --> nRetCode */
{
#if defined( HB_OS_WIN ) && defined( UNICODE )
LPTSTR lpStr = HB_TCHAR_CONVTO( hb_parcx( 2 ) );
hb_retni( SQLPrepare( ( HSTMT ) hb_parptr( 1 ), lpStr, SQL_NTS ) );
hb_retni( SQLPrepare( ( SQLHSTMT ) hb_parptr( 1 ), lpStr, SQL_NTS ) );
HB_TCHAR_FREE( lpStr );
#else
hb_retni( SQLPrepare( ( HSTMT ) hb_parptr( 1 ), ( unsigned char * ) hb_parcx( 2 ), SQL_NTS ) );
hb_retni( SQLPrepare( ( SQLHSTMT ) hb_parptr( 1 ), ( unsigned char * ) hb_parcx( 2 ), SQL_NTS ) );
#endif
}
HB_FUNC( SQLEXECUTE ) /* HB_SQLEXECUTE( hStmt ) --> nRetCode */
HB_FUNC( SQLEXECUTE ) /* SQLEXECUTE( hStmt ) --> nRetCode */
{
hb_retni( SQLExecute( ( HSTMT ) hb_parptr( 1 ) ) );
hb_retni( SQLExecute( ( SQLHSTMT ) hb_parptr( 1 ) ) );
}
HB_FUNC( SQLEXECUTESCALAR )
{
HSTMT hStmt;
SQLHSTMT hStmt;
SQLLEN lLen;
BYTE bBuffer[ 256 ];
SWORD wResult;
SWORD result;
wResult = SQLAllocStmt( ( HDBC ) hb_parptr( 2 ), &hStmt );
result = SQLAllocStmt( ( SQLHDBC ) hb_parptr( 2 ), &hStmt );
if( wResult == SQL_SUCCESS || wResult == SQL_SUCCESS_WITH_INFO )
if( result == SQL_SUCCESS || result == SQL_SUCCESS_WITH_INFO )
{
#if defined( HB_OS_WIN ) && defined( UNICODE )
LPTSTR lpStr = HB_TCHAR_CONVTO( hb_parcx( 1 ) );
wResult = SQLExecDirect( ( HSTMT ) hStmt, lpStr, SQL_NTS );
SQLWCHAR * lpStr = HB_TCHAR_CONVTO( hb_parcx( 1 ) );
result = SQLExecDirect( ( SQLHSTMT ) hStmt, ( SQLWCHAR * ) lpStr, SQL_NTS );
HB_TCHAR_FREE( lpStr );
#else
wResult = SQLExecDirect( ( HSTMT ) hStmt, ( unsigned char * ) hb_parcx( 1 ), SQL_NTS );
result = SQLExecDirect( ( SQLHSTMT ) hStmt, ( SQLCHAR * ) hb_parcx( 1 ), SQL_NTS );
#endif
if( wResult == SQL_SUCCESS || wResult == SQL_SUCCESS_WITH_INFO )
if( result == SQL_SUCCESS || result == SQL_SUCCESS_WITH_INFO )
{
wResult = SQLFetch( ( HSTMT ) hStmt );
if( wResult != SQL_NO_DATA )
result = SQLFetch( ( SQLHSTMT ) hStmt );
if( result != SQL_NO_DATA )
{
wResult = SQLGetData( ( HSTMT ) hStmt, 1, SQL_C_CHAR, bBuffer, sizeof( bBuffer ), &lLen );
result = SQLGetData( ( SQLHSTMT ) hStmt, 1, SQL_C_CHAR, ( SQLPOINTER ) bBuffer, sizeof( bBuffer ), &lLen );
hb_storc( ( char * ) bBuffer, 3 );
}
}
}
hb_retni( wResult );
hb_retni( result );
SQLFreeStmt( ( HSTMT ) hStmt, 0 );
SQLFreeStmt( ( SQLHSTMT ) hStmt, 0 );
}
HB_FUNC( SQLMORERESULTS ) /* hEnv, hDbc */
{
hb_retni( SQLMoreResults( ( SQLHSTMT ) hb_parptr( 1 ) ) );
}
#if 0
HB_FUNC( SQLBINDOUTPARAM ) /* SqlBindOutParam( nStatementHandle, nParameterNumber, nParameterType, ColumnSize, DecimalDigits, @ParamValue, @ParamLength ) --> nRetCode */
{
SQLLEN lLen = hb_parnint( 7 );
SQLRETURN ret;
ret = SQLBindParameter( ( SQLHSTMT ) hb_parptr( 1 ),
( SQLUSMALLINT ) hb_parni( 2 ),
( SQLSMALLINT ) SQL_PARAM_OUTPUT,
( SQLSMALLINT ) SQL_CHAR,
( SQLSMALLINT ) hb_parni( 3 ),
( SQLULEN ) hb_parnint( 4 ),
( SQLSMALLINT ) hb_parni( 5 ),
( SQLPOINTER ) hb_parcx( 6 ),
( SQLINTEGER ) hb_parclen( 6 ),
( SQLLEN * ) &lLen );
hb_stornint( lLen, 7 );
hb_retni( ret );
}
#endif
HB_FUNC( SQLSTOD )
{
if( hb_parclen( 1 ) >= 10 )
@@ -652,30 +689,29 @@ HB_FUNC( SQLSTOD )
hb_retds( NULL );
}
HB_FUNC( SQLMORERESULTS ) /* hEnv, hDbc */
HB_FUNC( SETNUMLEN ) /* SETNUMLEN( nValue, nSize, nDecimals ) ==> nValue (nSize, nDec) */
{
hb_retni( SQLMoreResults( ( SQLHSTMT ) hb_parptr( 1 ) ) );
hb_retnlen( hb_parnd( 1 ), hb_parni( 2 ), hb_parni( 3 ) );
}
#if 0
HB_FUNC( SQLBINDOUTPARAM ) /* SqlBindOutParam( nStatementHandle, nParameterNumber, nParameterType, ColumnSize, DecimalDigits, @ParamValue, @ParamLength ) --> nRetCode */
{
SQLLEN lLen = hb_parnl( 7 );
RETCODE ret;
#if !defined(HB_ODBC_LEGACY_LEVEL_OFF)
ret = SQLBindParameter( ( HSTMT ) hb_parptr( 1 ),
( USHORT ) hb_parni( 2 ),
SQL_PARAM_OUTPUT,
SQL_CHAR,
( USHORT ) hb_parni( 3 ),
( USHORT ) hb_parni( 4 ),
( USHORT ) hb_parni( 5 ),
hb_parcx( 6 ),
hb_parclen( 6 ),
&lLen );
hb_stornl( ( LONG ) lLen, 7 );
hb_retni( ret );
}
#endif
HB_FUNC_EXTERN( SQLALLOCENV ); HB_FUNC( SQLALLOCEN ) { HB_FUNC_EXEC( SQLALLOCENV ); }
HB_FUNC_EXTERN( SQLALLOCCONNECT ); HB_FUNC( SQLALLOCCO ) { HB_FUNC_EXEC( SQLALLOCCONNECT ); }
HB_FUNC_EXTERN( SQLDRIVERCONNECT ); HB_FUNC( SQLDRIVERC ) { HB_FUNC_EXEC( SQLDRIVERCONNECT ); }
HB_FUNC_EXTERN( SQLDISCONNECT ); HB_FUNC( SQLDISCONN ) { HB_FUNC_EXEC( SQLDISCONNECT ); }
HB_FUNC_EXTERN( SQLFREECONNECT ); HB_FUNC( SQLFREECON ) { HB_FUNC_EXEC( SQLFREECONNECT ); }
HB_FUNC_EXTERN( SQLALLOCSTMT ); HB_FUNC( SQLALLOCST ) { HB_FUNC_EXEC( SQLALLOCSTMT ); }
HB_FUNC_EXTERN( SQLFREESTMT ); HB_FUNC( SQLFREESTM ) { HB_FUNC_EXEC( SQLFREESTMT ); }
HB_FUNC_EXTERN( SQLEXECDIRECT ); HB_FUNC( SQLEXECDIR ) { HB_FUNC_EXEC( SQLEXECDIRECT ); }
HB_FUNC_EXTERN( SQLNUMRESULTCOLS ); HB_FUNC( SQLNUMRES ) { HB_FUNC_EXEC( SQLNUMRESULTCOLS ); }
HB_FUNC_EXTERN( SQLDESCRIBECOL ); HB_FUNC( SQLDESCRIB ) { HB_FUNC_EXEC( SQLDESCRIBECOL ); }
HB_FUNC_EXTERN( SQLEXTENDEDFETCH ); HB_FUNC( SQLEXTENDE ) { HB_FUNC_EXEC( SQLEXTENDEDFETCH ); }
HB_FUNC_EXTERN( SQLFETCHSCROLL ); HB_FUNC( SQLFETCHSC ) { HB_FUNC_EXEC( SQLFETCHSCROLL ); }
HB_FUNC_EXTERN( SQLROWCOUNT ); HB_FUNC( SQLROWCOUN ) { HB_FUNC_EXEC( SQLROWCOUNT ); }
HB_FUNC_EXTERN( SQLSETCONNECTATTR ); HB_FUNC( SQLSETCONNECTOPTION ) { HB_FUNC_EXEC( SQLSETCONNECTATTR ); }
HB_FUNC_EXTERN( SQLSETSTMTATTR ); HB_FUNC( SQLSETSTMTOPTION ) { HB_FUNC_EXEC( SQLSETSTMTATTR ); }
HB_FUNC_EXTERN( SQLGETCONNECTATTR ); HB_FUNC( SQLGETCONNECTOPTION ) { HB_FUNC_EXEC( SQLGETCONNECTATTR ); }
HB_FUNC_EXTERN( SQLGETSTMTATTR ); HB_FUNC( SQLGETSTMTOPTION ) { HB_FUNC_EXEC( SQLGETSTMTATTR ); }
#endif

View File

@@ -65,7 +65,7 @@ PROCEDURE Main()
PadR( dsFunctions:FieldByName( "City" ) :FieldName, 40 ) ;
COLOR "B/W"
WHILE !dsFunctions:Eof()
DO WHILE !dsFunctions:Eof()
? " " + PadR( dsFunctions:FieldByName( "First" ) :Value, 3 ), "³", ;
PadR( dsFunctions:FieldByName( "Last" ) :Value, 15 ), "³", ;
PadR( dsFunctions:FieldByName( "Street" ) :Value, 2 ), "³", ;

View File

@@ -25,21 +25,21 @@ PROCEDURE Main()
? padc( "*** ODBC ACCESS TEST ***", 80 )
?
? "Allocating environment... "
SQLAllocEn( @hEnv )
SQLAllocEnv( @hEnv )
? "Allocating connection... "
SQLAllocCo( hEnv, @hDbc )
SQLAllocConnect( hEnv, @hDbc )
? "Connecting to driver " + cConstrin + "... "
SQLDriverC( hDbc, cConstrin, @cConstrout )
SQLDriverConnect( hDbc, cConstrin, @cConstrout )
? "Allocating statement... "
SQLAllocSt( hDbc, @hStmt )
SQLAllocStmt( hDbc, @hStmt )
?
? "SQL: SELECT * FROM TEST"
SQLExecDir( hStmt, "select * from test" )
SQLExecDirect( hStmt, "select * from test" )
?
WHILE SQLFetch( hStmt ) == 0
DO WHILE SQLFetch( hStmt ) == 0
nRows++
GET ROW 1 INTO cCode
GET ROW 2 INTO cFunc
@@ -51,9 +51,9 @@ PROCEDURE Main()
? "------------------------------------------------------------------------------"
? str( nRows, 4 ), " row(s) affected."
SQLFreeStm( hStmt, SQL_DROP )
SQLDisconn( hDbc )
SQLFreeCon( hDbc )
SQLFreeStmt( hStmt, SQL_DROP )
SQLDisConnect( hDbc )
SQLFreeConnect( hDbc )
SQLFreeEnv( hEnv )
RETURN

View File

@@ -189,18 +189,18 @@ METHOD New( cODBCStr, cUserName, cPassword, lCache ) CLASS TODBC
::lCacheRS := lCache
// Allocates SQL Environment
IF ( nRet := SQLAllocEn( @xBuf ) ) == SQL_SUCCESS
IF ( nRet := SQLAllocEnv( @xBuf ) ) == SQL_SUCCESS
::hEnv := xBuf
ELSE
::nRetCode := nRet
RETURN NIL
ENDIF
SQLAllocCo( ::hEnv, @xBuf ) // Allocates SQL Connection
SQLAllocConnect( ::hEnv, @xBuf ) // Allocates SQL Connection
::hDbc := xBuf
IF cUserName == NIL
SQLDriverC( ::hDbc, ::cODBCStr, @xBuf ) // Connects to Driver
SQLDriverConnect( ::hDbc, ::cODBCStr, @xBuf ) // Connects to Driver
::cODBCRes := xBuf
ELSE
IF ! ( ( nRet := SQLConnect( ::hDbc, cODBCStr, cUserName, cPassword ) ) == SQL_SUCCESS .OR. nRet == SQL_SUCCESS_WITH_INFO )
@@ -229,8 +229,8 @@ METHOD SetAutocommit( lEnable ) CLASS TODBC
METHOD Destroy() CLASS TODBC
SQLDisconn( ::hDbc ) // Disconnects from Driver
SQLFreeCon( ::hDbc ) // Frees the connection
SQLDisConnect( ::hDbc ) // Disconnects from Driver
SQLFreeConnect( ::hDbc ) // Frees the connection
SQLFreeEnv( ::hEnv ) // Frees the environment
RETURN NIL
@@ -241,7 +241,7 @@ METHOD GetCnnOptions( nType ) CLASS TODBC
LOCAL cBuffer := Space( 256 )
::nRetCode := SQLGetConnectOption( ::hDbc, nType, @cBuffer )
::nRetCode := SQLGetConnectAttr( ::hDbc, nType, @cBuffer )
RETURN cBuffer
@@ -249,7 +249,7 @@ METHOD GetCnnOptions( nType ) CLASS TODBC
METHOD SetCnnOptions( nType, uBuffer ) CLASS TODBC
RETURN ::nRetCode := SQLSetConnectOption( ::hDbc, nType, uBuffer )
RETURN ::nRetCode := SQLSetConnectAttr( ::hDbc, nType, uBuffer )
/*-----------------------------------------------------------------------*/
@@ -269,7 +269,7 @@ METHOD GetStmtOptions( nType ) CLASS TODBC
LOCAL cBuffer := Space( 256 )
::nRetCode := SQLGetStmtOption( ::hStmt, nType, @cBuffer )
::nRetCode := SQLGetStmtAttr( ::hStmt, nType, @cBuffer )
RETURN cBuffer
@@ -277,7 +277,7 @@ METHOD GetStmtOptions( nType ) CLASS TODBC
METHOD SetStmtOptions( nType, uBuffer ) CLASS TODBC
RETURN ::nRetCode := SQLSetStmtOption( ::hStmt, nType, uBuffer )
RETURN ::nRetCode := SQLSetStmtAttr( ::hStmt, nType, uBuffer )
/*-----------------------------------------------------------------------*/
@@ -336,16 +336,16 @@ METHOD Open() CLASS TODBC
// Allocates and executes the statement
xBuf := ::hStmt
SQLAllocSt( ::hDbc, @xBuf )
SQLAllocStmt( ::hDbc, @xBuf )
::hStmt := xBuf
nRet := SQLExecDir( ::hStmt, ::cSQL )
nRet := SQLExecDirect( ::hStmt, ::cSQL )
// Get result information about fields and stores it
// on Fields collection
SQLNumRes( ::hStmt, @nCols )
SQLNumResultCols( ::hStmt, @nCols )
// Get number of rows in result set
nResult := SQLRowCoun( ::hStmt, @nRows )
nResult := SQLRowCount( ::hStmt, @nRows )
IF nResult == SQL_SUCCESS
::nRecCount := nRows
ENDIF
@@ -354,7 +354,7 @@ METHOD Open() CLASS TODBC
FOR i := 1 TO nCols
SQLDescrib( ::hStmt, i, @cColName, 255, @nNameLen, @nDataType, ;
SQLDescribeCol( ::hStmt, i, @cColName, 255, @nNameLen, @nDataType, ;
@nColSize, @nDecimals, @nNul )
AAdd( ::Fields, TODBCField():New() )
@@ -410,9 +410,9 @@ METHOD ExecSQL() CLASS TODBC
ELSE
// Allocates and executes the statement
xBuf := ::hStmt
SQLAllocSt( ::hDbc, @xBuf )
SQLAllocStmt( ::hDbc, @xBuf )
::hStmt := xBuf
nRet := SQLExecDir( ::hStmt, ::cSQL )
nRet := SQLExecDirect( ::hStmt, ::cSQL )
::Close()
ENDIF
@@ -425,7 +425,7 @@ METHOD ExecSQL() CLASS TODBC
METHOD Close() CLASS TODBC
// Frees the statement
SQLFreeStm( ::hStmt, SQL_DROP )
SQLFreeStmt( ::hStmt, SQL_DROP )
::Active := .F.
// Reset all recordset related variables
@@ -529,7 +529,7 @@ METHOD Fetch( nFetchType, nOffset ) CLASS TODBC
ELSE // apearently we don't have
// nResult := SQLFetch( ::hStmt /*, nFetchType, nOffSet */)
nResult := SQLExtende( ::hStmt, nFetchType, nOffSet, @nRows, 0 )
nResult := SQLExtendedFetch( ::hStmt, nFetchType, nOffSet, @nRows, 0 )
ENDIF
IF nResult == SQL_SUCCESS .OR. nResult == SQL_SUCCESS_WITH_INFO

View File

@@ -50,8 +50,6 @@
*
*/
#define HB_OS_WIN_USED
#include "hbapi.h"
#include "hbapierr.h"

View File

@@ -49,8 +49,6 @@
*
*/
#define HB_OS_WIN_USED
#include "hbapi.h"
#include "hbinit.h"
#include "hbapiitm.h"