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 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211
|
.ig >>
<STYLE TYPE="text/css">
<!--
A:link{text-decoration:none}
A:visited{text-decoration:none}
A:active{text-decoration:none}
OL,UL,P,BODY,TD,TR,TH,FORM { font-family: arial,helvetica,sans-serif;; font-size:small; color: #333333; }
H1 { font-size: x-large; font-family: arial,helvetica,sans-serif; }
H2 { font-size: large; font-family: arial,helvetica,sans-serif; }
H3 { font-size: medium; font-family: arial,helvetica,sans-serif; }
H4 { font-size: small; font-family: arial,helvetica,sans-serif; }
-->
</STYLE>
<title>ploticus: using #shell and #sql in ploticus scripts</title>
<body bgcolor=D0D0EE vlink=0000FF>
<br>
<br>
<center>
<table cellpadding=2 bgcolor=FFFFFF width=550><tr>
<td>
<table cellpadding=2 width=550><tr>
<td><br><h2>Using #shell and #sql in ploticus scripts</h2></td>
<td align=right>
<small>
<a href="../doc/welcome.html"><img src="../doc/ploticus.gif" border=0></a><br>
Version 2.33 Jun'06
<td></tr></table>
</td></tr>
<td>
<br>
<br>
.>>
.TH Using_#shell_and_#sql_in_ploticus_scripts PL "02-JUN-2006 PL ploticus.sourceforge.net"
.SH #shell and #sql
The
.ig >>
<a href="shell.html">
.>>
\0#shell
.ig >>
</a>
.>>
script directive may be used to invoke a shell command and capture the results.
.LP
The
.ig >>
<a href="sql.html">
.>>
\0#sql
.ig >>
</a>
.>>
script directive invokes an SQL command and captures the results.
The #sql directive is currently available only for builds related to the
.ig >>
<a href="http://quisp.sourceforge.net">
.>>
\0QUISP/SHSQL
.ig >>
</a>
.>>
package.
Interfaces to other databases (MySQL, Oracle, etc.) not yet available but should be
possible by coding in \fCdbinterface.c\fR.
.LP
Note that both of these are of limited value in ploticus... proc getdata already
has a \fCcommand\fR attribute for getting data from shell command results, and it
also has a \fCsql\fR attribute for running an SQL command. They should be viewed
as providing an alternative approach.
.ig >>
<br><br><br>
.>>
.SH STREAMING DATA
Here is an example of how
.ig >>
<a href="sql.html">
.>>
\0#sql
.ig >>
</a>
.>>
is to be used with
.ig >>
<a href="getdata.html">
.>>
\0proc getdata
.ig >>
</a>
.>>
:
.nf
\0 #proc getdata
\0 delim: tab
\0 data:
\0 #sql #dumptab select * from trialresults where trialnum = @TRIALNUM
.fi
.LP
For longer SQL commands a multi-line construct is available:
.nf
\0 #proc getdata
\0 delim: tab
\0 data:
\0 #sql #dumptab
\0 select trialnum, age, sex, weight, time1, time2
\0 from trialresults
\0 where trialnum = @TRIALNUM and trialdate = @TDATE
\0 #endsql
.fi
The
.ig >>
<a href="shell.html">
.>>
\0#shell
.ig >>
</a>
.>>
directive can be used similary, but this is redundant since
.ig >>
<a href="getdata.html">
.>>
\0proc getdata
.ig >>
</a>
.>>
already has a \fCcommand\fR attribute.
.ig >>
<br><br><br>
.>>
.SH SETTING VARIABLES
These directives may be used to set variables for plot labels, etc.
For example:
.nf
\0 #sql #load select fullname from tsyms where tickersym = @TSYM
\0
\0 #proc annotate
\0 location: min max-0.2
\0 text: @fullname
\0
.fi
.LP
Here is an example where the results of a shell command may be used to
set variables:
.nf
\0 // submit the command..
\0 #shell #processrows cat mydata | grep "^Jan"
\0 // get one result rows and parse out fields..
\0 #call $shellrow( A, B, C )
\0
\0 #proc annotate
\0 location: min max-0.2
\0 text: @A @B
.ig >>
<br><br><br>
.>>
.SH DRIVING LOOPS
These directives may be used to drive loops that iterate once per
row of results. For example:
.nf
\0 // get a list of cases
\0 #sql #processrows select caseid from cases
\0 #while $sqlrow() = 0
\0 // get data for a case
\0 #proc getdata
\0 delim: tab
\0 data:
\0 #sql2 #dumptab select * from casedata where caseid = @caseid
\0 ... plot the case
\0
\0 #endloop
.fi
.LP
.ig >>
<a href="shell.html">
.>>
\0#shell
.ig >>
</a>
.>>
may be used similary.
.ig >>
<br>
<br>
</td></tr>
<td align=right>
<a href="../doc/welcome.html">
<img src="../doc/ploticus.gif" border=0></a><br><small>data display engine <br>
<a href="../doc/Copyright.html">Copyright Steve Grubb</a>
<br>
<br>
<center>
<img src="../gallery/all.gif">
</center>
</td></tr>
</table>
<br>
<center>
Ploticus is hosted at http://ploticus.sourceforge.net <br>
<img src="http://sourceforge.net/sflogo.php?group_id=38453" width="88" height="31" border="0" alt="SourceForge Logo">
</center>
.>>
|