void parameter::claim()

in modules/platforms/cpp/ignite/odbc/app/parameter.cpp [26:152]


void parameter::claim(binary_tuple_builder &builder, int offset, SQLULEN idx) const {
    if (m_buffer.get_input_size() == SQL_NULL_DATA) {
        builder.claim_null(); // Type.
        builder.claim_null(); // Scale.
        builder.claim_null(); // Value.
        return;
    }

    // Buffer to use to get data.
    application_data_buffer buf(m_buffer);
    buf.set_byte_offset(offset);
    buf.set_element_offset(idx);

    auto stored_data_len = static_cast<SQLLEN>(m_stored_data.size());

    if (m_buffer.is_data_at_exec()) {
        buf = application_data_buffer(
            m_buffer.get_type(), const_cast<std::byte *>(&m_stored_data[0]), stored_data_len, &stored_data_len);
    }

    switch (m_sql_type) {
        case SQL_CHAR:
        case SQL_VARCHAR:
        case SQL_LONGVARCHAR: {
            protocol::claim_type_and_scale(builder, ignite_type::STRING);
            builder.claim_varlen(buf.get_string(m_column_size));
            break;
        }

        case SQL_TINYINT: {
            protocol::claim_type_and_scale(builder, ignite_type::INT8);
            builder.claim_int8(buf.get_int8());
            break;
        }

        case SQL_SMALLINT: {
            protocol::claim_type_and_scale(builder, ignite_type::INT16);
            builder.claim_int16(buf.get_int16());
            break;
        }

        case SQL_INTEGER: {
            protocol::claim_type_and_scale(builder, ignite_type::INT32);
            builder.claim_int32(buf.get_int32());
            break;
        }

        case SQL_BIGINT: {
            protocol::claim_type_and_scale(builder, ignite_type::INT64);
            builder.claim_int64(buf.get_int64());
            break;
        }

        case SQL_FLOAT: {
            protocol::claim_type_and_scale(builder, ignite_type::FLOAT);
            builder.claim_float(buf.get_float());
            break;
        }

        case SQL_DOUBLE: {
            protocol::claim_type_and_scale(builder, ignite_type::DOUBLE);
            builder.claim_double(buf.get_double());
            break;
        }

        case SQL_BIT: {
            protocol::claim_type_and_scale(builder, ignite_type::BOOLEAN);
            builder.claim_bool(buf.get_int8() != 0);
            break;
        }

        case SQL_TYPE_DATE:
        case SQL_DATE: {
            protocol::claim_type_and_scale(builder, ignite_type::DATE);
            builder.claim_date(buf.get_date());
            break;
        }

        case SQL_TYPE_TIMESTAMP:
        case SQL_TIMESTAMP: {
            protocol::claim_type_and_scale(builder, ignite_type::DATETIME);
            builder.claim_date_time(buf.get_date_time());
            break;
        }

        case SQL_TYPE_TIME:
        case SQL_TIME: {
            protocol::claim_type_and_scale(builder, ignite_type::TIME);
            builder.claim_time(buf.get_time());
            break;
        }

        case SQL_BINARY:
        case SQL_VARBINARY:
        case SQL_LONGVARBINARY: {
            protocol::claim_type_and_scale(builder, ignite_type::BYTE_ARRAY);

            const application_data_buffer &const_buf = buf;
            const SQLLEN *res_len_ptr = const_buf.get_result_len();
            if (!res_len_ptr)
                break;

            auto param_len = static_cast<std::size_t>(*res_len_ptr);
            builder.claim_varlen({const_buf.get_data(), param_len});
            break;
        }

        case SQL_GUID: {
            protocol::claim_type_and_scale(builder, ignite_type::UUID);
            builder.claim_uuid(buf.get_uuid());

            break;
        }

        case SQL_DECIMAL: {
            big_decimal dec_value;
            buf.get_decimal(dec_value);

            protocol::claim_type_and_scale(builder, ignite_type::DECIMAL, dec_value.get_scale());
            builder.claim_number(dec_value);
            break;
        }

        default:
            break;
    }
}