Click here to Skip to main content
15,896,912 members
Home / Discussions / Database
   

Database

 
GeneralRe: MySQL syntax error.. Please help... Pin
GuyThiebaut2-Sep-13 23:16
professionalGuyThiebaut2-Sep-13 23:16 
GeneralRe: MySQL syntax error.. Please help... Pin
Jassim Rahma2-Sep-13 23:19
Jassim Rahma2-Sep-13 23:19 
GeneralRe: MySQL syntax error.. Please help... Pin
GuyThiebaut2-Sep-13 23:32
professionalGuyThiebaut2-Sep-13 23:32 
GeneralRe: MySQL syntax error.. Please help... Pin
Jassim Rahma2-Sep-13 23:56
Jassim Rahma2-Sep-13 23:56 
GeneralRe: MySQL syntax error.. Please help... Pin
Jassim Rahma3-Sep-13 0:22
Jassim Rahma3-Sep-13 0:22 
GeneralRe: MySQL syntax error.. Please help... Pin
Jassim Rahma3-Sep-13 1:43
Jassim Rahma3-Sep-13 1:43 
QuestionPL/Mysql - can't run procedure with sql security invoker Pin
noislude1-Sep-13 15:59
noislude1-Sep-13 15:59 
QuestionPL/MySQL - can't load file Pin
noislude1-Sep-13 4:22
noislude1-Sep-13 4:22 
QuestionCan't create table - SQL 2008 R2 Pin
ThetaClear1-Sep-13 3:15
ThetaClear1-Sep-13 3:15 
AnswerRe: Can't create table - SQL 2008 R2 Pin
PIEBALDconsult1-Sep-13 3:35
mvePIEBALDconsult1-Sep-13 3:35 
GeneralRe: Can't create table - SQL 2008 R2 Pin
ThetaClear1-Sep-13 3:40
ThetaClear1-Sep-13 3:40 
GeneralRe: Can't create table - SQL 2008 R2 Pin
PIEBALDconsult1-Sep-13 3:53
mvePIEBALDconsult1-Sep-13 3:53 
GeneralRe: Can't create table - SQL 2008 R2 Pin
ThetaClear1-Sep-13 3:57
ThetaClear1-Sep-13 3:57 
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 

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.