Home » U++ Library support » U++ SQL » Handling multiple rows data in sqlite3
Handling multiple rows data in sqlite3 [message #12783] |
Fri, 16 November 2007 03:53 |
fuqr
Messages: 16 Registered: July 2007 Location: Singapore
|
Promising Member |
|
|
Dear UPP experts,
I'm quite new for UPP. I have got very useful references from "HomeBudget" about sqlite3 application. One of my question is:
when I use the code below, data of multiple rows can be passed to GridCtrl:
" SQL & ::Select(NAME, TOTAL).From(GROUPS).Where(GT_ID == dtid);
while(SQL.Fetch()) mostpr.Add(SQL); "
But my following code handles first row only when I try to update value of last column using data from other columns in the same row/line and the previous rows/lines:
====================================================
double vsi21=1, bi=1, bi2=1, mbi2;
SQL & ::Select(CAT_ID,S21,S22).From(CATEGORIES)
.Where(CS_ID == cid && GR_ID == gid);
while(SQL.Fetch())
{
double vs22 = SQL[S22];
double vs21 = SQL[S21];
int k = SQL[0];
bi2 = bi*vsi21;
mbi2 = bi2*bi2*vs22*gammer*dbfactor;
mbi2 = mbi2*mbi2;
bi = bi2;
vsi21 = vs21;
SQL & ::Update(CATEGORIES)(MBI, mbi2)
.Where(CS_ID == cid && GR_ID == gid && CAT_ID == k);
}
================================
If any mistakes in my code or any other simple way to handle it?
I failed to found any detail manuals in UPP especially for GridCtrl & sql database:).
Thanks in advance for your help.
Qinrong
|
|
|
Re: Handling multiple rows data in sqlite3 [message #12784 is a reply to message #12783] |
Fri, 16 November 2007 08:29 |
|
You can't use SQL object inside outer SQL.Fetch(). Transform your code to:
double vsi21=1, bi=1, bi2=1, mbi2;
SQL & ::Select(CAT_ID,S21,S22).From(CATEGORIES)
.Where(CS_ID == cid && GR_ID == gid);
Sql q_upd(::Update(CATEGORIES)(MBI, SqlArg())
.Where(CS_ID == cid && GR_ID == gid && CAT_ID == SqlArg()),
SQL.GetSession());
while(SQL.Fetch())
{
double vs22 = SQL[S22];
double vs21 = SQL[S21];
int k = SQL[0];
bi2 = bi*vsi21;
mbi2 = bi2*bi2*vs22*gammer*dbfactor;
mbi2 = mbi2*mbi2;
bi = bi2;
vsi21 = vs21;
q_upd.Run(mbi2, k);
}
|
|
|
Re: Handling multiple rows data in sqlite3 [message #12817 is a reply to message #12784] |
Mon, 19 November 2007 08:44 |
fuqr
Messages: 16 Registered: July 2007 Location: Singapore
|
Promising Member |
|
|
Dear Uno,
Thanks very much for your prompt help!
It's what I want. Where I can find some UPP/SQL programmer manuals for self-learning?
B.T.W. Can I have another question:
After completion of my GUI programming, is't possible to export the whole package then merging it together with my main C++ program in MS Visual Studion .NET 2003 platform and independently compiling all of project code only on C++ platform?
Best Regards,
Qinrong
|
|
|
Goto Forum:
Current Time: Mon Apr 29 00:30:01 CEST 2024
Total time taken to generate the page: 0.04010 seconds
|