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;
...
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...
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 ...
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. ...
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_...
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...
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,"")...
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...
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...
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...
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 ...
Any body know how to use Datastore Cursors with JPA?
...
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...
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)
...
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...
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()...
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...
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...
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?
...
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...