Re: need cursor info
RedGrittyBrick wrote:
gk wrote:
Hi,
i need some info on cursor.
cursor == current set of records ....right ?
No. Wrong.
ok , i found this text here
http://webopedia.com/TERM/c/cursor.html
it says ,cursor definition "......In some database languages, short for
current set of records, the currently selected set of records........"
so, it holds set of records ....
No it doesn't.
how many records it can hold ?
A cursor isn't really a place where records are held.
i have seen these examples
http://javaalmanac.com/egs/java.sql/MoveCursor.html
http://javaalmanac.com/egs/java.sql/GetCursorPosition.html
But, i have not got the answers of my questions.
here are the questions .
How i can set , how many record a cursor can hold ?
You can't because it doesn't.
How do i retrive those records ?
By using ResultSet.next() and ResultSet.getXXX() on your ResultSet instance;
ok. but these are as simple as extracting values from a ResultSet
......here is no cursor involved .
suppose, i have for loop and i want to get the next set of records ,
should i move the cursor by 1 place ?
Only if the set is of size 1.
why i should use the cursor ?
Because it has great utility.
great utility ?
does it improve in any case ?
I wonder what you mean? I suspect the answer is "yes", but the question
is unfathomable.
i have searched the net ....not found any answers / references where i
could find the answers of my questions.
Your Google-fu is too weak! Exercise it more!
If anybody can answer these questions or provide me some
resources/links where i could get the answers of these questions...
http://en.wikipedia.org/wiki/Cursor_%28databases%29
oh...ok, i see the wikipedia says ,
"..a cursor can be thought of as an iterator over the collection of
rows in the result set...."
well, but what will i get out of it ?
i can do the same thing like this (without a cursor)
while (rs.next()) {
// Get the data from the row using the column index
String s = rs.getString(1);
// Get the data from the row using the column name
s = rs.getString("col_string");
}
this is also iterating the resultset without a cursor ...right ? so,
why do i use cursor then ?
what benefit cursor will give ?
Yea, do you want to tell , cursor can go backwards in the resultset ? i
am not sure ....or this is a benefit i'll will get from a cursor .
please explain , why and when one should use cursor ?
http://java.sun.com/docs/books/tutorial/jdbc/basics/index.html
i'll appreciate
Will you? I'll wait ...
thank you for your response