Posted: Tue May 17, 2005 12:53 pm Post subject: error referencing in procedure
Novice
Joined: 03 Sep 2004 Posts: 13
I have the following WMQI v5 code that is giving me a syntax error in the toolkit. I have to believe it is because I am doing something that is not valid as opposed to just missing a character somewhere. Maybe not. The cursor error is shown on line 5 after "trgt". I am not able to create the BAR file until I clear this error.
CREATE PROCEDURE SetIndex(IN trgt REFERENCE) BEGIN
DECLARE i,indexnum INT;
SET i = 1;
WHILE i <= 3 DO
SET trgt[i].SECTION_X = i;
SET i = i + 1;
END WHILE;
END;
The xml tree that it might populate could look like this before executing the procedure:
I am looking for suggestions about either how to correct what I have started or suggestions about a better way to build it. Please understand that the actual message tree is more complex and much larger.
AFAIK, you just can't use reference to a list, it is always one field under a reference - you will have to pass your array's parent to your function and than use myref.dept[i] in your loop, or try to use MOVE NEXTSIBLING and check the LASTMOVE and FIELDNAME. Somthing like:
Code:
CREATE PROCEDURE SetIndex(IN trgt REFERENCE) BEGIN
DECLARE i,indexnum INT;
SET i = 1;
DECLARE list_name CHAR FIELDNAME(trgt);
WHILE i <= 3 AND LASTMOVE(trgt) DO
SET trgt.SECTION_X = i;
REPEAT
MOVE trgt NEXTSIBLING;
UNTIL (FIELDNAME(trgt) = list_name) OR (LASTMOVE(trgt) = FALSE)
END REPEAT;
SET i = i + 1;
END WHILE;
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum