49 #define NCBI_USE_ERRCODE_X Dbapi_DrvrUtil
78 if ((ts[
n - 1] & 0xC0) == 0xC0) {
81 if (
n + needed >
len) {
91 const void*
value,
size_t value_size,
94 static const char s_HexDigits[] =
"0123456789ABCDEF";
96 const unsigned char* c = (
const unsigned char*)
value;
97 size_t i = 0, margin = 0;
104 if (value_size * 2 + margin > buffer_size) {
111 for (
size_t j = 0; j < value_size; j++) {
112 buffer[
i++] = s_HexDigits[c[j] >> 4];
113 buffer[
i++] = s_HexDigits[c[j] & 0x0F];
171 }
catch (exception&) {
256 , m_MaxSize(max_size)
257 , m_DataType(data_type)
258 , m_Direction(direction)
291 const size_t param_num =
m_Info.size();
293 for (
unsigned int i = 0;
i < param_num; ++
i) {
294 if (
m_Info[
i].m_Name == name) {
316 return m_Info[num].m_Name;
356 return m_Info[num].m_MaxSize;
376 return m_Info[num].m_DataType;
396 return m_Info[num].m_Direction;
408 const string& sp_name,
427 unsigned int step = 0;
431 server_type =
conn.CalculateServerType(server_type);
443 unique_ptr<CDB_LangCmd>
cmd;
446 vector<string> arr_param;
451 switch (arr_param.size()) {
453 db_name = arr_param[pos++];
455 db_owner = arr_param[pos++];
457 sp_name = arr_param[pos++];
464 if (db_name.empty()) {
466 "SELECT '' from sysobjects WHERE name = @name \n"
468 "SELECT 'master' from master..sysobjects WHERE name = @name \n"
474 "SELECT 'sybsystemprocs' from sybsystemprocs..sysobjects WHERE name = @name \n"
476 "SELECT 'sybsystemdb' from sybsystemdb..sysobjects WHERE name = @name"
485 cmd->GetBindParams().Bind(
"@name", &sp_name_value);
488 while (
cmd->HasMoreResults()) {
489 unique_ptr<CDB_Result> res(
cmd->Result());
494 while (res->Fetch()) {
495 res->GetItem(&db_name_value);
497 if (!db_name_value.
IsNULL()) {
520 sql =
"exec " + db_name +
"." + db_owner +
".sp_sproc_columns @procedure_name";
525 cmd->GetBindParams().Bind(
"@procedure_name", &name_value);
528 while (
cmd->HasMoreResults()) {
529 unique_ptr<CDB_Result> res(
cmd->Result());
537 while (res->Fetch()) {
541 res->GetItem(&column_name);
542 res->GetItem(&column_type);
543 res->GetItem(&data_type);
546 res->GetItem(&data_len);
550 switch (data_type.
Value()) {
614 if (column_type.
Value() == 2 ||
615 column_type.
Value() == 4 ||
616 column_type.
Value() == 5 )
622 size_t(data_len.
Value()),
CMsgHandlerGuard(I_DriverContext &conn)
CDB_UserHandler_Exception m_Handler
CTempString implements a light-weight string on top of a storage buffer whose lifetime management is ...
virtual const string & GetName(const CDBParamVariant ¶m, CDBParamVariant::ENameFormat format=CDBParamVariant::eSQLServerName) const
Get name of column.
virtual unsigned int GetNum(void) const
Get total number of columns in resultset.
unsigned int GetNumInternal(void) const
virtual unsigned int GetIndex(const CDBParamVariant ¶m) const
void Add(const string &name, size_t max_size, EDB_Type data_type=eDB_UnsupportedType, EDirection direction=eOut) const
virtual ~CCachedRowInfo(void)
CCachedRowInfo(impl::CDB_Params &bindings)
virtual EDB_Type GetDataType(const CDBParamVariant ¶m) const
Get data type for column in the resultset.
virtual size_t GetMaxSize(const CDBParamVariant ¶m) const
Get maximum size in bytes for column.
bool IsInitialized(void) const
virtual void Initialize(void) const
void SetInitialized() const
unsigned int FindParamPosInternal(const string &name) const
virtual EDirection GetDirection(const CDBParamVariant ¶m) const
Get parameter's direction (in/out/inout).
void PushMsgHandler(CDB_UserHandler *h, EOwnership ownership=eNoOwnership)
Put the message handler into message handler stack.
void PopMsgHandler(CDB_UserHandler *h)
Remove the message handler (and all above it) from the stack.
virtual EDB_Type GetDataType(const CDBParamVariant ¶m) const
Get data type for column in the resultset.
AutoPtr< impl::CDB_Params > m_Bindings
virtual unsigned int GetIndex(const CDBParamVariant ¶m) const
virtual unsigned int GetNum(void) const
Get total number of columns in resultset.
CDBBindedParams(impl::CDB_Params &bindings, EOwnership ownership=eNoOwnership)
virtual const string & GetName(const CDBParamVariant ¶m, CDBParamVariant::ENameFormat format=CDBParamVariant::eSQLServerName) const
Get name of column.
virtual EDirection GetDirection(const CDBParamVariant ¶m) const
Get parameter's direction (in/out/inout).
virtual CDBParams * SemiShallowClone(void) const
Yield a lightweight copy of these parameters, sharing representations for variable-length datatypes.
virtual CDBParams & Bind(const CDBParamVariant ¶m, CDB_Object *value, bool out_param=false)
This method stores pointer to data.
virtual CDBParams & Set(const CDBParamVariant ¶m, CDB_Object *value, bool out_param=false)
This method stores copy of data.
virtual const CDB_Object * GetValue(const CDBParamVariant ¶m) const
Get value of column.
virtual size_t GetMaxSize(const CDBParamVariant ¶m) const
Get maximum size in bytes for column.
CDB_Object * GetParam(unsigned int param_no) const
bool BindParam(unsigned int param_no, const string ¶m_name, CDB_Object *param, bool is_out=false)
bool SetParam(unsigned int param_no, const string ¶m_name, CDB_Object *param, bool is_out=false)
const string & GetParamName(unsigned int param_no) const
CDB_Params * SemiShallowClone(void) const
Yield a lightweight copy of these parameters, sharing representations for variable-length datatypes.
unsigned int GetParamNum(const string ¶m_name) const
This method will throw an exception if parameter's name doesn't exist.
unsigned int NofParams() const
CDB_UserHandler_Exception m_Handler
CMsgHandlerGuard(impl::CConnection &conn)
impl::CConnection & m_Conn
const string & GetSPName(void) const
virtual ~CRowInfo_SP_SQL_Server(void)
virtual void Initialize(void) const
impl::CConnection & GetCConnection(void) const
CRowInfo_SP_SQL_Server(const string &sp_name, impl::CConnection &conn, impl::CDB_Params &bindings)
static CS_CONNECTION * conn
struct parameters_t bindings[]
@ eTakeOwnership
An object can take ownership of another.
#define DATABASE_DRIVER_ERROR(message, err_code)
bool IsPositional(void) const
virtual void PushDefConnMsgHandler(CDB_UserHandler *h, EOwnership ownership=eNoOwnership)=0
Add `per-connection' err.message handler "h" to the stack of default handlers which are inherited by ...
virtual void PopCntxMsgHandler(CDB_UserHandler *h)=0
Remove message handler "h" and all handlers above it in the stack.
virtual void PushCntxMsgHandler(CDB_UserHandler *h, EOwnership ownership=eNoOwnership)=0
Add message handler "h" to process 'context-wide' (not bound to any particular connection) error mess...
unsigned int GetPosition(void) const
virtual void PopDefConnMsgHandler(CDB_UserHandler *h)=0
Remove `per-connection' mess.
const string & GetName(void) const
virtual EDB_Type GetType() const =0
const string & AsString(void) const
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
NCBI_NS_STD::string::size_type SIZE_TYPE
static list< string > & Split(const CTempString str, const CTempString delim, list< string > &arr, TSplitFlags flags=0, vector< SIZE_TYPE > *token_pos=NULL)
Split a string using specified delimiters.
static TUnicodeSymbol DecodeFirst(char ch, SIZE_TYPE &more)
Begin converting first character of UTF8 sequence into Unicode.
static SIZE_TYPE GetValidBytesCount(const CTempString &src)
Get the number of valid UTF-8 bytes (code units) in buffer.
size_type size(void) const
Return the length of the represented array.
enum ENcbiOwnership EOwnership
Ownership relations between objects.
Definition of all error codes used in dbapi libraries (dbapi_driver.lib and others).
size_t binary_to_hex_string(char *buffer, size_t buffer_size, const void *value, size_t value_size, TBinaryToHexFlags flags=0)
SIZE_TYPE GetValidUTF8Len(const CTempString &ts)
const GenericPointer< typename T::ValueType > T2 value
#define SQL_LONGVARBINARY