Problem With Files
Posted: Tue Mar 04, 2003 12:12 am
I have used the keymgmtnextvalue routine to create a new server routine of my own.
I have copied the code and altered it to take one more param that decides the starting number in the sequnce instead of 1 that he uses by default.
iam getting the following error when i try to compile it
Unable to write record DSU.MySequence to file DSU_BP
also if i try to Test the routine i get this error
Unable to write test harness
the code that i have in my routine is
*************************************************************************
* Copyright (c) 1997-2001 Ascential Software Inc. - All Rights Reserved. *
* This code may be copied on condition that this copyright *
* notice is included as is in any code derived from this source. *
*************************************************************************
*
* Routine to generate a sequential number. The argument is a string used to
* identify the sequence.
*
* NOTE: This routine will only work when the sequence is being accessed by
* one process at a time.
*
* The routine uses a UniVerse file to store the next number to use. This
* value is stored in a record named after the supplied argument. The
* routine reads the number once, then increments and stores the value
* in common storage, writing the next value back to file each time.
*
* Declare shared memory storage.
Common /MySeq/ Initialized, NextVal, SeqFile
EQUATE RoutineName TO 'MySequence'
If NOT(Initialized) Then
* Not initialised. Attempt to open the file.
Initialized = 1
Open "SDKSequences" TO SeqFile Else
* Open failed. Create the sequence file.
EXECUTE "CREATE.FILE SDKSequences 2 1 1"
Open "SDKSequences" TO SeqFile Else Ans = -1
End
* Attempt to read the named record from the file.
Readu NextVal From SeqFile, SequenceName Else
* No record by that name.
* Start new sequence at InitialValue.
NextVal = InitialValue
End
End
Ans = NextVal
* Increment the sequence value, and write back to file.
NextVal = NextVal + 1
Writeu NextVal On SeqFile, SequenceName Else Ans = -1
Programmer Analyst,
Cognizant,
Chennai.
I have copied the code and altered it to take one more param that decides the starting number in the sequnce instead of 1 that he uses by default.
iam getting the following error when i try to compile it
Unable to write record DSU.MySequence to file DSU_BP
also if i try to Test the routine i get this error
Unable to write test harness
the code that i have in my routine is
*************************************************************************
* Copyright (c) 1997-2001 Ascential Software Inc. - All Rights Reserved. *
* This code may be copied on condition that this copyright *
* notice is included as is in any code derived from this source. *
*************************************************************************
*
* Routine to generate a sequential number. The argument is a string used to
* identify the sequence.
*
* NOTE: This routine will only work when the sequence is being accessed by
* one process at a time.
*
* The routine uses a UniVerse file to store the next number to use. This
* value is stored in a record named after the supplied argument. The
* routine reads the number once, then increments and stores the value
* in common storage, writing the next value back to file each time.
*
* Declare shared memory storage.
Common /MySeq/ Initialized, NextVal, SeqFile
EQUATE RoutineName TO 'MySequence'
If NOT(Initialized) Then
* Not initialised. Attempt to open the file.
Initialized = 1
Open "SDKSequences" TO SeqFile Else
* Open failed. Create the sequence file.
EXECUTE "CREATE.FILE SDKSequences 2 1 1"
Open "SDKSequences" TO SeqFile Else Ans = -1
End
* Attempt to read the named record from the file.
Readu NextVal From SeqFile, SequenceName Else
* No record by that name.
* Start new sequence at InitialValue.
NextVal = InitialValue
End
End
Ans = NextVal
* Increment the sequence value, and write back to file.
NextVal = NextVal + 1
Writeu NextVal On SeqFile, SequenceName Else Ans = -1
Programmer Analyst,
Cognizant,
Chennai.