File: insertJournalEntry.ipl

package info (click to toggle)
cloc 2.04-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 7,776 kB
  • sloc: perl: 29,368; cpp: 1,219; ansic: 334; asm: 267; makefile: 240; sh: 186; sql: 144; java: 136; ruby: 111; cs: 104; python: 84; pascal: 52; lisp: 50; cobol: 35; f90: 35; haskell: 35; objc: 25; php: 22; javascript: 15; fortran: 9; ml: 8; xml: 7; tcl: 2
file content (54 lines) | stat: -rw-r--r-- 1,844 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/*
https://www.ibm.com/developerworks/community/wikis/home?lang=en#!/wiki/Tivoli+Netcool+Impact/page/Policy+Language+Code+Library
 */
//--------------------------------------------------------------------
//
// insertJournalEntry- this IPL function will create a journal entry
//                     of 'text' for event with serial# 'serial' in
//                     data source 'datasource'.
//
//                     The OOB function for creating journal entries
//                     does not support 2+ entries for same serial
//                     in same second.
//
//--------------------------------------------------------------------

Function insertJournalEntry ( datasource, serial, text )
{

  UID = 16;  // user impact
  Chrono = GetDate();
  randNum = Random(100000);   // this is added to support 2+ entries made for same serial# in same second
  KeyField = serial + ":" + UID + ":" + Chrono + ":" + randNum;

  // journal entry text (jet) array - 16 "text fields" each varchar(255)
  jet = { "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" };

  index = 0;
  while( (Length(text)>0) and (index<Length(jet)) )
  {
    jet[index] = Substring(text, 0, 256);
    if(Length(text)>255)
    {
      text = Substring(text, 256, Length(text));
    }
    else
    {
      text="";
    }
    index = index + 1;
  }

  insertStmt = "insert into alerts.journal ( KeyField,Serial,UID,Chrono,Text1,Text2,Text3,Text4,Text5,Text6,Text7,Text8,Text9,T
ext10,Text11,Text12,Text13,Text14,Text15,Text16)";
  insertStmt = insertStmt + " values ( '" + KeyField + "', " + serial + ", " + UID + ", " + Chrono;
  index=0;
  while(index<Length(jet))
  {
    insertStmt = insertStmt + ",'" + Replace(jet[index], "'", "\"") + "'";
    index = index + 1;
  }
  insertStmt = insertStmt + ")";

  DirectSQL( datasource, insertStmt, False );
}