For basic data types I have no problems parsing data using a format like:
if (FALSE == PQgetisnull(res, rowNumber, columnIndex))
{
retVal.m_assignedSocket = atol(PQgetvalue(res, rowNumber, columnIndex));
} else
{
retVal.m_assignedSocket = 0;
}
I would like to have an array field in one of my tables that is an array of bigints. I believe I can insert the data like this:
// array elements are separated by curly braces
insertQuery += "{";
for (size_t i = 0; i < settings.m_stepVector.size(); i++)
{
if (snprintf(buffer, sizeof(buffer), ", %llu", settings.m_stepVector[i]) > (int) sizeof(buffer))
{
LOG_SYSTEM_WARNING("Unexpected string truncation\n");
}
insertQuery += buffer;
}
insertQuery += "}";
The problem comes with parsing the row. I have not found any examples or documentation stating the format of the returned array column. My assumption is that it is a string with curly braces on each end. What is the format between the curly braces? It doesn't seem like this is something new but I cannot find an answer anywhere. Could be I don't know the right keywords to search under. I tried postgresql, array, PQgetvalue, and parsing.