void Cask::CdapOdbc::ColumnsDataReader::getColumnValue(const ColumnBinding& binding) {
  auto& record = this->queryResult.getRows().at(this->currentRowIndex);
  std::wstring name;
  std::wstring typeName;
  SQLSMALLINT radix = 0;

  switch (binding.getColumnNumber()) {
    case 1: // TABLE_CAT 
    case 2: // TABLE_SCHEM 
    case 9: // DECIMAL_DIGITS 
    case 12: // REMARKS 
    case 13: // COLUMN_DEF 
    case 15: // SQL_DATETIME_SUB 
    case 16: // CHAR_OCTET_LENGTH 
      this->fetchNull(binding);
      break;
    case 3: // TABLE_NAME 
      this->fetchVarchar(this->tableName.c_str(), binding);
      break;
    case 4: // COLUMN_NAME 
      name = record.at(L"name").as_string();
      this->fetchVarchar(name.c_str(), binding);
      break;
    case 5: // DATA_TYPE
    case 14: // SQL_DATA_TYPE 
      this->fetchSmallint(getDataType(record.at(L"type")), binding);
      break;
    case 6: // TYPE_NAME 
      typeName = getTypeName(record.at(L"type"));
      this->fetchVarchar(typeName.c_str(), binding);
      break;
    case 7: // COLUMN_SIZE 
      this->fetchInt(getColumnSize(record.at(L"type")), binding);
      break;
    case 8: // BUFFER_LENGTH 
      this->fetchInt(getBufferLength(record.at(L"type")), binding);
      break;
    case 10: // NUM_PREC_RADIX 
      radix = getRadix(record.at(L"type"));
      if (radix > 0) {
        this->fetchSmallint(radix, binding);
      } else {
        this->fetchNull(binding);
      }

      break;
    case 11: // NULLABLE
      this->fetchSmallint(getIsNull(record.at(L"type")), binding);
      break;
    case 17: // ORDINAL_POSITION 
      this->fetchInt(this->currentRowIndex + 1, binding);
      break;
    case 18: // IS_NULLABLE 
      this->fetchVarchar((getIsNull(record.at(L"type")) == SQL_NO_NULLS) ? L"NO" : L"YES", binding);
      break;
  }
}
Example #2
0
 void PugiElement::setName( const std::string& name )
 {
     if( getIsNull() )
     {
         return;
     }
     myNode.set_name( name.c_str() );
 }
Example #3
0
 std::string PugiElement::getValue() const
 {
     if( getIsNull() )
     {
         return std::string{};
     }
     return std::string{ myNode.text().as_string() };
 }
Example #4
0
 std::string PugiElement::getName() const
 {
     if( getIsNull() )
     {
         return "";
     }
     return std::string{ myNode.name() };
 }
Example #5
0
        XElementType PugiElement::getType() const
        {
            if( getIsNull() )
            {
                return XElementType::null;
            }

            if( std::string{ myNode.text().as_string() }.length() > 0 )
            {
                return XElementType::text;
            }

            if( elementsBegin() == elementsEnd() )
            {
                return XElementType::empty;
            }

            return XElementType::element;
        }
Example #6
0
 void PugiElement::setValue( const std::string& value )
 {
     if( getIsNull() )
     {
         return;
     }
     XElementType xetype = getType();
     
     if( xetype == XElementType::element )
     {
         MX_THROW( "the object cannot hold both elements and text" );
     }
     else if( xetype == XElementType::empty )
     {
         auto newnode = myNode.prepend_child( pugi::node_pcdata );
         newnode.set_value( value.c_str() );
     }
     else if( xetype == XElementType::text )
     {
         auto it = myNode.begin();
         it->set_value( value.c_str() );
     }
 }