General information
Category:
Databases,Tables, Views, Indexing and SQL syntax
I have this SP. When it does deletes the server returns -1 back to my apps.
The deletes go thru Ok, but the value returned is -1.
Any idea?
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[usp_UpdateConsistPersonnel](@xmlstring TEXT)
AS
DECLARE @idoc int
--Create an internal representation of the XML document.
EXEC sp_xml_preparedocument @idoc OUTPUT, @xmlstring
CREATE TABLE #TempData (
id int,
header_id int,
person int,
name nchar (100),
worknum int)
INSERT #TempData
SELECT *
FROM OpenXML(@idoc, 'VFPData/datacursor', 1)
WITH (
[id] [int],
[header_id] [int],
[person] [int],
[name] [nchar] (100),
[worknum] [int])
-- update
update consistpersonnel set
[person] = t.person,
[name] = t.name,
[worknum] = t.worknum
from #TempData t
where consistpersonnel.id = t.id
-- insert
insert consistpersonnel
select
[header_id],
[person],
[name],
[worknum]
from #TempData t
where t.id = 0
-- delete
delete consistpersonnel
from #TempData t
where consistpersonnel.id = t.id
and t.header_id = -1
exec sp_xml_removedocument @idoc
Thanks
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only