From ab9dec8671eeb90230064474cf86c49c69fd8e10 Mon Sep 17 00:00:00 2001
From: znone <glyc@sina.com.cn>
Date: Wed, 27 Jun 2018 06:54:45 +0000
Subject: [PATCH] 允许用字段名绑定数据(会影响性能) 允许对同一个数据结构进行不同的绑定
---
include/qtl_odbc.hpp | 22 ++++++++++++++++++++++
1 files changed, 22 insertions(+), 0 deletions(-)
diff --git a/include/qtl_odbc.hpp b/include/qtl_odbc.hpp
index 99a4c49..c31c620 100644
--- a/include/qtl_odbc.hpp
+++ b/include/qtl_odbc.hpp
@@ -538,6 +538,26 @@
return count;
}
+ size_t find_field(const char* name) const
+ {
+ SQLSMALLINT count=0;
+ verify_error(SQLNumResultCols(m_handle, &count));
+ for(SQLSMALLINT i=0; i!=count; i++)
+ {
+ SQLCHAR field_name[256]={0};
+ SQLSMALLINT name_length=0;
+ SQLSMALLINT data_type;
+ SQLULEN column_size;
+ SQLSMALLINT digits;
+ SQLSMALLINT nullable;
+ verify_error(SQLDescribeCol(m_handle, i, field_name, sizeof(field_name), &name_length,
+ &data_type, &column_size, &digits, &nullable));
+ if(strncmp((char*)field_name, name, name_length)==0)
+ return i;
+ }
+ return -1;
+ }
+
/*
ODBC do not support this function, but you can use query to instead it:
For MS SQL Server: SELECT @@IDENTITY;
@@ -595,6 +615,8 @@
class database : public object<SQL_HANDLE_DBC>, public qtl::base_database<database, statement>
{
public:
+ typedef odbc::error exception_type;
+
explicit database(environment& env) : object(env.handle()), m_opened(false)
{
}
--
Gitblit v1.9.3