 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Charles Adriano Guest
|
Posted: Tue Dec 28, 2004 10:00 pm Post subject: stored procedure |
|
|
sorry for simple question
i have a table (SQLServer 2000)
Dg0000001
Key varcahr(50)
ID bigint
i have this record
key ID
Dg0010001 1
Dg0010002 1
and i have a stored procedure for generate and reserve IDs
CREATE PROCEDURE ReserveID @Key varchar(40), @Count bigint AS
declare @NextID integer
begin transaction
update Dg0000001
set ID = ID + @Count
Where Nome = @Key
select @NextID = (ID - @Count + 1) From Dg0000001
commit transaction
RETURN @NextID
--------------------------------------------------------- use
declare @NextID integer
exec @NextID = ReserveID 'Dg0010001',1
select @NextID as FirstNextID
--------------------------------------------------------- end use
i have a D7 + DBExpres
and SQLQuery
CommandText = ReserveID
CommandType = ctStoredProc
with params
Key ftString ptInput
Count ftInteger ptInput
Ret ftInteger ptResult
when executed the code
SQLQuery.Params.ParamByName('KEY').AsString := '0010001';
SQLQuery.Params.ParamByName('Count').AsInteger := 1;
SQLQuery.execsql(true); // or SQLQuery.execsql(fakse)
showed this message
List index out of bouns(0)
Questions
1) i missing
2) how i call stored procedure with result and arguments
charles
sorry for my english
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|