fix for trie index
[csql.git] / src / odbc / odbcDesc.cxx
blobacf2883784ee7b6b894f52b2bcf6aa2e16fc8cb9
1 /* Class CSqlOdbcDescList
2 Description: Generic Descriptor manager.
4 Functions:
5 CSqlOdbcDescList::delDesc();
6 CSqlOdbcDescList::freeAllDesc();
7 CSqlOdbcDescList::getDescWithColNum();
9 CSqlOdbcDesc::CSqlOdbcDesc();
12 #include "odbcCommon.h"
14 // Class CSqlOdbcDescList Member functions
15 //----------------------------------
16 // Delete descriptor from list
17 SQLRETURN CSqlOdbcDescList::delDesc( CSqlOdbcDesc *node )
19 ListIterator iter = descList_.getIterator();
20 CSqlOdbcDesc *descElem = NULL;
21 while (iter.hasElement()) {
22 descElem = (CSqlOdbcDesc *) iter.nextElement();
23 if (descElem == node) {
24 iter.reset();
25 delete node;
26 descList_.remove(descElem);
27 return( SQL_SUCCESS );
30 return(SQL_ERROR);
33 void CSqlOdbcDescList::freeAllDesc( void )
35 ListIterator iter = descList_.getIterator();
36 CSqlOdbcDesc *descElem = NULL;
37 while (iter.hasElement()) {
38 descElem = (CSqlOdbcDesc *) iter.nextElement();
39 if (type_ == SQL_DESC_IMP) {
40 if (descElem->dataPtr_ != NULL) {
41 if(descElem->csqlType_ == typeString ||
42 descElem->csqlType_ == typeBinary)
43 delete [] (char*)descElem->dataPtr_;
44 else
45 delete descElem->dataPtr_;
46 descElem->dataPtr_=NULL;
49 delete descElem;
50 descElem = NULL;
52 descList_.reset();
55 SQLRETURN CSqlOdbcDescList::getDescWithColNum( int colNum, CSqlOdbcDesc **out )
57 ListIterator iter = descList_.getIterator();
58 CSqlOdbcDesc *descElem = NULL;
59 while (iter.hasElement()) {
60 descElem = (CSqlOdbcDesc *) iter.nextElement();
61 if (colNum == descElem->col_) {
62 *out = descElem;
63 return (SQL_SUCCESS);
66 return (SQL_ERROR);
69 CSqlOdbcDescList::CSqlOdbcDescList( int descType )
71 type_=descType;
74 // Class CSqlOdbcDesc Functions
75 //----------------------------------
76 CSqlOdbcDesc::CSqlOdbcDesc( void ) :
77 col_( 0 ),
78 dataPtr_( 0 ),
79 length_( 0 ),
80 precision_( 0 ),
81 scale_( 0 ),
82 indPtr_( 0 ),
83 cType_( -1 ),
84 sqlType_( -1 ),
85 csqlType_( -1 ),
86 paramType_( SQL_PARAM_TYPE_UNKNOWN )
88 schemaName_[0] = '\0';
89 tableName_[0] = '\0';
90 colName_[0] = '\0';