Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

sp_xml_preparedocument - Return Value Expand / Collapse
Author
Message
Posted Tuesday, March 4, 2003 4:30 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Wednesday, January 8, 2014 3:28 AM
Points: 19, Visits: 3
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




Post #10342
Posted Friday, March 7, 2003 1:21 AM
UDP Broadcaster

UDP BroadcasterUDP BroadcasterUDP BroadcasterUDP BroadcasterUDP BroadcasterUDP BroadcasterUDP BroadcasterUDP Broadcaster

Group: General Forum Members
Last Login: Saturday, February 28, 2009 6:51 AM
Points: 1,489, 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/
Post #55406
Posted Tuesday, April 15, 2014 11:14 AM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Today @ 1:55 PM
Points: 65, Visits: 196
I've always used the other way around. When 0, then fail; when >0, then success. Is the SQL Server documentation incorrect?
Post #1561994
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse