Hi,
I have been struggling with this for a couple of hours now:
I have the following stored procedure in SQL Server:
ALTER PROCEDURE [dbo].[NewSequenceNumber]
(
@TenantId bigint
,@SequenceId bigint
,@NextNumber decimal(18,0) output
)
AS
declare @TenantSeqId UniqueId;
BEGIN
--
select
@NextNumber = NextNumber
,@TenantSeqId = TenantSeqId
from
TenantSequence
with
(UPDLOCK)
where
TenantId = @TenantId
and
SequenceId = @SequenceId;
--
update
TenantSequence
set
NextNumber = @NextNumber +1
where
TenantSeqId = @TenantSeqId;
--
END
In Interactive Window i am issuing:
dim conn as sql::connection
?conn.open("::Name::modiloConnection")
dim args as sql::arguments
args.Clear()
?args.set("TenantId",1)
= .T.
?args.set("SequenceId",2)
= .T.
?args.set("NextNumber",0,sql::ArgumentUsage::OutputArgument)
= .T.
?conn.Execute("exec NewSequenceNumber :TenantId, :SequenceId, :NextNumber",args)
= .T.
?args.Find("NextNumber")
= Data = 0
IsNull = .F.
Name = "nextnumber"
Usage = 1
XML = <SQLArgument>
<Name>nextnumber</Name>
<Data Type="N">0</Data>
<IsNull Type="L">0</IsNull>
<Usage>Output</Usage>
</SQLArgument>
How do I access the "NextNumber" output parameter value? It should be something else than zero.
I can verify in the TenantSequence table that the sequence have been updated, so I want
to have the new value returned back to my A5 application.
Kind Regards,
Charles
I have been struggling with this for a couple of hours now:
I have the following stored procedure in SQL Server:
ALTER PROCEDURE [dbo].[NewSequenceNumber]
(
@TenantId bigint
,@SequenceId bigint
,@NextNumber decimal(18,0) output
)
AS
declare @TenantSeqId UniqueId;
BEGIN
--
select
@NextNumber = NextNumber
,@TenantSeqId = TenantSeqId
from
TenantSequence
with
(UPDLOCK)
where
TenantId = @TenantId
and
SequenceId = @SequenceId;
--
update
TenantSequence
set
NextNumber = @NextNumber +1
where
TenantSeqId = @TenantSeqId;
--
END
In Interactive Window i am issuing:
dim conn as sql::connection
?conn.open("::Name::modiloConnection")
dim args as sql::arguments
args.Clear()
?args.set("TenantId",1)
= .T.
?args.set("SequenceId",2)
= .T.
?args.set("NextNumber",0,sql::ArgumentUsage::OutputArgument)
= .T.
?conn.Execute("exec NewSequenceNumber :TenantId, :SequenceId, :NextNumber",args)
= .T.
?args.Find("NextNumber")
= Data = 0
IsNull = .F.
Name = "nextnumber"
Usage = 1
XML = <SQLArgument>
<Name>nextnumber</Name>
<Data Type="N">0</Data>
<IsNull Type="L">0</IsNull>
<Usage>Output</Usage>
</SQLArgument>
How do I access the "NextNumber" output parameter value? It should be something else than zero.
I can verify in the TenantSequence table that the sequence have been updated, so I want
to have the new value returned back to my A5 application.
Kind Regards,
Charles