cursors

Do database cursors pick up changes to the underlying data?

Quick question about cursors (in particular Oracle cursors). Let's say I have a table called "my_table" which has two columns, an ID and a name. There are millions of rows, but the name column is always the string 'test'. I then run this PL/SQL script: declare cursor cur is select t.id, t.name from my_table t order by 1; ...

cursors - %notfound is true even when row is returned

I have a cursor that is used to get some preliminary information for some other processing. It is possible that the query backing the cursor may not return any rows, and in these rare cases, we want to raise a special exception (handled and logged elsewhere so processing is not compeltely halted) so that the user knows about what is most...

Looping Over Result Sets in MySQL (Resolved: Using Cursors)

I am trying to write a stored procedure in MySQL which will perform a somewhat simple select query, and then loop over the results in order to decide whether to perform additional queries, data transformations, or discard the data altogether. Effectively, I want to implement this: $result = mysql_query("SELECT something FROM somewhere ...

C# WaitCursor while form loads

Hello all, I'm having a form that takes a few seconds to finally display. This form is called through: using (ResultsForm frm = new ResultsForm()) { this.Visible = false; frm.ShowDialog(); this.Visible = true; } It's useful that I get the default cursor to Cursors.WaitCursor while waiting for the form to finally display. ...

ORA-02014- How do I update a randomly selected row from a table?

I'm trying to randomly select a card from a table of cards with columns c_value and c_suit using a procedure. After selecting it, the procedure should update that entry's taken field to be 'Y'. create or replace procedure j_prc_sel_card(p_value OUT number, p_suit OUT number) AS CURSOR CUR_...

Deleting records using a cursor

I have limited knowledge of SQL so can someone let me know if my thoughts are correct. I have a table that slowly fills up over time. I need to delete records from the first record to a given point in the table. As the primary key is based on GUIDs I am aware that I can’t do a delete easily because I can’t sort based on GUIDs (this was d...

Java: ResultSet closing strategy, apart from closing it in finally

I am facing ORA-01000: maximum open cursors exceeded although I am closing the resultsets in finally block. But I suspect there is some trouble with my legacy code, below is my pseudo-code while (someCondition) { rs1=executePreparedStatementNew(query1,param1,""); //do something with rs1 rs1=executePreparedStatementNew(query2,param2,"")...

mysql dynamic cursor

Here is the procedure I wrote- Cursors c1 & c2. c2 is inside c1, I tried declaring c2 below c1 (outside the c1 cursor) but then I is NOT taking the updated value :( Any suggestions to make it working would be helpful, Thanks create table t1(i int); create table t2(i int, j int); insert into t1(i) values(1), (2), (3), (4), (5); inse...

Equally divide resultset into groups, with cursor or not?

I'm building a race administration system, with drivers and race heats. I need to divide, lets say, 13 drivers into groups of maximum 6 per group. It's not possible since the result will be 2.2 groups, wich is impossible, 3 groups is required. Smaller groups than 6 is allowed, so I decide to divide 13 by 3 to accomplish the follwing di...

MySQL fetch next cursor problem

Hello, I have a problem fetching values from a MySQL cursor. I create a temporary table which is a mere copy of another table (the original table has a variable name, that's passed as the procedure's parameter, and because MySQL doesn't support variable table names, I have to create a copy - can't use the original directly). The temp...

in oracle, do explicit cursors load the entire query result in memory?

I have a table with about 1 billion rows. I'm the sole user so there's no contention on locks, etc. I noticed that when I run something like this: DECLARE CURSOR cur IS SELECT col FROM table where rownum < N; BEGIN OPEN cur; LOOP dbms_output.put_line("blah") END LOOP; CLOSE cur; END; there is a lag between the time ...

How to use datastore cursors with jpa on GAE

Any body know how to use Datastore Cursors with JPA? ...

Help replace this SQL cursor with better code

Can anyone give me a hand improving the performance of this cursor logic from SQL 2000. It runs great in SQl2005 and SQL2008, but takes at least 20 minutes to run in SQL 2000. BTW, I would never choose to use a cursor, and I didn't write this code, just trying to get it to run faster. Upgrading this client to 2005/2008 is not an option i...

Sending one record from cursor to another function Postgres

FYI: I am completely new to using cursors... So I have one function that is a cursor: CREATE FUNCTION get_all_product_promos(refcursor, cursor_object_id integer) RETURNS refcursor AS ' BEGIN OPEN $1 FOR SELECT * FROM promos prom1 JOIN promo_objects ON (prom1.promo_id = promo_objects.promotion_id) ...

How can I exit an inner loop and continue an outer loop?

This is a follow-up to my previous question (Thanks for the answer, BTW!) If I have two loops: while @@fetch_status=0 begin set y=y+1 set x=0 while @@fetch_status=0 begin x=y+1 if y = 5 'exit the second do while and back to the first do while --> y=y+1 end end ...how can I exit from the...

MySQL Cursor Issue

I've got the following code - this is the first time I've really attempted using cursors. DELIMITER $$ DROP PROCEDURE IF EXISTS demo$$ DROP TABLE IF EXISTS temp$$ CREATE TEMPORARY TABLE temp( id INTEGER NOT NULL AUTO_INCREMENT, start DATETIME NOT NULL, end DATETIME NOT NULL, PRIMARY KEY(id) ) $$ CREATE PROCEDURE demo()...

Stored procedure using cursor in mySql.

I wrote a stored procedure using cursor in mysql but that procedure is taking 10 second to fetch the result while that result set have only 450 records so, I want to know that why that proedure is taking that much time to fetch tha record. procedure as below: DELIMITER // DROP PROCEDURE IF EXISTS curdemo123// CREATE PROCEDURE curdemo1...

SQL question - Cursor or not?

Hi, I have a query which returns 2+ rows. In those results is a column which we can call columnX for now. Lets look at those example results: columnX 100 86 85 70 null null I get 6 rows for example, some of them are null, some of them are not null. Now I want to go through those results and stop as soon as I find a row which is <> null...

Where to find good Windows-compatible mouse cursor images?

I"d like to find some good, basic mouse cursor graphics (like the pointing finger used when mousing over a hyperlink). Any suggestions of some good sources for that? ...

using SimpleCusorAdapter to populate a ListView for android

Hi all, I'm trying to get multiple pieces of data from an SQLite database into a ListView but it doesn't seem to be working. I'm using the code from developer.android.com's Notepad example and it works fine for 1 piece of data but not 2. I'm trying to get the title and body of each database entry from the database, through a cursor an...