ZodiacXP
Erfahrenes Mitglied
Ich habe ein NestedSet gebaut und wollte eine Prozedur zum Einfügen von Knoten machen. Leider akzeptiert mySQL meinen Code nicht, da es scheinbar keine Results in Variablen speichern kann.
Folgendes soll gemacht werden:
Der Fehler ist schon in Zeile 4: 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 '' at line 4
Selbst ohne @ mit einem DECLARE vorher geht es nicht.
Folgendes soll gemacht werden:
Code:
CREATE PROCEDURE sites_add (new_file VARCHAR(255), par_id INT)
BEGIN
SET @par_rgt = (SELECT rgt FROM sites WHERE siteid = par_id LIMIT 1);
SET @par_lft = (SELECT lft FROM sites WHERE siteid = par_id LIMIT 1);
UPDATE sites
SET lft = lft + 2
WHERE lft > @par_rgt
AND rgt >= @par_rgt;
UPDATE sites
SET rgt = rgt + 2
WHERE rgt >= @par_rgt;
INSERT INTO sites (file, parent, lft, rgt) VALUES (new_file, par_id, @par_rgt, @par_rgt+1);
END
Der Fehler ist schon in Zeile 4: 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 '' at line 4
Selbst ohne @ mit einem DECLARE vorher geht es nicht.