Hi,
You can use statement to iterate over all rows (see
http://soci.sourceforge.net/doc/3.2/statements.html):
int main()
{
session sql(firebird, "service=D:/New_DB.FDB user=SYSDBA
password=masterkey");
row r;
std::string m_name;
double ystr;
soci::statement stmt = (sql.prepare << "select * from materials",
into(r));
stmt.execute(false); // false to not fetch any data until loop
while(stmt.fetch())
{
r >> m_name >> ystr >> ystr;
cout << "Hello world!" << endl;
}
return 0;
}
Or, without soci::row
int main()
{
session sql(firebird, "service=D:/New_DB.FDB user=SYSDBA
password=masterkey");
std::string m_name;
double ystr;
soci::statement stmt = (sql.prepare << "select * from materials",
into(m_name), into(ystr), into(ystr));
stmt.execute(false); // false to not fetch any data until loop
while(stmt.fetch())
{
std::cout << "m_name: " << m_name << "; ystr = " << ystr <<
std::endl;
}
return 0;
}
Arnaud
On 12/07/2015 09:08, Sonya Blade wrote:
Hi All,
I'd like to know how one is supposeed to iterate through rows of
resulting database. For example if I have
following code the resulting dataset is returned into r (row)
variable, but I don't know how iterate through it.
Any help will be appreicated,
Regards,
int main()
{
session sql(firebird, "service=D:/New_DB.FDB user=SYSDBA
password=masterkey");
row r;
sql << "select * from materials", into(r);
std::string m_name;
double ystr;
r >> m_name >> ystr >> ystr;
cout << "Hello world!" << endl;
return 0;
}
------------------------------------------------------------------------------
Don't Limit Your Business. Reach for the Cloud.
GigeNET's Cloud Solutions provide you with the tools and support that
you need to offload your IT needs and focus on growing your business.
Configured For All Businesses. Start Your Cloud Today.
https://www.gigenetcloud.com/
_______________________________________________
soci-devel mailing list
soci-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/soci-devel
------------------------------------------------------------------------------
Don't Limit Your Business. Reach for the Cloud.
GigeNET's Cloud Solutions provide you with the tools and support that
you need to offload your IT needs and focus on growing your business.
Configured For All Businesses. Start Your Cloud Today.
https://www.gigenetcloud.com/
_______________________________________________
soci-devel mailing list
soci-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/soci-devel