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