Solved

I am having an error in my stored procedure saying "XML parsing error: Expected token 'eof' found ','."

Posted on 2006-06-13
5
1,760 Views
Last Modified: 2007-12-19
my stored procedure looks like the following:

ALTER       PROCEDURE spDeleteMerchant
(
      @xmlDeleteMerchant text
)
AS

DECLARE @docHandle int,
      @type tinyint -- This variable determines the kind of deletions of merchants.
                  -- '0' means set the deleted flag to 1
                  -- '1' means physically delete the merchant.
EXEC sp_xml_preparedocument @docHandle OUTPUT, @xmlDeleteMerchant
SET @type = (SELECT type FROM OPENXML(@docHandle,'Input/Data/MerchantId,1') WITH (type tinyint))      
print @type

IF @type = 0
BEGIN
      UPDATE tblMerchants  
      SET Deleted = 1 /*Deleted*/
      WHERE MerchantId  IN (SELECT value FROM OPENXML(@docHandle, 'Input/Data/MerchantId',1) WITH (value int))
      SELECT @@ROWCOUNT rowsCount
END
ELSE IF @type = 1
BEGIN
      DELETE FROM tblMerchants
      WHERE MerchantId IN (SELECT value FROM OPENXML(@docHandle, 'Input/Data/MerchantId',1) WITH (value int))
      SELECT @@ROWCOUNT rowsCount

      DELETE FROM tblMerchantBankAccount
      WHERE MerchantId IN (SELECT value FROM OPENXML(@docHandle, 'Input/Data/MerchantId',1) WITH (value int))

      DELETE FROM tblMerchantApplications
      WHERE MerchantId IN (SELECT value FROM OPENXML(@docHandle, 'Input/Data/MerchantId',1) WITH (value int))
                  
END

When I run it using the following xml string I will have an xml parser error saying "XML parsing error: Expected token 'eof' found ','."

spDeleteMerchant '<Input><Data><MerchantId value="38" type="0"/></Data></Input>' --this is sample xml string.

what went wrong?

Thank you in advance.


0
Comment
Question by:chaleastale
  • 3
  • 2
5 Comments
 
LVL 3

Accepted Solution

by:
RickBeebe earned 50 total points
ID: 16895440
Modify this line in the stored procedure:

From:
SET @type = (SELECT type FROM OPENXML(@docHandle,'Input/Data/MerchantId,1') WITH (type tinyint))  
To:
SET @type = (SELECT type FROM OPENXML(@docHandle,'Input/Data/MerchantId',1) WITH (type tinyint))  
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 16896578
Your Xml document is not well-formed it should be:
<Input><Data><MerchantId value="38" type="0"></Data></Input>

Also, don't forget to release the Xml documentation when you are through or you will eventually run out of memory:
sp_xml_removedocument @docHandle
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 16896614
Actually, please ignore my comment, not sure what I was thinking.
0
 
LVL 3

Expert Comment

by:RickBeebe
ID: 16896852
I would agree with adding this statement to the end of your procedure:

sp_xml_removedocument @docHandle
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 16899126
>>I would agree with adding this statement to the end of your procedure<<
Right.  That was the only part that made sense :)
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

I guess that all of us know that caching the data usually increase the performance, but I worried if all of us are aware about the risk that caching the data provides and how to minimize this.  That’s the reason why I decided to write this short art…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now