2010-02-27 12:28 UTC+0100 Viktor Szakats (harbour.01 syenar.hu)
* contrib/hbodbc/odbc.c
* contrib/rddsql/sddodbc/sddodbc.c
+ Added support for UNICODE mode on non-Windows systems.
This also means that by now HB_TCHAR_* macros aren't used
in non-win/wce code anymore.
NOTE: Since the translation functions have been changed,
now _SET_OSCODEPAGE setting are honored in these
calls. We may change this later to some lib specific cp.
; TOFIX: Warnings are showing up in non-UNICODE mode:
odbc.c:438: warning: pointer targets in passing argument 2 of 'hb_storstr' differ in signedness
Couldn't find an optimal way to pacify them (also in sddodbc).
Can someone help?
* include/hbdefs.h
+ HB_TCHAR_* macros are again only defined for win/wce targets.
This will make sure these won't get used in non-win/wce specific code.
* contrib/hbmysql/tmysql.prg
! Fixed old buggy code which started to throw errors
after introducing strict parameter evaluation in
lower-level code.
For now I replaced the code with old behavior.
Pls make further to replicate original _intent_.
This commit is contained in:
@@ -17,6 +17,31 @@
|
||||
past entries belonging to author(s): Viktor Szakats.
|
||||
*/
|
||||
|
||||
2010-02-27 12:28 UTC+0100 Viktor Szakats (harbour.01 syenar.hu)
|
||||
* contrib/hbodbc/odbc.c
|
||||
* contrib/rddsql/sddodbc/sddodbc.c
|
||||
+ Added support for UNICODE mode on non-Windows systems.
|
||||
This also means that by now HB_TCHAR_* macros aren't used
|
||||
in non-win/wce code anymore.
|
||||
NOTE: Since the translation functions have been changed,
|
||||
now _SET_OSCODEPAGE setting are honored in these
|
||||
calls. We may change this later to some lib specific cp.
|
||||
; TOFIX: Warnings are showing up in non-UNICODE mode:
|
||||
odbc.c:438: warning: pointer targets in passing argument 2 of 'hb_storstr' differ in signedness
|
||||
Couldn't find an optimal way to pacify them (also in sddodbc).
|
||||
Can someone help?
|
||||
|
||||
* include/hbdefs.h
|
||||
+ HB_TCHAR_* macros are again only defined for win/wce targets.
|
||||
This will make sure these won't get used in non-win/wce specific code.
|
||||
|
||||
* contrib/hbmysql/tmysql.prg
|
||||
! Fixed old buggy code which started to throw errors
|
||||
after introducing strict parameter evaluation in
|
||||
lower-level code.
|
||||
For now I replaced the code with old behavior.
|
||||
Pls make further to replicate original _intent_.
|
||||
|
||||
2010-02-27 11:14 UTC+0100 Viktor Szakats (harbour.01 syenar.hu)
|
||||
* contrib/rddsql/sddoci/sddoci.c
|
||||
+ Changed to use STR API for UNICODE conversions. This fixes
|
||||
|
||||
@@ -368,21 +368,9 @@ METHOD New( nSocket, cQuery ) CLASS TMySQLQuery
|
||||
NEXT
|
||||
|
||||
::getRow( ::nCurRow )
|
||||
|
||||
ELSE
|
||||
// Should query have returned rows? (Was it a SELECT like query?)
|
||||
|
||||
IF ( ::nNumFields := mysql_num_fields( nSocket ) ) == 0
|
||||
|
||||
// Was not a SELECT so reset ResultHandle changed by previous mysql_store_result()
|
||||
::nResultHandle := NIL
|
||||
|
||||
ELSE
|
||||
::lError := .T.
|
||||
|
||||
ENDIF
|
||||
::nResultHandle := NIL
|
||||
ENDIF
|
||||
|
||||
ELSE
|
||||
::lError := .T.
|
||||
ENDIF
|
||||
|
||||
@@ -76,14 +76,16 @@
|
||||
*/
|
||||
|
||||
#include "hbapi.h"
|
||||
#include "hbapistr.h"
|
||||
#include "hbset.h"
|
||||
|
||||
/* Required by headers on Windows */
|
||||
#if defined( HB_OS_WIN )
|
||||
# include <windows.h>
|
||||
#endif
|
||||
|
||||
#include <sql.h>
|
||||
#include <sqlext.h>
|
||||
#include <sqltypes.h>
|
||||
|
||||
#if !defined( HB_OS_WIN )
|
||||
# if !defined( SQLLEN ) && !defined( SQLTCHAR )
|
||||
@@ -101,6 +103,28 @@
|
||||
# define SQL_NO_DATA SQL_NO_DATA_FOUND
|
||||
#endif
|
||||
|
||||
#if defined( UNICODE )
|
||||
#define O_HB_PARSTR( n, h, len ) hb_parstr_u16( n, HB_CDP_ENDIAN_NATIVE, h, len )
|
||||
#define O_HB_PARSTRDEF( n, h, len ) hb_wstrnull( hb_parstr_u16( n, HB_CDP_ENDIAN_NATIVE, h, len ) )
|
||||
#define O_HB_STORSTR( str, n ) hb_storstr_u16( HB_CDP_ENDIAN_NATIVE, str, n )
|
||||
#define O_HB_STORSTRLEN( str, len, n ) hb_storstrlen_u16( HB_CDP_ENDIAN_NATIVE, str, len, n )
|
||||
#define O_HB_ARRAYGETSTR( arr, n, phstr, plen ) hb_arrayGetStrU16( arr, n, HB_CDP_ENDIAN_NATIVE, phstr, plen )
|
||||
#define O_HB_ITEMCOPYSTR( itm, str, len ) hb_itemCopyStrU16( itm, HB_CDP_ENDIAN_NATIVE, str, len )
|
||||
#define O_HB_ITEMGETSTR( itm, phstr, plen ) hb_itemGetStrU16( itm, HB_CDP_ENDIAN_NATIVE, phstr, plen )
|
||||
#define O_HB_ITEMPUTSTR( itm, str ) hb_itemPutStrU16( itm, HB_CDP_ENDIAN_NATIVE, str )
|
||||
#define O_HB_ITEMPUTSTRLEN( itm, str, len ) hb_itemPutStrLenU16( itm, HB_CDP_ENDIAN_NATIVE, str, len )
|
||||
#else
|
||||
#define O_HB_PARSTR( n, h, len ) hb_parstr( n, hb_setGetOSCP(), h, len )
|
||||
#define O_HB_PARSTRDEF( n, h, len ) hb_strnull( hb_parstr( n, hb_setGetOSCP(), h, len ) )
|
||||
#define O_HB_STORSTR( str, n ) hb_storstr( hb_setGetOSCP(), str, n )
|
||||
#define O_HB_STORSTRLEN( str, len, n ) hb_storstrlen( hb_setGetOSCP(), str, len, n )
|
||||
#define O_HB_ARRAYGETSTR( arr, n, phstr, plen ) hb_arrayGetStr( arr, n, hb_setGetOSCP(), phstr, plen )
|
||||
#define O_HB_ITEMCOPYSTR( itm, str, len ) hb_itemCopyStr( itm, hb_setGetOSCP(), str, len )
|
||||
#define O_HB_ITEMGETSTR( itm, phstr, plen ) hb_itemGetStr( itm, hb_setGetOSCP(), phstr, plen )
|
||||
#define O_HB_ITEMPUTSTR( itm, str ) hb_itemPutStr( itm, hb_setGetOSCP(), str )
|
||||
#define O_HB_ITEMPUTSTRLEN( itm, str, len ) hb_itemPutStrLen( itm, hb_setGetOSCP(), str, len )
|
||||
#endif
|
||||
|
||||
HB_FUNC( SQLALLOCENV ) /* @hEnv --> nRetCode */
|
||||
{
|
||||
SQLHENV hEnv;
|
||||
@@ -119,24 +143,24 @@ HB_FUNC( SQLDRIVERCONNECT ) /* hDbc, @cConnectString --> nRetCode */
|
||||
{
|
||||
SQLSMALLINT wLen;
|
||||
SQLRETURN ret;
|
||||
SQLTCHAR * lpStr = ( SQLTCHAR * ) HB_TCHAR_CONVTO( hb_parcx( 2 ) );
|
||||
void * hConnStr;
|
||||
SQLTCHAR buffer[ 1024 ];
|
||||
|
||||
buffer[ 0 ] = '\0';
|
||||
|
||||
ret = SQLDriverConnect( ( SQLHDBC ) hb_parptr( 1 ),
|
||||
( SQLHWND ) NULL,
|
||||
( SQLTCHAR * ) lpStr,
|
||||
( SQLTCHAR * ) O_HB_PARSTRDEF( 2, &hConnStr, NULL ),
|
||||
( SQLSMALLINT ) hb_parclen( 2 ),
|
||||
( SQLTCHAR * ) buffer,
|
||||
( SQLSMALLINT ) HB_SIZEOFARRAY( buffer ),
|
||||
( SQLSMALLINT * ) &wLen,
|
||||
( SQLUSMALLINT ) SQL_DRIVER_COMPLETE );
|
||||
HB_TCHAR_FREE( lpStr );
|
||||
if( HB_ISBYREF( 3 ) )
|
||||
{
|
||||
char * szStr = HB_TCHAR_CONVFROM( buffer );
|
||||
hb_storc( szStr, 3 );
|
||||
HB_TCHAR_FREE( szStr );
|
||||
}
|
||||
|
||||
hb_strfree( hConnStr );
|
||||
|
||||
O_HB_STORSTR( buffer, 3 );
|
||||
|
||||
hb_retni( ret );
|
||||
}
|
||||
|
||||
@@ -144,21 +168,21 @@ HB_FUNC( SQLCONNECT ) /* hDbc, cDSN, cUseName, cPassword --> nRetCode */
|
||||
{
|
||||
SQLRETURN ret;
|
||||
|
||||
SQLTCHAR * lpDSN = ( SQLTCHAR * ) HB_TCHAR_CONVTO( hb_parcx( 2 ) );
|
||||
SQLTCHAR * lpUseName = ( SQLTCHAR * ) HB_TCHAR_CONVTO( hb_parcx( 3 ) );
|
||||
SQLTCHAR * lpPassword = ( SQLTCHAR * ) HB_TCHAR_CONVTO( hb_parcx( 4 ) );
|
||||
void * hDSN;
|
||||
void * hUser;
|
||||
void * hPass;
|
||||
|
||||
ret = SQLConnect( ( SQLHDBC ) hb_parptr( 1 ),
|
||||
( SQLTCHAR * ) lpDSN,
|
||||
( SQLTCHAR * ) O_HB_PARSTRDEF( 2, &hDSN, NULL ),
|
||||
( SQLSMALLINT ) hb_parclen( 2 ),
|
||||
( SQLTCHAR * ) lpUseName,
|
||||
( SQLTCHAR * ) O_HB_PARSTRDEF( 3, &hUser, NULL ),
|
||||
( SQLSMALLINT ) hb_parclen( 3 ),
|
||||
( SQLTCHAR * ) lpPassword,
|
||||
( SQLTCHAR * ) O_HB_PARSTRDEF( 4, &hPass, NULL ),
|
||||
( SQLSMALLINT ) hb_parclen( 4 ) );
|
||||
|
||||
HB_TCHAR_FREE( lpDSN );
|
||||
HB_TCHAR_FREE( lpUseName );
|
||||
HB_TCHAR_FREE( lpPassword );
|
||||
hb_strfree( hDSN );
|
||||
hb_strfree( hUser );
|
||||
hb_strfree( hPass );
|
||||
|
||||
hb_retni( ret );
|
||||
}
|
||||
@@ -193,11 +217,11 @@ HB_FUNC( SQLFREESTMT ) /* hStmt, nType --> nRetCode */
|
||||
|
||||
HB_FUNC( SQLEXECDIRECT ) /* hStmt, cStatement --> nRetCode */
|
||||
{
|
||||
SQLTCHAR * lpStr = ( SQLTCHAR * ) HB_TCHAR_CONVTO( hb_parcx( 2 ) );
|
||||
void * hStatement;
|
||||
hb_retni( SQLExecDirect( ( SQLHSTMT ) hb_parptr( 1 ),
|
||||
( SQLTCHAR * ) lpStr,
|
||||
( SQLTCHAR * ) O_HB_PARSTRDEF( 2, &hStatement, NULL ),
|
||||
( SQLINTEGER ) hb_parclen( 2 ) ) );
|
||||
HB_TCHAR_FREE( lpStr );
|
||||
hb_strfree( hStatement );
|
||||
}
|
||||
|
||||
HB_FUNC( SQLFETCH ) /* hStmt --> nRetCode */
|
||||
@@ -309,12 +333,7 @@ HB_FUNC( SQLDESCRIBECOL ) /* hStmt, nCol, @cName, nLen, @nBufferLen, @nDataType,
|
||||
|
||||
if( result == SQL_SUCCESS || result == SQL_SUCCESS_WITH_INFO )
|
||||
{
|
||||
if( HB_ISBYREF( 3 ) )
|
||||
{
|
||||
char * szStr = HB_TCHAR_CONVNFROM( buffer, wBufLen );
|
||||
hb_storclen( szStr, ( HB_SIZE ) wBufLen, 3 );
|
||||
HB_TCHAR_FREE( szStr );
|
||||
}
|
||||
O_HB_STORSTRLEN( buffer, ( HB_SIZE ) wBufLen, 3 );
|
||||
hb_storni( ( int ) wBufLen, 5 );
|
||||
hb_storni( ( int ) wDataType, 6 );
|
||||
hb_stornint( wColSize, 7 );
|
||||
@@ -416,19 +435,9 @@ HB_FUNC( SQLERROR ) /* hEnv, hDbc, hStmt, @cErrorClass, @nType, @cErrorMsg */
|
||||
( SQLSMALLINT ) sizeof( szErrorMsg ),
|
||||
( SQLSMALLINT * ) &wLen ) );
|
||||
|
||||
if( HB_ISBYREF( 4 ) )
|
||||
{
|
||||
char * szStr = HB_TCHAR_CONVFROM( buffer );
|
||||
hb_storc( szStr, 4 );
|
||||
HB_TCHAR_FREE( szStr );
|
||||
}
|
||||
O_HB_STORSTR( buffer, 4 );
|
||||
hb_stornl( ( long ) lError, 5 );
|
||||
if( HB_ISBYREF( 6 ) )
|
||||
{
|
||||
char * szStr = HB_TCHAR_CONVFROM( szErrorMsg );
|
||||
hb_storc( szStr, 6 );
|
||||
HB_TCHAR_FREE( szStr );
|
||||
}
|
||||
O_HB_STORSTR( szErrorMsg, 6 );
|
||||
}
|
||||
|
||||
HB_FUNC( SQLROWCOUNT )
|
||||
@@ -544,11 +553,11 @@ HB_FUNC( SQLROLLBACK ) /* hEnv, hDbc */
|
||||
|
||||
HB_FUNC( SQLPREPARE ) /* hStmt, cStatement --> nRetCode */
|
||||
{
|
||||
SQLTCHAR * lpStr = ( SQLTCHAR * ) HB_TCHAR_CONVTO( hb_parcx( 2 ) );
|
||||
void * hStatement;
|
||||
hb_retni( SQLPrepare( ( SQLHSTMT ) hb_parptr( 1 ),
|
||||
( SQLTCHAR * ) lpStr,
|
||||
( SQLTCHAR * ) O_HB_PARSTRDEF( 2, &hStatement, NULL ),
|
||||
( SQLINTEGER ) SQL_NTS ) );
|
||||
HB_TCHAR_FREE( lpStr );
|
||||
hb_strfree( hStatement );
|
||||
}
|
||||
|
||||
HB_FUNC( SQLEXECUTE ) /* hStmt --> nRetCode */
|
||||
@@ -565,11 +574,11 @@ HB_FUNC( SQLEXECUTESCALAR )
|
||||
|
||||
if( result == SQL_SUCCESS || result == SQL_SUCCESS_WITH_INFO )
|
||||
{
|
||||
SQLTCHAR * lpStr = ( SQLTCHAR * ) HB_TCHAR_CONVTO( hb_parcx( 1 ) );
|
||||
void * hStatement;
|
||||
result = SQLExecDirect( ( SQLHSTMT ) hStmt,
|
||||
( SQLTCHAR * ) lpStr,
|
||||
( SQLTCHAR * ) O_HB_PARSTRDEF( 1, &hStatement, NULL ),
|
||||
( SQLINTEGER ) SQL_NTS );
|
||||
HB_TCHAR_FREE( lpStr );
|
||||
hb_strfree( hStatement );
|
||||
|
||||
if( result == SQL_SUCCESS || result == SQL_SUCCESS_WITH_INFO )
|
||||
{
|
||||
|
||||
@@ -52,18 +52,21 @@
|
||||
#include "hbapi.h"
|
||||
#include "hbapiitm.h"
|
||||
#include "hbdate.h"
|
||||
#include "hbapistr.h"
|
||||
#include "hbset.h"
|
||||
#include "hbvm.h"
|
||||
|
||||
#if defined( HB_OS_WIN )
|
||||
# include <windows.h>
|
||||
#endif
|
||||
|
||||
#if defined( __XCC__ ) || defined( __LCC__ )
|
||||
# include "hbrddsql.h"
|
||||
#else
|
||||
# include "../hbrddsql.h"
|
||||
#endif
|
||||
|
||||
/* Required by headers on Windows */
|
||||
#if defined( HB_OS_WIN )
|
||||
# include <windows.h>
|
||||
#endif
|
||||
|
||||
#include <sql.h>
|
||||
#include <sqlext.h>
|
||||
|
||||
@@ -79,6 +82,20 @@
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined( UNICODE )
|
||||
#define O_HB_ARRAYGETSTR( arr, n, phstr, plen ) hb_arrayGetStrU16( arr, n, HB_CDP_ENDIAN_NATIVE, phstr, plen )
|
||||
#define O_HB_ITEMCOPYSTR( itm, str, len ) hb_itemCopyStrU16( itm, HB_CDP_ENDIAN_NATIVE, str, len )
|
||||
#define O_HB_ITEMGETSTR( itm, phstr, plen ) hb_itemGetStrU16( itm, HB_CDP_ENDIAN_NATIVE, phstr, plen )
|
||||
#define O_HB_ITEMPUTSTR( itm, str ) hb_itemPutStrU16( itm, HB_CDP_ENDIAN_NATIVE, str )
|
||||
#define O_HB_ITEMPUTSTRLEN( itm, str, len ) hb_itemPutStrLenU16( itm, HB_CDP_ENDIAN_NATIVE, str, len )
|
||||
#else
|
||||
#define O_HB_ARRAYGETSTR( arr, n, phstr, plen ) hb_arrayGetStr( arr, n, hb_setGetOSCP(), phstr, plen )
|
||||
#define O_HB_ITEMCOPYSTR( itm, str, len ) hb_itemCopyStr( itm, hb_setGetOSCP(), str, len )
|
||||
#define O_HB_ITEMGETSTR( itm, phstr, plen ) hb_itemGetStr( itm, hb_setGetOSCP(), phstr, plen )
|
||||
#define O_HB_ITEMPUTSTR( itm, str ) hb_itemPutStr( itm, hb_setGetOSCP(), str )
|
||||
#define O_HB_ITEMPUTSTRLEN( itm, str, len ) hb_itemPutStrLen( itm, hb_setGetOSCP(), str, len )
|
||||
#endif
|
||||
|
||||
static HB_ERRCODE odbcConnect( SQLDDCONNECTION * pConnection, PHB_ITEM pItem );
|
||||
static HB_ERRCODE odbcDisconnect( SQLDDCONNECTION * pConnection );
|
||||
static HB_ERRCODE odbcExecute( SQLDDCONNECTION * pConnection, PHB_ITEM pItem );
|
||||
@@ -157,12 +174,13 @@ static char * odbcGetError( SQLHENV hEnv, SQLHDBC hConn, SQLHSTMT hStmt, HB_ERRC
|
||||
|
||||
if( SQL_SUCCEEDED( SQLError( hEnv, hConn, hStmt, szError, &iNativeErr, szError + 6, SQL_MAX_MESSAGE_LENGTH, &iLen ) ) )
|
||||
{
|
||||
char * szStr;
|
||||
PHB_ITEM pRet;
|
||||
|
||||
szError[ 5 ] = ' ';
|
||||
szStr = HB_TCHAR_CONVFROM( szError );
|
||||
szRet = hb_strdup( szStr );
|
||||
HB_TCHAR_FREE( szStr );
|
||||
|
||||
pRet = O_HB_ITEMPUTSTR( NULL, szError );
|
||||
szRet = hb_strdup( hb_itemGetCPtr( pRet ) );
|
||||
hb_itemRelease( pRet );
|
||||
}
|
||||
else
|
||||
szRet = hb_strdup( "HY000 Unable to get error message" );
|
||||
@@ -188,29 +206,29 @@ static HB_ERRCODE odbcConnect( SQLDDCONNECTION * pConnection, PHB_ITEM pItem )
|
||||
|
||||
if( SQL_SUCCEEDED( SQLAllocHandle( SQL_HANDLE_DBC, hEnv, &hConnect ) ) )
|
||||
{
|
||||
SQLTCHAR * lpStr = ( SQLTCHAR * ) HB_TCHAR_CONVTO( hb_arrayGetCPtr( pItem, 2 ) );
|
||||
SQLTCHAR cBuffer[ 1024 ];
|
||||
SQLSMALLINT iLen = 1024;
|
||||
void * hConnStr;
|
||||
SQLTCHAR cBuffer[ 1024 ];
|
||||
SQLSMALLINT iLen = HB_SIZEOFARRAY( cBuffer );
|
||||
|
||||
cBuffer[ 0 ] ='\0';
|
||||
|
||||
if( SQL_SUCCEEDED( SQLDriverConnect( hConnect,
|
||||
NULL,
|
||||
lpStr,
|
||||
( SQLTCHAR * ) O_HB_ARRAYGETSTR( pItem, 2, &hConnStr, NULL ),
|
||||
( SQLSMALLINT ) hb_arrayGetCLen( pItem, 2 ),
|
||||
cBuffer,
|
||||
HB_SIZEOFARRAY( cBuffer ),
|
||||
&iLen,
|
||||
SQL_DRIVER_NOPROMPT ) ) )
|
||||
{
|
||||
HB_TCHAR_FREE( lpStr );
|
||||
hb_strfree( hConnStr );
|
||||
pConnection->hCargo = ( void * ) hEnv;
|
||||
pConnection->hConnection = ( void * ) hConnect;
|
||||
return HB_SUCCESS;
|
||||
}
|
||||
else
|
||||
{
|
||||
HB_TCHAR_FREE( lpStr );
|
||||
hb_strfree( hConnStr );
|
||||
szError = odbcGetError( hEnv, hConnect, SQL_NULL_HSTMT, &errCode );
|
||||
hb_rddsqlSetError( errCode, szError, NULL, NULL, 0 );
|
||||
hb_xfree( szError );
|
||||
@@ -246,7 +264,7 @@ static HB_ERRCODE odbcDisconnect( SQLDDCONNECTION * pConnection )
|
||||
|
||||
static HB_ERRCODE odbcExecute( SQLDDCONNECTION * pConnection, PHB_ITEM pItem )
|
||||
{
|
||||
SQLTCHAR * lpStr;
|
||||
void * hStatement;
|
||||
SQLHSTMT hStmt;
|
||||
SQLLEN iCount;
|
||||
char * szError;
|
||||
@@ -260,11 +278,9 @@ static HB_ERRCODE odbcExecute( SQLDDCONNECTION * pConnection, PHB_ITEM pItem )
|
||||
return HB_FAILURE;
|
||||
}
|
||||
|
||||
lpStr = ( SQLTCHAR * ) HB_TCHAR_CONVTO( hb_itemGetCPtr( pItem ) );
|
||||
|
||||
if ( SQL_SUCCEEDED( SQLExecDirect( hStmt, lpStr, hb_itemGetCLen( pItem ) ) ) )
|
||||
if ( SQL_SUCCEEDED( SQLExecDirect( hStmt, ( SQLTCHAR * ) O_HB_ITEMGETSTR( pItem, &hStatement, NULL ), hb_itemGetCLen( pItem ) ) ) )
|
||||
{
|
||||
HB_TCHAR_FREE( lpStr );
|
||||
hb_strfree( hStatement );
|
||||
|
||||
if ( SQL_SUCCEEDED( SQLRowCount( hStmt, &iCount ) ) )
|
||||
{
|
||||
@@ -275,7 +291,7 @@ static HB_ERRCODE odbcExecute( SQLDDCONNECTION * pConnection, PHB_ITEM pItem )
|
||||
}
|
||||
}
|
||||
else
|
||||
HB_TCHAR_FREE( lpStr );
|
||||
hb_strfree( hStatement );
|
||||
|
||||
szError = odbcGetError( ( SQLHENV ) pConnection->hCargo, ( SQLHDBC ) pConnection->hConnection, hStmt, &errCode );
|
||||
hb_rddsqlSetError( errCode, szError, hb_itemGetCPtr( pItem ), NULL, errCode );
|
||||
@@ -287,7 +303,7 @@ static HB_ERRCODE odbcExecute( SQLDDCONNECTION * pConnection, PHB_ITEM pItem )
|
||||
|
||||
static HB_ERRCODE odbcOpen( SQLBASEAREAP pArea )
|
||||
{
|
||||
SQLTCHAR * lpStr;
|
||||
void * hQuery;
|
||||
SQLHSTMT hStmt;
|
||||
SQLSMALLINT iNameLen, iDataType, iDec, iNull;
|
||||
SQLTCHAR cName[ 256 ];
|
||||
@@ -307,11 +323,12 @@ static HB_ERRCODE odbcOpen( SQLBASEAREAP pArea )
|
||||
return HB_FAILURE;
|
||||
}
|
||||
|
||||
lpStr = ( SQLTCHAR * ) HB_TCHAR_CONVTO( pArea->szQuery );
|
||||
pItem = hb_itemPutC( NULL, pArea->szQuery );
|
||||
|
||||
if ( ! SQL_SUCCEEDED( SQLExecDirect( hStmt, lpStr, strlen( pArea->szQuery ) ) ) )
|
||||
if ( ! SQL_SUCCEEDED( SQLExecDirect( hStmt, ( SQLTCHAR * ) O_HB_ITEMGETSTR( pItem, &hQuery, NULL ), hb_itemGetCLen( pItem ) ) ) )
|
||||
{
|
||||
HB_TCHAR_FREE( lpStr );
|
||||
hb_strfree( hQuery );
|
||||
hb_itemRelease( pItem );
|
||||
szError = odbcGetError( ( SQLHENV ) pArea->pConnection->hCargo, ( SQLHDBC ) pArea->pConnection->hConnection, hStmt, &errCode );
|
||||
SQLFreeStmt( hStmt, SQL_DROP );
|
||||
hb_errRT_ODBCDD( EG_OPEN, ESQLDD_INVALIDQUERY, szError, pArea->szQuery, errCode );
|
||||
@@ -319,7 +336,10 @@ static HB_ERRCODE odbcOpen( SQLBASEAREAP pArea )
|
||||
return HB_FAILURE;
|
||||
}
|
||||
else
|
||||
HB_TCHAR_FREE( lpStr );
|
||||
{
|
||||
hb_strfree( hQuery );
|
||||
hb_itemRelease( pItem );
|
||||
}
|
||||
|
||||
if ( ! SQL_SUCCEEDED( SQLNumResultCols( hStmt, &iNameLen ) ) )
|
||||
{
|
||||
@@ -341,7 +361,7 @@ static HB_ERRCODE odbcOpen( SQLBASEAREAP pArea )
|
||||
bError = HB_FALSE;
|
||||
for ( uiIndex = 0; uiIndex < uiFields; uiIndex++ )
|
||||
{
|
||||
if ( ! SQL_SUCCEEDED( SQLDescribeCol( hStmt, ( SQLSMALLINT ) uiIndex + 1, ( SQLTCHAR* ) cName, HB_SIZEOFARRAY( cName ), &iNameLen, &iDataType, &uiSize, &iDec, &iNull ) ) )
|
||||
if ( ! SQL_SUCCEEDED( SQLDescribeCol( hStmt, ( SQLSMALLINT ) uiIndex + 1, ( SQLTCHAR * ) cName, HB_SIZEOFARRAY( cName ), &iNameLen, &iDataType, &uiSize, &iDec, &iNull ) ) )
|
||||
{
|
||||
hb_itemRelease( pItemEof );
|
||||
szError = odbcGetError( ( SQLHENV ) pArea->pConnection->hCargo, ( SQLHDBC ) pArea->pConnection->hConnection, hStmt, NULL );
|
||||
@@ -422,7 +442,7 @@ static HB_ERRCODE odbcOpen( SQLBASEAREAP pArea )
|
||||
{
|
||||
case HB_FT_STRING:
|
||||
{
|
||||
char* pStr;
|
||||
char * pStr;
|
||||
|
||||
pStr = ( char * ) hb_xgrab( ( HB_SIZE ) pFieldInfo.uiLen + 1 );
|
||||
memset( pStr, ' ', pFieldInfo.uiLen );
|
||||
|
||||
@@ -1575,26 +1575,28 @@ typedef HB_U32 HB_FATTR;
|
||||
|
||||
#endif
|
||||
|
||||
#if defined( HB_OS_WIN ) && defined( UNICODE )
|
||||
#define HB_TCHAR_CPTO(d,s,l) hb_mbtowccpy(d,s,l)
|
||||
#define HB_TCHAR_GETFROM(d,s,l) hb_wctombget(d,s,l)
|
||||
#define HB_TCHAR_SETTO(d,s,l) hb_mbtowcset(d,s,l)
|
||||
#define HB_TCHAR_CONVTO(s) hb_mbtowc(s)
|
||||
#define HB_TCHAR_CONVFROM(s) hb_wctomb(s)
|
||||
#define HB_TCHAR_CONVNTO(s,l) hb_mbntowc(s,l)
|
||||
#define HB_TCHAR_CONVNFROM(s,l) hb_wcntomb(s,l)
|
||||
#define HB_TCHAR_CONVNREV(d,s,l) do { hb_wctombget(d,s,l); hb_xfree(s); } while( 0 )
|
||||
#define HB_TCHAR_FREE(s) hb_xfree(s)
|
||||
#else
|
||||
#define HB_TCHAR_CPTO(d,s,l) hb_strncpy(d,s,l)
|
||||
#define HB_TCHAR_SETTO(d,s,l) memcpy(d,s,l)
|
||||
#define HB_TCHAR_GETFROM(d,s,l) memcpy(d,s,l)
|
||||
#define HB_TCHAR_CONVTO(s) ((char *)(s))
|
||||
#define HB_TCHAR_CONVFROM(s) ((char *)(s))
|
||||
#define HB_TCHAR_CONVNTO(s,l) ((char *)(s))
|
||||
#define HB_TCHAR_CONVNFROM(s,l) ((char *)(s))
|
||||
#define HB_TCHAR_CONVNREV(d,s,l) do { ; } while( 0 )
|
||||
#define HB_TCHAR_FREE(s) HB_SYMBOL_UNUSED(s)
|
||||
#if defined( HB_OS_WIN )
|
||||
#if defined( UNICODE )
|
||||
#define HB_TCHAR_CPTO(d,s,l) hb_mbtowccpy(d,s,l)
|
||||
#define HB_TCHAR_GETFROM(d,s,l) hb_wctombget(d,s,l)
|
||||
#define HB_TCHAR_SETTO(d,s,l) hb_mbtowcset(d,s,l)
|
||||
#define HB_TCHAR_CONVTO(s) hb_mbtowc(s)
|
||||
#define HB_TCHAR_CONVFROM(s) hb_wctomb(s)
|
||||
#define HB_TCHAR_CONVNTO(s,l) hb_mbntowc(s,l)
|
||||
#define HB_TCHAR_CONVNFROM(s,l) hb_wcntomb(s,l)
|
||||
#define HB_TCHAR_CONVNREV(d,s,l) do { hb_wctombget(d,s,l); hb_xfree(s); } while( 0 )
|
||||
#define HB_TCHAR_FREE(s) hb_xfree(s)
|
||||
#else
|
||||
#define HB_TCHAR_CPTO(d,s,l) hb_strncpy(d,s,l)
|
||||
#define HB_TCHAR_SETTO(d,s,l) memcpy(d,s,l)
|
||||
#define HB_TCHAR_GETFROM(d,s,l) memcpy(d,s,l)
|
||||
#define HB_TCHAR_CONVTO(s) ((char *)(s))
|
||||
#define HB_TCHAR_CONVFROM(s) ((char *)(s))
|
||||
#define HB_TCHAR_CONVNTO(s,l) ((char *)(s))
|
||||
#define HB_TCHAR_CONVNFROM(s,l) ((char *)(s))
|
||||
#define HB_TCHAR_CONVNREV(d,s,l) do { ; } while( 0 )
|
||||
#define HB_TCHAR_FREE(s) HB_SYMBOL_UNUSED(s)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Function declaration macros */
|
||||
|
||||
Reference in New Issue
Block a user