gopik
December 6th, 2002, 09:58 AM
Hello,
When i use sp_xml_removedocument passing the document handle, it shud return '0' when the document is removed from the memory. But in my case, its returning a value of '1'. Please let me know the reason behind returning a value of 1 instead of 0.
Find below the source code i have used inside the Stored Procedure.
*******************************************
CREATE PROCEDURE UpdateLocation AS
DECLARE @idoc int
DECLARE @doc varchar(1000)
SET @doc ='
<root>
<PKG PkgID="1" DateToBeArchivedPS="01022002">
<FILE FileName="AIP01_1.bin" LocType="FilePath"></FILE>
</PKG>
<PKG PkgID="2" DateToBeArchivedPS="01022003">
<FILE FileName="AIP02_2.bin" LocType="FilePath"></FILE>
</PKG>
<PKG PkgID="3" DateToBeArchivedPS="01022004">
<FILE FileName="AIP01_3.bin" LocType="FilePath"></FILE>
</PKG>
<PKG PkgID="4" DateToBeArchivedPS="01022005">
<FILE FileName="AIP02_4.bin" LocType="FilePath"></FILE>
</PKG>
</root>'
--Create an internal representation of the XML document.
declare @retStatus int
EXEC @retStatus=sp_xml_preparedocument @idoc OUTPUT, @doc
if @retStatus > 0
begin
print 'Prepare Document Failed'
print @retStatus
return 1 --failure
end
-- Execute a SELECT statement that uses the OPENXML rowset provider.
INSERT INTO Location
SELECT * FROM OPENXML(@idoc, '/root/PKG/FILE')
WITH (PkgID char(10) '../@PkgID',
DateToBeArchivedPS char(8) '../@DateToBeArchivedPS',
FileName char(50) '@FileName',
LocType char(50) '@LocType')
EXEC @retStatus=sp_xml_removedocument @idoc
if @retStatus > 0
begin
print 'Remove Document Failed'
print @retStatus
print '@@Error='
set @retStatus=@@ERROR
print @retStatus
return 1 --failure
end
return 0
GO
*******************************************
Result Set when viewed in Query Analyser
Remove Document Failed
1
@@Error=
0
1
*******************************************
When i use sp_xml_removedocument passing the document handle, it shud return '0' when the document is removed from the memory. But in my case, its returning a value of '1'. Please let me know the reason behind returning a value of 1 instead of 0.
Find below the source code i have used inside the Stored Procedure.
*******************************************
CREATE PROCEDURE UpdateLocation AS
DECLARE @idoc int
DECLARE @doc varchar(1000)
SET @doc ='
<root>
<PKG PkgID="1" DateToBeArchivedPS="01022002">
<FILE FileName="AIP01_1.bin" LocType="FilePath"></FILE>
</PKG>
<PKG PkgID="2" DateToBeArchivedPS="01022003">
<FILE FileName="AIP02_2.bin" LocType="FilePath"></FILE>
</PKG>
<PKG PkgID="3" DateToBeArchivedPS="01022004">
<FILE FileName="AIP01_3.bin" LocType="FilePath"></FILE>
</PKG>
<PKG PkgID="4" DateToBeArchivedPS="01022005">
<FILE FileName="AIP02_4.bin" LocType="FilePath"></FILE>
</PKG>
</root>'
--Create an internal representation of the XML document.
declare @retStatus int
EXEC @retStatus=sp_xml_preparedocument @idoc OUTPUT, @doc
if @retStatus > 0
begin
print 'Prepare Document Failed'
print @retStatus
return 1 --failure
end
-- Execute a SELECT statement that uses the OPENXML rowset provider.
INSERT INTO Location
SELECT * FROM OPENXML(@idoc, '/root/PKG/FILE')
WITH (PkgID char(10) '../@PkgID',
DateToBeArchivedPS char(8) '../@DateToBeArchivedPS',
FileName char(50) '@FileName',
LocType char(50) '@LocType')
EXEC @retStatus=sp_xml_removedocument @idoc
if @retStatus > 0
begin
print 'Remove Document Failed'
print @retStatus
print '@@Error='
set @retStatus=@@ERROR
print @retStatus
return 1 --failure
end
return 0
GO
*******************************************
Result Set when viewed in Query Analyser
Remove Document Failed
1
@@Error=
0
1
*******************************************