Not logged in - Login

Retrieving the Next Note Index in GP

An example of how to call the smGetNextNoteIndex stored procedure to get the next note index for a Great Plains in SQL. The following assumes that we're in the company database.

-- declare some variables we'll need for calling the stored procedure
DECLARE @RC int
DECLARE @I_sCompanyID smallint
DECLARE @I_iSQLSessionID int
DECLARE @O_mNoteIndex numeric(19,5)
DECLARE @O_iErrorState int


-- get the Company ID
select @I_sCompanyID = CMPANYID
from DYNAMICS..SY01500 a
where a.INTERID = db_name()


-- call the stored procedure. This will get the next note index and increment the current value.
EXECUTE @RC = DYNAMICS..smGetNextNoteIndex
       @I_sCompanyID
       , @I_iSQLSessionID = 1
       , @O_mNoteIndex = @O_mNoteIndex OUTPUT
       , @O_iErrorState = @O_iErrorState OUTPUT


-- output our return value (should be 0 for success)
print @RC
-- output our note index.
print @O_mNoteIndex