Click here to Skip to main content
15,887,453 members
Home / Discussions / Database
   

Database

 
GeneralRe: Can't create table - SQL 2008 R2 Pin
PIEBALDconsult1-Sep-13 4:06
mvePIEBALDconsult1-Sep-13 4:06 
GeneralRe: Can't create table - SQL 2008 R2 Pin
ThetaClear1-Sep-13 6:30
ThetaClear1-Sep-13 6:30 
GeneralRe: Can't create table - SQL 2008 R2 Pin
PIEBALDconsult1-Sep-13 6:37
mvePIEBALDconsult1-Sep-13 6:37 
GeneralRe: Can't create table - SQL 2008 R2 Pin
ThetaClear1-Sep-13 8:19
ThetaClear1-Sep-13 8:19 
GeneralRe: Can't create table - SQL 2008 R2 Pin
PIEBALDconsult1-Sep-13 8:25
mvePIEBALDconsult1-Sep-13 8:25 
GeneralRe: Can't create table - SQL 2008 R2 Pin
ThetaClear1-Sep-13 8:47
ThetaClear1-Sep-13 8:47 
GeneralRe: Can't create table - SQL 2008 R2 Pin
PIEBALDconsult2-Sep-13 17:47
mvePIEBALDconsult2-Sep-13 17:47 
Question[SOLVED] PL/MySQL - Duplicated last row Pin
noislude29-Aug-13 3:58
noislude29-Aug-13 3:58 
edit

I found the source of the problem. I forgot to close the cursor;

Hello. My second SP is printing the last row twice and I don't know what to do about it. The second one is calling the first.

SQL
delimiter //
drop procedure if exists sp_overdue_sales //
create procedure sp_overdue_sales()
begin
  drop temporary table if exists overdue_sales_tmp;
  create temporary table overdue_sales_tmp as select
  sales_id, customer_id, sale_date, quantity, sale_value
  from sales where sale_status = 'A' limit 10;
end;
//


SQL
delimiter //
drop procedure if exists sp_issue_invoice //
create procedure sp_issue_invoice()
begin
  declare var_sales_id int;
  declare last_sale int default 0;

  declare sales_csr cursor for
  select sales_id from overdue_sales_tmp;

  declare continue handler for not found set last_sale = 1;
  open sales_csr;
  sales_repeat: repeat
     if last_sale then
        leave sales_repeat;
     end if;
     fetch sales_csr into var_sales_id;
     select var_sales_id;
  until last_sale end repeat;
end;
//


| var_sales_id |
+--------------+
|           10 |
+--------------+
1 row in set (0.00 sec)

+--------------+
| var_sales_id |
+--------------+
|           10 |
+--------------+
1 row in set (0.00 sec)

Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> show warnings;
+-------+------+-----------------------------------------------------+
| Level | Code | Message                                             |
+-------+------+-----------------------------------------------------+
| Error | 1329 | No data - zero rows fetched, selected, or processed |
+-------+------+-----------------------------------------------------+


modified 29-Aug-13 11:38am.

QuestionHelp Me Pin
Kailashkumar Raghvani28-Aug-13 21:57
Kailashkumar Raghvani28-Aug-13 21:57 
AnswerRe: Help Me Pin
Ingo28-Aug-13 22:30
Ingo28-Aug-13 22:30 
AnswerRe: Help Me Pin
Simon_Whale29-Aug-13 0:13
Simon_Whale29-Aug-13 0:13 
AnswerRe: Help Me Pin
Amol_B11-Oct-13 0:26
professionalAmol_B11-Oct-13 0:26 
Questiondatabase connectivity issue Pin
knaivekiller26-Aug-13 21:21
knaivekiller26-Aug-13 21:21 
AnswerRe: database connectivity issue Pin
Jörgen Andersson26-Aug-13 21:32
professionalJörgen Andersson26-Aug-13 21:32 
Questionselecting maximum entry from sql server compact column Pin
paul4everyone24-Aug-13 0:02
paul4everyone24-Aug-13 0:02 
AnswerRe: selecting maximum entry from sql server compact column Pin
Tim Carmichael24-Aug-13 2:14
Tim Carmichael24-Aug-13 2:14 
GeneralRe: selecting maximum entry from sql server compact column Pin
paul4everyone24-Aug-13 2:43
paul4everyone24-Aug-13 2:43 
AnswerRe: selecting maximum entry from sql server compact column Pin
paul4everyone24-Aug-13 2:38
paul4everyone24-Aug-13 2:38 
AnswerRe: selecting maximum entry from sql server compact column Pin
Eddy Vluggen24-Aug-13 2:43
professionalEddy Vluggen24-Aug-13 2:43 
AnswerRe: selecting maximum entry from sql server compact column Pin
paul4everyone24-Aug-13 2:47
paul4everyone24-Aug-13 2:47 
GeneralRe: selecting maximum entry from sql server compact column Pin
Mycroft Holmes24-Aug-13 13:31
professionalMycroft Holmes24-Aug-13 13:31 
GeneralRe: selecting maximum entry from sql server compact column Pin
Jörgen Andersson26-Aug-13 21:30
professionalJörgen Andersson26-Aug-13 21:30 
AnswerRe: selecting maximum entry from sql server compact column Pin
paul4everyone25-Aug-13 4:19
paul4everyone25-Aug-13 4:19 
GeneralRe: selecting maximum entry from sql server compact column Pin
Mycroft Holmes25-Aug-13 12:40
professionalMycroft Holmes25-Aug-13 12:40 
QuestionPL/MySQL - No data - zero rows fetched, selected, or processed Pin
noislude22-Aug-13 5:22
noislude22-Aug-13 5:22 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.