The issue is that when you bind the result you are actually binding a
pointer to a contiguous buffer, not a C++ object.
So actually it's &vec[0] that is being bound. If a vector is resized upward
then &vec[0] would change
and the pointers would no longer be valid.
Once the results are read in the vectors can be resized down for you just
to inform you how many were actually returned.
The fact that you get fewer results than your buffer size doesn't mean
there aren't more results, just that there are no
more results ready at present. Remember the database doesn't necessarily
return all its results at once. Therefore
you can resize your vectors at this point but when a vector does a resize
down it doesn't reduce the capacity therefore
if you resize it back up again the pointers won't actually change. The size
is a logical size, i.e. indicates the number of
rows populated.
Note that a vector must be resized even to write into the memory directly.
You can't rely on reserve.
On Thu, Feb 16, 2012 at 8:03 AM, Simon Walter <[email protected]> wrote:
> Hi all,
>
> I'm sure this is a very common question. I've read the docs and I
> understand that I cannot use an empty vector to store results in:
>
> "Use of the vector based types mirrors that of the standard types, with
> the size of the vector used to specify the number of records to process
> at a time."
>
> and
>
> "The above example retrieves first 100 rows of data (or less). The
> initial size of names vector provides the (maximum) number of rows that
> should be read. Both vectors will be automatically resized according to
> the number of rows that were actually read."
>
> Can someone point me to some docs or give an example of how I can
> retrieve a result set of an unknown size?
>
> Thanks,
>
> Simon
>
>
> ------------------------------------------------------------------------------
> Virtualization & Cloud Management Using Capacity Planning
> Cloud computing makes use of virtualization - but cloud computing
> also focuses on allowing computing to be delivered as a service.
> http://www.accelacomm.com/jaw/sfnl/114/51521223/
> _______________________________________________
> Soci-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/soci-users
>
------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
Soci-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/soci-users