Debian Codegraph @

tests/inputs/insertJournalEntry.ipl

raw
1 /*
2 https://www.ibm.com/developerworks/community/wikis/home?lang=en#!/wiki/Tivoli+Netcool+Impact/page/Policy+Language+Code+Library
3 */
4 //--------------------------------------------------------------------
5 //
6 // insertJournalEntry- this IPL function will create a journal entry
7 // of 'text' for event with serial# 'serial' in
8 // data source 'datasource'.
9 //
10 // The OOB function for creating journal entries
11 // does not support 2+ entries for same serial
12 // in same second.
13 //
14 //--------------------------------------------------------------------
15
16 Function insertJournalEntry ( datasource, serial, text )
17 {
18
19 UID = 16; // user impact
20 Chrono = GetDate();
21 randNum = Random(100000); // this is added to support 2+ entries made for same serial# in same second
22 KeyField = serial + ":" + UID + ":" + Chrono + ":" + randNum;
23
24 // journal entry text (jet) array - 16 "text fields" each varchar(255)
25 jet = { "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" };
26
27 index = 0;
28 while( (Length(text)>0) and (index<Length(jet)) )
29 {
30 jet[index] = Substring(text, 0, 256);
31 if(Length(text)>255)
32 {
33 text = Substring(text, 256, Length(text));
34 }
35 else
36 {
37 text="";
38 }
39 index = index + 1;
40 }
41
42 insertStmt = "insert into alerts.journal ( KeyField,Serial,UID,Chrono,Text1,Text2,Text3,Text4,Text5,Text6,Text7,Text8,Text9,T
43 ext10,Text11,Text12,Text13,Text14,Text15,Text16)";
44 insertStmt = insertStmt + " values ( '" + KeyField + "', " + serial + ", " + UID + ", " + Chrono;
45 index=0;
46 while(index<Length(jet))
47 {
48 insertStmt = insertStmt + ",'" + Replace(jet[index], "'", "\"") + "'";
49 index = index + 1;
50 }
51 insertStmt = insertStmt + ")";
52
53 DirectSQL( datasource, insertStmt, False );
54 }