| 738 | } |
| 739 | |
| 740 | SQLRETURN ODBCStatement::GetData(SQLSMALLINT record_number, SQLSMALLINT c_type, |
| 741 | SQLPOINTER data_ptr, SQLLEN buffer_length, |
| 742 | SQLLEN* indicator_ptr) { |
| 743 | if (record_number == 0) { |
| 744 | throw DriverException("Bookmarks are not supported", "07009"); |
| 745 | } else if (static_cast<size_t>(record_number) > ird_->GetRecords().size()) { |
| 746 | throw DriverException("Invalid column index: " + std::to_string(record_number), |
| 747 | "07009"); |
| 748 | } |
| 749 | |
| 750 | SQLSMALLINT evaluated_c_type = c_type; |
| 751 | |
| 752 | // Get precision and scale from IRD (implementation row descriptor) as defaults. |
| 753 | // These can be overridden by ARD (application row descriptor) if specified. |
| 754 | const DescriptorRecord& ird_record = ird_->GetRecords()[record_number - 1]; |
| 755 | int precision = ird_record.precision > 0 ? ird_record.precision |
| 756 | : arrow::Decimal128Type::kMaxPrecision; |
| 757 | int scale = ird_record.scale; |
| 758 | |
| 759 | if (c_type == SQL_ARD_TYPE) { |
| 760 | if (static_cast<size_t>(record_number) > current_ard_->GetRecords().size()) { |
| 761 | throw DriverException("Invalid column index: " + std::to_string(record_number), |
| 762 | "07009"); |
| 763 | } |
| 764 | const DescriptorRecord& record = current_ard_->GetRecords()[record_number - 1]; |
| 765 | evaluated_c_type = record.concise_type; |
| 766 | precision = record.precision; |
| 767 | scale = record.scale; |
| 768 | } |
| 769 | |
| 770 | // Note: this is intentionally not an else if, since the type can be SQL_C_DEFAULT in |
| 771 | // the ARD. |
| 772 | if (evaluated_c_type == SQL_C_DEFAULT) { |
| 773 | if (static_cast<size_t>(record_number) <= current_ard_->GetRecords().size()) { |
| 774 | const DescriptorRecord& ard_record = current_ard_->GetRecords()[record_number - 1]; |
| 775 | precision = ard_record.precision; |
| 776 | scale = ard_record.scale; |
| 777 | } |
| 778 | |
| 779 | evaluated_c_type = getc_typeForSQLType(ird_record); |
| 780 | } |
| 781 | |
| 782 | return current_result_->GetData(record_number, evaluated_c_type, precision, scale, |
| 783 | data_ptr, buffer_length, indicator_ptr); |
| 784 | } |
| 785 | |
| 786 | SQLRETURN ODBCStatement::GetMoreResults() { |
| 787 | // Multiple result sets are not supported by Arrow protocol. |