I need to check if two cursors pointing at the same rows with the same values. Is it possible?
More details:
ContentProvider
ContentProvider
with new values.Below is my code: CREATE OR REPLACE PROCEDURE CHECK_STUDENT AS CURSOR SCHOOL_REG IS SELECT STUDENT_ID FROM SCHOOL WHERE CLASSROOM IN (1,2,3,4,5); CURSOR CLASS_REG IS SELECT STUDENT_ID, STUDENT_NAME FROM REGISTER WHERE CLASSROOM = 1; FOR X IN CLASS_REG LOOP IF X. STUDENT_ID <> SCHOOL_REG. STUDENT_ID THEN DBMS_OUTPUT.
The trick to declaring a cursor within a cursor is that you need to continue to open and close the second cursor each time a new record is retrieved from the first cursor. That way, the second cursor will use the new variable values from the first cursor.
Can cursor operate multiple rows? The multiple-row FETCH statement can be used with both serial and scrollable cursors. The operations used to define, open, and close a cursor for a multiple-row FETCH remain the same.
As per CommonsWare's deleted answer:
Iterate over the relevant columns in the Cursor, retrieve the values, and compare each.
Although you may not know in advance the type of each column, you can find out with Cursor.getType()
. You can also use Cursor.getColumnNames()
to get the name of each column, and the number of columns.
This information will allow you to then use the correct accessor method to obtain each value and compare.
In SQLite, rows do not have an identity separate from their column values (but the ROWID
is one of these values).
What you want requires that your data has some unique column(s) as part of the cursor, either the ROWID
, or some other key value that is guaranteed to have no duplicates.
Otherwise, you can never know if what you see is just two records that happen to have the same values in those columns.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With