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

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Determine next b-weekly date 12 91
Cassandra Select Query 1 77
null value 15 102
How Resolve Word 2011 Office-Database Error in Mac OS X 10 61
Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
Shadow IT is coming out of the shadows as more businesses are choosing cloud-based applications. It is now a multi-cloud world for most organizations. Simultaneously, most businesses have yet to consolidate with one cloud provider or define an offic…
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…

803 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