MySQL Forums
Forum List  »  Connector/C++

Re: Getting query results as strings
Posted by: James Cooper
Date: April 19, 2023 01:31PM

It looks like the only solution is to get the type of each column and convert it to a string using either an if or switch statement like this:


string s1 = columns[index].getColumnName();
string sval = "";
int itype = row[index].getType();
if (itype == row[index].FLOAT) {
float val = float(row[index]);
sval = std::to_string(val);
}
if (itype == row[index].INT64) {
int val = int(row[index]);
sval = std::to_string(val);
}
if (itype == row[index].STRING) {
string val = string(row[index]);
sval = val;
}

Options: ReplyQuote


Subject
Views
Written By
Posted
582
April 19, 2023 07:28AM
Re: Getting query results as strings
145
April 19, 2023 01:31PM


This forum is currently read only. You can not log in or make any changes. This is a temporary situation.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.