Hi all,
Ik heb een probleem binnen een mysql stored procedure. (zie hieronder)
Als ik de 'IF EXISTS' weghaal bij DROP TEMPORARY TABLE IF EXISTS tmp_arrivaldates; dan maakt de procedure zich goed aan. Zoals hieronder krijg ik de fout
[Err] 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DELIMITER' at line 38
Hopelijk kunnen jullie mij helpen want Google wist het antwoord niet
Ik heb een probleem binnen een mysql stored procedure. (zie hieronder)
Als ik de 'IF EXISTS' weghaal bij DROP TEMPORARY TABLE IF EXISTS tmp_arrivaldates; dan maakt de procedure zich goed aan. Zoals hieronder krijg ik de fout
[Err] 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DELIMITER' at line 38
Hopelijk kunnen jullie mij helpen want Google wist het antwoord niet
SQL:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
| DROP PROCEDURE IF EXISTS ProGetArrivalDates; DELIMITER $$ CREATE PROCEDURE ProGetArrivalDates() BEGIN DECLARE lastSync DATE; #date of last successfull sync with @leisure DECLARE currAvailString TEXT; DECLARE charToCheck CHAR(1); DECLARE currDate DATE; DECLARE cur1 CURSOR FOR SELECT AvailString FROM jsonrpc.avail_by_night LIMIT 0,10; #cursor to loop through the resultset SELECT last_sync INTO lastSync FROM jsonrpc.last_sync WHERE id=1; #load last successfull sync date and store it in lastSync DROP TEMPORARY TABLE IF EXISTS tmp_arrivaldates; CREATE TEMPORARY TABLE tmp_arrivaldates (ad DATE); OPEN cur1; read_loop: LOOP #loop through resultset SET currDate = lastSync; FETCH cur1 INTO currAvailString;#save availstring from result into variable to work with WHILE LENGTH(currAvailString) > 0 DO SET charToCheck = LEFT(currAvailString,1); IF charToCheck BETWEEN 2 AND 3 THEN INSERT INTO tmp_arrivaldates(ad) VALUES (currDate); END IF; SET currAvailString = substr(currAvailString,2); #cut of selected char SET currDate = DATE_ADD(currDate, INTERVAL 1 DAY); END WHILE; END LOOP; CLOSE cur1; SELECT * FROM tmp_arrivaldates; END$$ DELIMITER ; |
[ Voor 0% gewijzigd door RobIII op 05-10-2010 19:02 . Reden: Code tags toegevoegd ]