Initial add of defaria.com
[clearscm.git] / defaria.com / blogs / Status / archives / 000224.html
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml" id="sixapart-standard">
4 <head>
5    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
6    <meta name="generator" content="Movable Type 5.2.3" />
7
8    <link rel="stylesheet" href="http://defaria.com/blogs/Status/styles-site.css" type="text/css" />
9    <link rel="alternate" type="application/atom+xml" title="Atom" href="http://defaria.com/blogs/Status/atom.xml" />
10    <link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="http://defaria.com/blogs/Status/index.xml" />
11
12    <title>Status for Andrew DeFaria: New Trigger</title>
13
14    <link rel="start" href="http://defaria.com/blogs/Status/" title="Home" />
15    <link rel="prev" href="http://defaria.com/blogs/Status/archives/000223.html" title="Server move (cont)" />
16    <link rel="next" href="http://defaria.com/blogs/Status/archives/000225.html" title="CommentSQLCode Trigger" />
17
18    
19
20    
21
22    <script type="text/javascript" src="http://defaria.com/blogs/Status/mt-site.js"></script>
23 </head>
24 <body class="layout-one-column" onload="individualArchivesOnLoad(commenter_name)">
25    <div id="container">
26       <div id="container-inner" class="pkg">
27
28          <div id="banner">
29             <div id="banner-inner" class="pkg">
30                <h1 id="banner-header"><a href="http://defaria.com/blogs/Status/" accesskey="1">Status for Andrew DeFaria</a></h1>
31                <h2 id="banner-description">Searchable status reports and work log</h2>
32             </div>
33          </div>
34
35          <div id="pagebody">
36             <div id="pagebody-inner" class="pkg">
37                <div id="alpha">
38                   <div id="alpha-inner" class="pkg">
39
40                      <p class="content-nav">
41                         <a href="http://defaria.com/blogs/Status/archives/000223.html">&laquo; Server move (cont)</a> |
42                         <a href="http://defaria.com/blogs/Status/">Main</a>
43                         | <a href="http://defaria.com/blogs/Status/archives/000225.html">CommentSQLCode Trigger &raquo;</a>
44                      </p>
45
46                      <a id="a000224"></a>
47                      <div class="entry" id="entry-224">
48                         <h3 class="entry-header">New Trigger</h3>
49                         <div class="entry-content">
50                            <div class="entry-body">
51                               <p>Here are the requirements as I understand them for the trigger that Steve Lipson wants for the SQL checkins. Basically he desires a trigger that will capture the checkin comment and other information and insert that information in the form of a comment at the top of the checked in element. This trigger will:</p>
52
53 <ul>
54   <li>Be a postop trigger for the checkin action</li>
55   <li><b>Not</b> be an all element trigger rather it will be attached to certain file elements in the vob</li>
56   <li>Be made for the &lt;<i>fill in vob name here</i>&gt; vob</li>
57   <li>Only work on file elements - directory elements are to be skipped</li>
58   <li>Only work on file elements that have an extension of .sql - other elements will be skipped</li>
59 </ul>
60
61 <p>Roughly the psuedo code for this trigger will be:</p>
62
63 <div class="code"><pre>
64 # Get name of element and its type
65 $pname        = $ENV{CLEARCASE_PN};
66 $element_type = $ENV{CLEARCASE_ELTYPE};
67
68 # Skip directories and elements that aren't .sql
69 exit if $element_type =~ /directory/i || $pname !~ /\.sql$/i;
70
71 # Get comment and user
72 $comment   = $ENV{CLEARCASE_COMMENT};
73 $userid    = $ENV{CLEARCASE_USER};
74
75 # Format timestamp
76 $timestamp = getCurrentTime;
77
78 # Parse output of lsactivity -cact -long
79 ($activity_id, $activity_title, $activity_owner) = parseLSActivity;
80
81 # Open up $pname for reading and $pname.trig for writting
82 open PNAME_IN, $pname
83   or die "Unable to open $pname for reading - $!\n";
84
85 open PNAME_OUT, ">$pname.trig"
86   or dir "Unable to open $pname.trig for writing - $!\n";
87
88 # Add comment to top of file
89 print $PNAME_OUT &lt;&lt;END;
90 -- Date:            $timestamp
91 -- Activity: $activity_id: $activity_title
92 -- Owner:    $activity_owner ($userid)
93 -- Comment:  $comment
94 END
95
96 # Append $pname
97 while (<PNAME_IN>) {
98   print PNAME_OUT $_;
99 } # while
100
101 close PNAME;
102 close PNAME_OUT;
103
104 # Switch $pname.trig -> $pname
105 unlink $pname;
106 rename "$pname.trig", $pname;
107
108 # Allow checkin to proceed
109 exit 0;
110 </pre></div>
111                            </div>
112                            <div id="more" class="entry-more">
113                               
114                            </div>
115                         </div>
116                         <p class="entry-footer">
117                            <span class="post-footers">Posted by  on August  3, 2004  6:54 PM</span> <span class="separator">|</span> <a class="permalink" href="http://defaria.com/blogs/Status/archives/000224.html">Permalink</a>
118                         </p>
119                      </div>
120
121                      
122
123                      
124                   </div>
125                </div>
126             </div>
127          </div>
128       </div>
129    </div>
130 </body>
131 </html>