If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > mysql procedure bad answer

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-16-12, 02:00
Brigita Brigita is offline
Registered User
 
Join Date: Feb 2012
Posts: 1
mysql procedure bad answer

Hi,

I have a problem with Mysql query browser.
I have :

DELIMITER $$
DROP PROCEDURE IF EXISTS `TESTO` $$
CREATE PROCEDURE `TESTO`()
BEGIN
DECLARE i INT DEFAULT 0;
DECLARE KIEKIS INT DEFAULT 0;
SET KIEKIS=(SELECT COUNT(KODAS) FROM ISSS_SR I);
WHILE i<1 DO
PREPARE uzklausa FROM 'SELECT KODAS, RF FROM ISSS_SR LIMIT ?, 1 into @KODAS_1, @FORMULE';
SET @a = i;
EXECUTE uzklausa using @a;
PREPARE uzklausa3 FROM 'UPDATE ISSS_SR SET SR=@FORMULE WHERE KODAS=@KODAS_1';
EXECUTE uzklausa3;
SET i=i+1;
DEALLOCATE PREPARE uzklausa;
DEALLOCATE PREPARE uzklausa3;
END WHILE;
END $$
DELIMITER ;

Calculates the "SR" where "@FORMULE":
SELECT(SELECT
SUM(SR) FROM ISSS_ATASKAITA
WHERE DUOM_TIPAS=2 AND STRAIPSNIS = 292 AND SEKTORIUS= 'S1312' AND PRIEMONE='F7') + (SELECT
SUM(SR) FROM ISSS_ATASKAITA_F06
WHERE DUOM_TIPAS=2 AND STRAIPSNIS = 3040 AND SEKTORIUS= 'S1314' AND PRIEMONE='F99')

Every code is different from the query. Now, with a request for me to "SR" column, not "@ FORMULA" answer, but just the same formulas.
Do you have any tips on how to do that I first counted and then recorded in response to SR.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On