Friday, 15 June 2012

sql - MySQL Stored Procedure INSERT issue -



sql - MySQL Stored Procedure INSERT issue -

so next scenario applies:

...

create temporary table if not exists `smth_table` ( `login` varchar(20), `password` varchar(20), `type` int(11), `account_state` decimal(12,4) ); prepare selection "insert `smth_table` (select ta.`login`, ta.`password`, ta.`type`, ta.`account_state` tablea ta inner bring together tableb tb on tb.id_client = ta.id_client tb.id_lot = ? , ta.`type` mod 2 = 0 , ta.first_use = '0000-00-00 00:00:00' , ta.account_state = 0 limit ?)"; set @where = var1; set @limit = var2; execute selection using @where, @limit; deallocate prepare selection; declare curs cursor select `password` `smth_table`; declare go on handler not found set v_finished = 1; open pin_curs; get_pass: loop fetch curs pass; if v_finished = 1 leave get_pass; end if; update tablea ta inner bring together tableb tb on tb.id_client = ta.id_client set `type` = `type` | 1, `account_state` = `account_state` + 5 tb.id_lot = var1 , `password` = pass; end loop get_pass; close curs; end

my question is: why, when run stored procedure, temp table populates more limit? maintain in mind set limit in variable passed trough procedure... , it's 10, btw... when run procedure inserts in temp table more 100 rows... , don't understand why... when should insert 10...

can help?

solved!

the issue relayed on fact not deleting table upon creating again, inserting same values on , on again...

drop table if exists `smth_table`;

this inserted before creating , query's run smooth :-)

hope helps others too! luck, ares.

mysql sql sql-server stored-procedures

No comments:

Post a Comment