12
May

Raising flags from a stored procedure (Part 2)

Raising flags from a stored procedure part 2

This is in addition to the first post.

So we have a process with a flag called "My Flag", which starts the process.

If the flag itself takes flag data, say four items being a Key value, a message string, an amount, and a date.

So in the flag you would access the flag data like

%keyValue:=%Session.FlagData[1] %message:=%Session.FlagData[2] %amount:=%Session.FlagData[3] %flagdate:=%Session.FlagData[4]

Now as the flag starts the process, there will be no corresponding row in the EWait table.

So we could invoke the flag by inserting a row in the ERaisedFlagFolder like this

INSERT INTO eRaisedFlag(eEngineName,eThreadNo,eFlagName,eFlagFolder,eFlagData) VALUES (' ',0,'My_Flag','','My_Flag' + CHAR(9) + '999' + CHAR(9) + 'This is a message' + CHAR(9) + '55.54' + CHAR(9) + '01/01/2000' + CHAR(9))

So breaking this down

  • eEngine Name is set to single space ' '
  • eThreadNo is set to 0 always
  • eFlagName is the Flag name, with spaces replaced with underscores e.g. My_Flag
  • eFlagFolder is set to empty string ''
  • eFlagData is all of the flag data in correct sequence, seperated with tab characters

Also, and I confess I do not know why, the first item in the flag data must be the flag name. Also there must be a trailing tab character.