Get Compile Date and Time of OpenInsight Stored Procedure

Arev and OpenInsight both store a time stamp in the binary code of compiled stored procedures. It's difficult to view the compiled code in the system editor or debugger due to line marks and null characters causing the display to appear empty. In addition, the time stamp is also stored as an internal value which requires conversion to be useful.

The following code can be used to display the time stamp in human readable form simply by passing in the name of the routine.

Function CS_GetCompileDate(Routine)
*
* Read a compiled routine and extract the last compiled date and time stamp.
*
* Params:
* Routine - Name of the routine in the current OI application 
*
* Returns:
* Displays the date time in a message box. Also returns the value.
*
* Last Revised: 2016-04-17

Declare Function Read_Row, Index

*Name of the compiled routine. Assumes current application.
Convert @LOWER_CASE To @UPPER_CASE In Routine
Key = '$' : Routine : '*' : @APPID<1>

*Table containing compiled routines
OBJTableName = "SYSOBJ"

Open OBJTableName To Table Else 
	Call FSMsg()
	Return ''
End

Read ObjCode From Table, Key Else 
	Call Msg("Unable to read " : KEY : " from " : OBJTableName)
	Return ''
End

ObjCodeLen = Len(ObjCode)

*Extract a chunk off the end of the routine
ChunkLen = 50
Chunk = ObjCode[(ObjCodeLen - ChunkLen),ObjCodeLen]

*Look for the code segment end marker that precedes the initials and date/time
SearchToken = \00\ : \00\ : \14\ : \00\
EndCodePos = Index(Chunk, SearchToken,1)

*Trim the chunk down, start at the character after the search token.
*Resulting chunk has compiled initials and date/time
Chunk = Chunk[(EndCodePos + Len(SearchToken)), ObjCodeLen]

CompiledBy = Chunk<1>
TimeChunk = Chunk<2>

*Look for a NULL character at the end of the time chunk so we know where DateTime value ends
EndDelimPos = Index(TimeChunk, \00\, 1)

*Internal DateTime value ends 2 bytes before the end of the null char
DateTimeI = TimeChunk[1, (EndDelimPos - 2)]

*Convert to internal for display
DateTimeO = OConv(DateTimeI,'DT2/^H')

Call Msg("Progam last compiled " : DateTimeO : " by " : CompiledBy)
Return DateTimeO

After copying the code into your system you can call it from TCL (Press F5 when in OI development mode) and type:

run cs_getcompiledate YOUR_ROUTINE_NAME

The code will read the SYSOBJ table where YOUR_ROUTINE_NAME name is stored and display a message box with the last compiled date time stamp.

If you're working strictly in OpenInsight you can also use the GetLastUpdate method to find the last modified time of stored procedures and additional repository types. Thanks for the reminder Daniel!

Share this post

Comments (2)

  • anon

    Couldn't one use the Repository GetLastUpdate Method?

    Mar 23, 2016
  • Jared Bratu's picture

    Thanks for sharing, GetLastUpdate works too and for more types of repository resources than just compiled stored procedures. Getting the compiled date directly from the compiled code dates back to my days working in Arev before the repository came along.

    Jul 23, 2016

Leave a comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
By submitting this form, you accept the Mollom privacy policy.

About Us

Congruity Service is a technology solutions company bringing the best technology solutions to OpenInsight projects, Drupal sites, servers, networks, and your technology needs.