Mysql tutorial, mysql tutorial, mysql and java tutorial, using mysql, mysql lessons, mysql,mysql tips,mysql cheat sheet!
Sycorax - complete tutorials
Programming Tutorials
" Java provides the industry - software companies and customer alike , an opportunity to create a true open computing environment where software is portable,
and customers benefit from increase competition. "
Java and the Future
December 1, 2008-LEJB 3.1: EJB New and Improved!
The EJB 3.0 specification was a huge improvement from what you were used to in the early versions of EJB. Available as an early draft, EJB 3.1 has many more features and is even easier to use.
December 1, 2008-Should Java Assert that Network I/O Can't Occur on the UI Thread?
Doing network I/O on the user interface (UI) thread is bad. Most developers know that and can tell you why; unfortunately, it's still done.
Register now to recieve special alert and latest technology news!
Cursors
Cursors are supported inside stored procedures and functions and triggers. The syntax is as in embedded SQL. Cursors are currently asensitive, read-only, and non-scrolling. Asensitive means that the server may or may not make a copy of its result table.
Cursors must be declared before declaring handlers, and variables and conditions must be declared before declaring either cursors or handlers.
Example:
CREATE PROCEDURE curdemo()
BEGIN
DECLARE done INT DEFAULT 0;
DECLARE a CHAR(16);
DECLARE b,c INT;
DECLARE cur1 CURSOR FOR SELECT id,data FROM test.t1;
DECLARE cur2 CURSOR FOR SELECT i FROM test.t2;
DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET done = 1;
OPEN cur1;
OPEN cur2;
REPEAT
FETCH cur1 INTO a, b;
FETCH cur2 INTO c;
IF NOT done THEN
IF b < c THEN
INSERT INTO test.t3 VALUES (a,b);
ELSE
INSERT INTO test.t3 VALUES (a,c);
END IF;
END IF;
UNTIL done END REPEAT;
CLOSE cur1;
CLOSE cur2;
END
Declaring Cursors
DECLARE cursor_name CURSOR FOR select_statement
This statement declares a cursor. Multiple cursors may be declared in a routine, but each cursor in a given block must have a unique name.
The SELECT statement cannot have an INTO clause.
Cursor OPEN Statement
OPEN cursor_name
This statement opens a previously declared cursor.
Cursor FETCH Statement
FETCH cursor_name INTO var_name [, var_name] ...
This statement fetches the next row (if a row exists) using the specified open cursor, and advances the cursor pointer.
Cursor CLOSE Statement
CLOSE cursor_name
This statement closes a previously opened cursor.

