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,826 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When table data gets too large to manage or queries take too long to execute the solution is often to buy bigger hardware or assign more CPUs and memory resources to the machine to solve the problem. However, the best, cheapest and most effective so…
When it comes to protecting Oracle Database servers and systems, there are a ton of myths out there. Here are the most common.
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…

734 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