SQLGetEnvAttr.cpp
上传用户:romrleung
上传日期:2022-05-23
资源大小:18897k
文件大小:2k
源码类别:

MySQL数据库

开发平台:

Visual C++

  1. /* Copyright (C) 2003 MySQL AB
  2.    This program is free software; you can redistribute it and/or modify
  3.    it under the terms of the GNU General Public License as published by
  4.    the Free Software Foundation; either version 2 of the License, or
  5.    (at your option) any later version.
  6.    This program is distributed in the hope that it will be useful,
  7.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  8.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  9.    GNU General Public License for more details.
  10.    You should have received a copy of the GNU General Public License
  11.    along with this program; if not, write to the Free Software
  12.    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
  13. #include "driver.hpp"
  14. #if ODBCVER >= 0x0300
  15. SQLRETURN SQL_API
  16. SQLGetEnvAttr(
  17.     SQLHENV EnvironmentHandle,
  18.     SQLINTEGER Attribute,
  19.     SQLPOINTER Value,
  20.     SQLINTEGER BufferLength,
  21.     SQLINTEGER* StringLength)
  22. {
  23.     driver_enter(SQL_API_SQLGETENVATTR);
  24.     const char* const sqlFunction = "SQLGetEnvAttr";
  25.     HandleRoot* const pRoot = HandleRoot::instance();
  26.     if (EnvironmentHandle == 0) {
  27. // process-level attributes
  28. Ctx& ctx = *new Ctx;
  29. ctx.logSqlEnter(sqlFunction);
  30. try {
  31.     pRoot->sqlGetRootAttr(ctx, Attribute, Value, BufferLength, StringLength);
  32. } catch (CtxAssert& ctxAssert) {
  33.     ctx.handleEx(ctxAssert);
  34. }
  35. pRoot->saveCtx(ctx);
  36. ctx.logSqlExit();
  37. SQLRETURN ret = ctx.getCode();
  38. driver_exit(SQL_API_SQLGETENVATTR);
  39. return ret;
  40.     } else {
  41. HandleEnv* pEnv = pRoot->findEnv(EnvironmentHandle);
  42. if (pEnv == 0) {
  43.     driver_exit(SQL_API_SQLGETENVATTR);
  44.     return SQL_INVALID_HANDLE;
  45. }
  46. Ctx& ctx = *new Ctx;
  47. ctx.logSqlEnter(sqlFunction);
  48. try {
  49.     pEnv->sqlGetEnvAttr(ctx, Attribute, Value, BufferLength, StringLength);
  50. } catch (CtxAssert& ctxAssert) {
  51.     ctx.handleEx(ctxAssert);
  52. }
  53. pEnv->saveCtx(ctx);
  54. ctx.logSqlExit();
  55. SQLRETURN ret = ctx.getCode();
  56. driver_exit(SQL_API_SQLGETENVATTR);
  57. return ret;
  58.     }
  59.     return SQL_ERROR; // not reached
  60. }
  61. #endif // ODBCVER >= 0x0300