Renamed some confusing parameter names

Support for SQLEndTransaction
This commit is contained in:
eknauel 2002-05-17 12:22:15 +00:00
parent 41a3e0fcfb
commit 5ab07b6398
2 changed files with 60 additions and 8 deletions

View File

@ -179,30 +179,30 @@ s48_value odbc_alloc_statement_handle(s48_value conn_handle) {
/* Connect to a server */
s48_value odbc_sql_connect(s48_value connection_handle,
s48_value server_name,
s48_value ds_name,
s48_value user_name,
s48_value authentication)
{
SQLHDBC ch;
SQLCHAR *server, *user, *auth;
SQLCHAR *dsn, *user, *auth;
SQLRETURN retval;
int server_len, user_len, auth_len;
int dsn_len, user_len, auth_len;
ODBC_DEBUG_PRINTF("odbc_sql_connect\n");
server = (SQLCHAR *) s48_extract_string(server_name);
dsn = (SQLCHAR *) s48_extract_string(ds_name);
user = (SQLCHAR *) s48_extract_string(user_name);
auth = (SQLCHAR *) s48_extract_string(authentication);
server_len = S48_STRING_LENGTH(server_name);
dsn_len = S48_STRING_LENGTH(ds_name);
user_len = S48_STRING_LENGTH(user_name);
auth_len = S48_STRING_LENGTH(authentication);
ch = (SQLHDBC) s48_extract_integer(connection_handle);
retval = SQLConnect(ch,
server, server_len,
dsn, dsn_len,
user, user_len,
auth, auth_len);
@ -1750,6 +1750,53 @@ s48_value odbc_sql_cancel(s48_value stmt_handle)
}
}
/* Commits or rolls back a transaction */
s48_value odbc_sql_endtran(s48_value handle_type, s48_value handle,
s48_value completion_type)
{
SQLSMALLINT ht, ct;
SQLHANDLE h;
SQLRETURN retval;
ODBC_DEBUG_PRINTF("odbc_sql_endtran\n");
ht = (SQLSMALLINT) s48_extract_integer(handle_type);
h = (SQLHANDLE) s48_extract_integer(handle);
ct = (SQLSMALLINT) s48_extract_integer(completion_type);
retval = SQLEndTran(ht, h, ct);
switch (retval)
{
case SQL_SUCCESS:
{
return S48_TRUE;
}
case SQL_SUCCESS_WITH_INFO:
{
ODBC_DEBUG_DIAGREC(ht, h);
return S48_TRUE;
}
case SQL_ERROR:
{
ODBC_DEBUG_DIAGREC(ht, h);
ODBC_RAISE_EXCEPTION("SQLEndTran returned SQL_ERROR");
break;
}
case SQL_INVALID_HANDLE:
{
ODBC_RAISE_EXCEPTION("SQLEndTran got invalid handle");
break;
}
default:
{
ODBC_RAISE_EXCEPTION("SQLEndTran returned unknown error code");
break;
}
}
}
/*
*
* PART 10
@ -2068,6 +2115,7 @@ void s48_init_odbc(void)
S48_EXPORT_FUNCTION(odbc_sql_free_statement);
S48_EXPORT_FUNCTION(odbc_sql_close_cursor);
S48_EXPORT_FUNCTION(odbc_sql_cancel);
S48_EXPORT_FUNCTION(odbc_sql_endtran);
/* PART 10 */
S48_EXPORT_FUNCTION(odbc_sql_disconnect);

View File

@ -87,11 +87,11 @@ void odbc_sql_set_env_attr(SQLHENV env_handle);
s48_value odbc_alloc_connection_handle(s48_value env_handle);
/* Given a valid connection handle get a statement handle */
s48_value odbc_alloc_statement_handle(s48_value db_handle);
s48_value odbc_alloc_statement_handle(s48_value stmt_handle);
/* Connect to a server */
s48_value odbc_sql_connect(s48_value connection_handle,
s48_value server_name,
s48_value ds_name,
s48_value user_name,
s48_value authentication);
@ -246,6 +246,10 @@ s48_value odbc_sql_close_cursor(s48_value stmt_handle);
/* Cancels an SQL statement */
s48_value odbc_sql_cancel(s48_value stmt_handle);
/* Commits or rolls back a transaction */
s48_value odbc_sql_endtran(s48_value handle_type, s48_value handle,
s48_value completion_type);
/*
*
* PART 10