27
Apr
Raising flags from a stored procedure
Firing flags from a stored procedure.
This is something that you may need to do from time to time. And it is not without it's problems.
This post deals with what you need to do to raise flag by inserting a row in the eRaisedFlag table.
This post does not deal with whether or not you should do this. I have used this technique without problems for years, and know of implementations that use this technique and still sleep soundly at night.
Firstly let us look at the structure of the eRaisedFlag table
| Column | Type | Comment |
|---|---|---|
| eSequenceNo | integer | automatically generated |
| eEngineName | text (31) | [default space] |
| eThreadNo | check | [default 0] |
| eFlagName | text (63) | |
| eFlagFolder | text (31) | folder ID (if specified) |
| eFlagData | memo | |
| eNextEntry | time |
The important points to note are :
- The eSequenceNo is automatically generated, so there is no need to insert a value
- The eEngineName is either a valid engine name or, in the case of only one engine, the defaults is SPACE
- The eThreadNo should be 0.
And not in the documentation are the following points
- The eFlagData cannot be NULL. If there is no flag data, it should be set to empty string ''
- It is not necessary to set the eNextEntry column.
- There should be a corresponding row in the eWait table for the flag you are attempting to fire.
Just to expand on this last point a bit.
Let's say I have a process called "Absence tracking", which has a flag named "Archive Folder" that moves the folder to an archive stage.
I would insert a row into eRaisedFlag like so
INSERT INTO eRaisedFlag ( eEngineName,eThreadNo,eFlagName, eFlagFolder,eFlagData ) VALUES ( ' ',0,'Archive_Folder', '0000000000000000000000000000001','' )
For this flag to fire, there would need to be a row in eWait.
SELECT * FROM eWait WHERE eFolderId = '0000000000000000000000000000001'
Would return a row like
[Quote] eSequenceNo,eFlagName,eWaitTime,eFolderId,eMapName,eEngineName,eThreadNo,ePriority,eFlagFolder,eActionName 123456,Archive_Folder,1753-01-01 00:01:00.000,0000000000000000000000000000001,,,0,0,0000000000000000000000000000001,Archive Folder [/Quote]
It is vitally important that you observe all of the gotchas I mentioned earlier. If there is no corresponding row in the eWait table then this means the flag will not fire.
One other bear trap is that you notice the flag name was "Archive Folder", and yet in the eWait table the flag name is Archive_Folder. Although it is possible to give a flag a name with spaces in, in the Designer, under the bonnet Metastorm will replace the spaces with underscores.
Good luck, and happy flag raising
- Login to post comments
