Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2006-06-13
5
Medium Priority
?
1,895 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 200 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 learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

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

Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
What we learned in Webroot's webinar on multi-vector protection.
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

730 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