sp_xml_preparedocument - Return Value

  • 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

  • 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

  • I've always used the other way around. When 0, then fail; when >0, then success. Is the SQL Server documentation incorrect?

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply