SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


sp_xml_preparedocument - Return Value


sp_xml_preparedocument - Return Value

Author
Message
AndyD
AndyD
Grasshopper
Grasshopper (21 reputation)Grasshopper (21 reputation)Grasshopper (21 reputation)Grasshopper (21 reputation)Grasshopper (21 reputation)Grasshopper (21 reputation)Grasshopper (21 reputation)Grasshopper (21 reputation)

Group: General Forum Members
Points: 21 Visits: 15
According to the documentation sp_xml_preparedocument should return 0 (success) or >0 (failure).

The following Code fails to write my error record as it appears that a value is not being returned correctly.

Has anyone else encountered this problem ?

Suggestions welcome.

Thanks

Andy

Declare @iDocError Int
Declare @Message Varchar(30)

EXECUTE @iDocError = sp_xml_preparedocument @iDoc OUTPUT, @XmlString
SELECT @iDocError
IF @iDocError <> 0 /*Can't Parse File*/
BEGIN
Set @Message = 'Problem Parsing File'
INSERT INTO ArcsXml (SourceFileName, OurStatus,RepairId)
Values(@SourceFileName ,@Messsage, -3)
END



Chris Hedgate
Chris Hedgate
SSCrazy
SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)

Group: General Forum Members
Points: 2447 Visits: 7
Andy, why should it record an error? If all goes well, as it should, the code would just go past the if-statement. If the xml-string is not valid then parsing will create an error and your code should actually stop running. I am not 100% sure, but I the only way you could run sp_xml_preparedocument without encountering an error but still getting a non-zero return value is if there is not enough memory for the operation or something like that.

--
Chris Hedgate @ Apptus Technologies (http://www.apptus.se)
http://www.sql.nu

--
Chris Hedgate http://www.hedgate.net/
Contributor to the Best of SQL Server Central volumes
Articles: http://www.sqlservercentral.com/columnists/chedgate/
N_Muller
N_Muller
Old Hand
Old Hand (344 reputation)Old Hand (344 reputation)Old Hand (344 reputation)Old Hand (344 reputation)Old Hand (344 reputation)Old Hand (344 reputation)Old Hand (344 reputation)Old Hand (344 reputation)

Group: General Forum Members
Points: 344 Visits: 434
I've always used the other way around. When 0, then fail; when >0, then success. Is the SQL Server documentation incorrect?
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search