[SQL] Client and server cursors // cool C++
Ruslan Zasukhin
sunshine at public.kherson.ua
Wed Mar 5 11:15:33 CST 2003
on 3/5/03 3:49 AM, Andreas Grosam at agrosam at computerworks.ch wrote:
>> Now if you want do modifications of records you can do simply:
>>
>> curs.Stringfield( "name" ) = 'something new'
>> curs.Update(); <<<<<<<< this send command to server.
>>
>> >> What you think about this approach ?
>> >> Anybody see any potential problems with this ?
>> **>> I do not remember if any other db use this way? IT seems I have see
>> always generation of new SQL command in background...
>
> This is all ok. I like it.
> JDBC defines this, too (similar).
>
> One usefull addition would be such a construct:
> Notice, that a cursor only have ONE current record. So, if you want
> simultaneously access two values from a certain column from different rows -
> or if you want access the record as a whole - you might find this usefull:
>
> class Cursor; // the valentina cursor
>
> Cursor c = /*...*/; // create and open the cursor.
>
> c.pos(1); // position the the first record
>
> Cursor::RowValue row1 = c.value(); // create and initialize a "RowValue" from
> current record
> Cursor::RowValue row2 = c[2]; // position to pos 2, then assign row2 the
> values of the
> // current record
>
> // note, that row1 now contains a copy of the record at position 1, and row2
> contains
> // a copy of the record at position 2.
>
> if (row1 == row2)
> cout << " Heureka, they are the same!" << endl;
>
> cout << row1[1]; // print out the first column.
> cout << row1["name"]; // print out column with name "name".
> row2["name"] = "Ruslan"; // assign the first column of variable row2 a value
>
> c[1] = row1; // position the cursor to pos 1, then copy the
> // values of row1 into the cursor buffer
> c.Update(); // now upadte record at position 1
>
>
> // Store the row values -just for fun - or for later retrival:
> typedef std::map<Cursor::pos_type, Cursor::RowValue> Result;
> Result r;
> r.insert(Result::value_type(1, row1));
> r.insert(Result::value_type(2, row2));
>
> or in a vector:
>
> std::vector<Cursor::RowValue> v;
> v.push_back(row1);
> cout << v[0]["name"] << endl;
>
>
> This is what I have already implemented for another "high level" cursor. It
> can be simply incorporated into the valentina cursor, though. Some details
> ommitted. For C++ only.
> You may wonder what the RowValue is? - source can be made available if it is
> considered to be usefull.
>
> What do you think?
Well, just excellent ideas Andreas.
And once again, I want repeat.
* For 2.0 the Valentina C++ SDK will change API.
Andreas, it seems I already have sent you some draft.
* kernel will have Interfaces for access.
they will be as reach as possible.
* Now around this interfaces we can build SEVERAL different MAPs.
-- template classes that provide current VDK functionality
-- Helper classes like you show now
-- helpers that integrate into STL API.
And so on ...
--
Best regards,
Ruslan Zasukhin [ I feel the need...the need for speed ]
-------------------------------------------------------------
e-mail: ruslan at paradigmasoft.com
web: http://www.paradigmasoft.com
To subscribe to the Valentina mail list go to:
http://listserv.macserve.net/mailman/listinfo/valentina
-------------------------------------------------------------
More information about the Valentina
mailing list