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,862 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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

This article shows the steps required to install WordPress on Azure. Web Apps, Mobile Apps, API Apps, or Functions, in Azure all these run in an App Service plan. WordPress is no exception and requires an App Service Plan and Database to install
Recently I was talking with Tim Sharp, one of my colleagues from our Technical Account Manager team about MongoDB’s scalability. While doing some quick training with some of the Percona team, Tim brought something to my attention...
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…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…

632 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