August 27, 2004 at 8:11 am
Hopefully this is something simple that I am overlooking....
I am working on an SP to handle data sorting. One of the processes requires me to loop through a set of records which I do using a cursor. For each record I need to go to another table to grab a couple of data values to use. It is this second select that is causing me problems. I want to retrieve two values from the ITEMMAST table and put them in locally defined variables but I cannot seem to get the syntax right. Here is what I have. The code in red is the problem area:
DECLARE @item_no char (20), @edpno numeric, @item_customization_code char(2)
DECLARE mkfile1_cursor CURSOR
FOR SELECT EDPNO FROM mkfile1
ORDER BY SUBSTRING(DIVISION,1,1),
FULLORDERNO,
ZONECOMBO,
WAREHOUSELOC
FOR UPDATE OF MISCDATA50
OPEN mkfile1_cursor
FETCH NEXT FROM mkfile1_cursor INTO @edpno
-- Check @@FETCH_STATUS to see if there are any more rows to fetch.
WHILE @@FETCH_STATUS = 0
BEGIN
--read ITEMMAST table
SELECT ITEMNO, SUBSTRING(FLAGS,1,2) INTO :item_no, :item_customization_code
FROM dbo.ITEMMAST
WHERE EDPNO = @edpno
FETCH NEXT FROM mkfile1_cursor INTO @edpno
END
CLOSE mkfile1_cursor
DEALLOCATE mkefile1_cursor
I have tried a couple of different ways with this but still get syntax errors. How do I code this to be able to use @item_no and @item_customization_code after the select is complete?
All advise/input is appreciated! Thanks in advance!!!!!
~mj
August 27, 2004 at 8:19 am
From a syntax point of view try:
SELECT @item_no= ITEMNO, @item_customization_code =SUBSTRING(FLAGS,1,2)
FROM dbo.msg_queue
WHERE EDPNO = @edpno
Francis
August 27, 2004 at 8:36 am
Thank you. That seems to have done the trick as far as passing the syntax checks.
I appreciate it!
-mlj
~mj
Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply